blob: afd5986a8cf59007d2046f0c543894bee49da360 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05302 * Copyright (c) 2012-2016 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"
Jeff Johnson295189b2012-06-20 16:38:30 -070079#define CSR_NUM_IBSS_START_CHANNELS_50 4
80#define CSR_NUM_IBSS_START_CHANNELS_24 3
81#define CSR_DEF_IBSS_START_CHANNEL_50 36
82#define CSR_DEF_IBSS_START_CHANNEL_24 1
Abhishek Singhadc66102016-08-16 10:50:09 +053083/* 15 seconds, for WPA, WPA2, CCKM */
84#define CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD (15 * PAL_TIMER_TO_SEC_UNIT)
85/* 120 seconds, for WPS */
86#define CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD (120 * PAL_TIMER_TO_SEC_UNIT)
Jeff Johnson295189b2012-06-20 16:38:30 -070087/*---------------------------------------------------------------------------
88 OBIWAN recommends [8 10]% : pick 9%
89---------------------------------------------------------------------------*/
90#define CSR_VCC_UL_MAC_LOSS_THRESHOLD 9
Jeff Johnson295189b2012-06-20 16:38:30 -070091/*---------------------------------------------------------------------------
92 OBIWAN recommends -85dBm
93---------------------------------------------------------------------------*/
94#define CSR_VCC_RSSI_THRESHOLD 80
95#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD 500 //ms
96#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS 2000 //ms
97#define CSR_MIN_TL_STAT_QUERY_PERIOD 500 //ms
98#define CSR_DIAG_LOG_STAT_PERIOD 3000 //ms
Jeff Johnson295189b2012-06-20 16:38:30 -070099//We use constatnt 4 here
100//This macro returns true when higher AC parameter is bigger than lower AC for a difference
101//The bigger the number, the less chance of TX
102//It must put lower AC as the first parameter.
103#define SME_DETECT_AC_WEIGHT_DIFF(loAC, hiAC) (v_BOOL_t)(((hiAC) > (loAC)) ? (((hiAC)-(loAC)) > 4) : 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700104//Flag to send/do not send disassoc frame over the air
105#define CSR_DONT_SEND_DISASSOC_OVER_THE_AIR 1
Jeff Johnson295189b2012-06-20 16:38:30 -0700106#define RSSI_HACK_BMPS (-40)
Jeff Johnsone7245742012-09-05 17:12:55 -0700107#define MAX_CB_VALUE_IN_INI (2)
108
Srinivas Girigowda577ed652013-08-14 11:38:29 -0700109#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
110static tANI_BOOLEAN bRoamScanOffloadStarted = VOS_FALSE;
111#endif
112
Agrawal Ashishe4288772016-01-13 14:10:10 +0530113#define MAX_PWR_FCC_CHAN_12 8
114#define MAX_PWR_FCC_CHAN_13 2
115
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 ------------------------------------------------------------------------*/
124#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700125int diagAuthTypeFromCSRType(eCsrAuthType authType)
126{
127 int n = AUTH_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700128 switch(authType)
129 {
130 case eCSR_AUTH_TYPE_SHARED_KEY:
131 n = AUTH_SHARED;
132 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700133 case eCSR_AUTH_TYPE_WPA:
134 n = AUTH_WPA_EAP;
135 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700136 case eCSR_AUTH_TYPE_WPA_PSK:
137 n = AUTH_WPA_PSK;
138 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700139 case eCSR_AUTH_TYPE_RSN:
Abhishek Singhae408032014-09-25 17:22:04 +0530140#ifdef WLAN_FEATURE_11W
141 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
142#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700143 n = AUTH_WPA2_EAP;
144 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700145 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700146#ifdef WLAN_FEATURE_11W
147 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
148#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700149 n = AUTH_WPA2_PSK;
150 break;
151#ifdef FEATURE_WLAN_WAPI
152 case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE:
153 n = AUTH_WAPI_CERT;
154 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700155 case eCSR_AUTH_TYPE_WAPI_WAI_PSK:
156 n = AUTH_WAPI_PSK;
157 break;
158#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -0700159 default:
160 break;
161 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700162 return (n);
163}
Jeff Johnson295189b2012-06-20 16:38:30 -0700164int diagEncTypeFromCSRType(eCsrEncryptionType encType)
165{
166 int n = ENC_MODE_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700167 switch(encType)
168 {
169 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
170 case eCSR_ENCRYPT_TYPE_WEP40:
171 n = ENC_MODE_WEP40;
172 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700173 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
174 case eCSR_ENCRYPT_TYPE_WEP104:
175 n = ENC_MODE_WEP104;
176 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700177 case eCSR_ENCRYPT_TYPE_TKIP:
178 n = ENC_MODE_TKIP;
179 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700180 case eCSR_ENCRYPT_TYPE_AES:
181 n = ENC_MODE_AES;
182 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700183#ifdef FEATURE_WLAN_WAPI
184 case eCSR_ENCRYPT_TYPE_WPI:
185 n = ENC_MODE_SMS4;
186 break;
187#endif /* FEATURE_WLAN_WAPI */
188 default:
189 break;
190 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700191 return (n);
192}
Jeff Johnson295189b2012-06-20 16:38:30 -0700193#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700194static const tANI_U8 csrStartIbssChannels50[ CSR_NUM_IBSS_START_CHANNELS_50 ] = { 36, 40, 44, 48};
195static const tANI_U8 csrStartIbssChannels24[ CSR_NUM_IBSS_START_CHANNELS_24 ] = { 1, 6, 11 };
Jeff Johnson295189b2012-06-20 16:38:30 -0700196static void initConfigParam(tpAniSirGlobal pMac);
197static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
198 eCsrRoamCompleteResult Result, void *Context );
199static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId,
200 tCsrRoamProfile *pProfile,
201 tANI_BOOLEAN *pfSameIbss );
202static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirSmeNewBssInfo *pNewBss );
203static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -0700204 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes);
205static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700206eHalStatus csrInitGetChannels(tpAniSirGlobal pMac);
207static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result );
208eHalStatus csrRoamOpen(tpAniSirGlobal pMac);
209eHalStatus csrRoamClose(tpAniSirGlobal pMac);
210void csrRoamMICErrorTimerHandler(void *pv);
211void csrRoamTKIPCounterMeasureTimerHandler(void *pv);
212tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2);
213
214static eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval);
215static eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId);
216static void csrRoamRoamingTimerHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700217eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval);
218eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac);
219static void csrRoamWaitForKeyTimeOutHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700220static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnsone7245742012-09-05 17:12:55 -0700221static eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700222static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo );
223eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
224 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
225 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
226 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
227 tANI_U8 *pKeyRsc );
228static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
229 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes,
230 tCsrRoamProfile *pProfile );
231void csrRoamStatisticsTimerHandler(void *pv);
232void csrRoamStatsGlobalClassDTimerHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700233static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid);
234VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
235 v_U8_t rssiNotification,
236 void * context);
237static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId);
238void csrRoamVccTrigger(tpAniSirGlobal pMac);
239eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId);
240/*
241 pStaEntry is no longer invalid upon the return of this function.
242*/
243static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700244static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,tANI_U8 operationChn, eCsrBand *pBand );
Jeff Johnson295189b2012-06-20 16:38:30 -0700245static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700246tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
247 tDblLinkList *pStaList,
248 tCsrStatsClientReqInfo *pStaEntry);
249void csrRoamStatsClientTimerHandler(void *pv);
250tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
251 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId);
252void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
253 tCsrStatsCallback callback, tANI_U8 staId, void *pContext);
Jeff Johnsone7245742012-09-05 17:12:55 -0700254void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats);
Jeff Johnson295189b2012-06-20 16:38:30 -0700255void csrRoamTlStatsTimerHandler(void *pv);
256void csrRoamPeStatsTimerHandler(void *pv);
257tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
258void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry);
259tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
260eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac);
261static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac );
262static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc );
263static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId );
264static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
265 tCsrRoamSetKey *pSetKey, tANI_U32 roamId );
266//static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand );
267static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
268void csrRoamReissueRoamCommand(tpAniSirGlobal pMac);
269#ifdef FEATURE_WLAN_BTAMP_UT_RF
270void csrRoamJoinRetryTimerHandler(void *pv);
271#endif
Atul Mittalb849d5a2014-07-29 12:08:39 +0530272void limInitOperatingClasses( tHalHandle hHal );
Jeff Johnson295189b2012-06-20 16:38:30 -0700273extern void SysProcessMmhMsg(tpAniSirGlobal pMac, tSirMsgQ* pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700274extern void btampEstablishLogLinkHdlr(void* pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700275static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700276void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand);
Jeff Johnson295189b2012-06-20 16:38:30 -0700277
278//Initialize global variables
279static void csrRoamInitGlobals(tpAniSirGlobal pMac)
280{
281 if(pMac)
282 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800283 vos_mem_zero(&csrRoamRoamSession, sizeof(csrRoamRoamSession));
284 pMac->roam.roamSession = csrRoamRoamSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700285 }
286 return;
287}
288
Jeff Johnson295189b2012-06-20 16:38:30 -0700289static void csrRoamDeInitGlobals(tpAniSirGlobal pMac)
290{
291 if(pMac)
292 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800293 pMac->roam.roamSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700294 }
295 return;
296}
Jeff Johnson295189b2012-06-20 16:38:30 -0700297eHalStatus csrOpen(tpAniSirGlobal pMac)
298{
299 eHalStatus status = eHAL_STATUS_SUCCESS;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530300#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700301 static uNvTables nvTables;
302 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700303 v_REGDOMAIN_t regId;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530304#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700305 tANI_U32 i;
306
307 do
308 {
309 /* Initialize CSR Roam Globals */
310 csrRoamInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700311 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
312 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i);
313
314 initConfigParam(pMac);
315 if(!HAL_STATUS_SUCCESS((status = csrScanOpen(pMac))))
316 break;
317 if(!HAL_STATUS_SUCCESS((status = csrRoamOpen(pMac))))
318 break;
319 pMac->roam.nextRoamId = 1; //Must not be 0
320 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.statsClientReqList)))
321 break;
322 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.peStatsReqList)))
323 break;
324 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.roamCmdPendingList)))
325 break;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530326
327#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700328 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
329 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
330 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530331 vos_mem_copy(pMac->scan.countryCodeDefault, nvTables.defaultCountryTable.countryCode,
332 WNI_CFG_COUNTRY_CODE_LEN);
333 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700334 }
335 else
336 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800337 smsLog( pMac, LOGE, FL(" fail to get NV_FIELD_IMAGE") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700338 //hardcoded for now
339 pMac->scan.countryCodeDefault[0] = 'U';
340 pMac->scan.countryCodeDefault[1] = 'S';
341 pMac->scan.countryCodeDefault[2] = 'I';
342 //status = eHAL_STATUS_SUCCESS;
343 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700344 smsLog( pMac, LOG1, FL(" country Code from nvRam %.2s"), pMac->scan.countryCodeDefault );
Kiet Lam6c583332013-10-14 05:37:09 +0530345
346 if (!('0' == pMac->scan.countryCodeDefault[0] &&
347 '0' == pMac->scan.countryCodeDefault[1]))
348 {
349 csrGetRegulatoryDomainForCountry(pMac, pMac->scan.countryCodeDefault,
350 &regId, COUNTRY_NV);
351 }
352 else
353 {
354 regId = REGDOMAIN_WORLD;
355 }
Abhishek Singha306a442013-11-07 18:39:01 +0530356 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700357 pMac->scan.domainIdDefault = regId;
358 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Kiet Lam64c1b492013-07-12 13:56:44 +0530359 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
360 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700361 status = csrInitGetChannels( pMac );
Mihir Shetee1093ba2014-01-21 20:13:32 +0530362#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700363 }while(0);
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530364
Jeff Johnson295189b2012-06-20 16:38:30 -0700365 return (status);
366}
367
Mihir Shetee1093ba2014-01-21 20:13:32 +0530368/* --------------------------------------------------------------------------
369 \fn csrInitChannels
370 \brief This function must be called to initialize CSR channel lists
371 \return eHalStatus
372 ----------------------------------------------------------------------------*/
373eHalStatus csrInitChannels(tpAniSirGlobal pMac)
374{
375 eHalStatus status = eHAL_STATUS_SUCCESS;
376 static uNvTables nvTables;
377 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530378 v_REGDOMAIN_t regId = REGDOMAIN_WORLD;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530379
380 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
381 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
382 {
383 vos_mem_copy(pMac->scan.countryCodeDefault,
384 nvTables.defaultCountryTable.countryCode,
385 WNI_CFG_COUNTRY_CODE_LEN);
386 }
387 else
388 {
389 smsLog( pMac, LOGE, FL(" fail to get NV_FIELD_IMAGE") );
390 //hardcoded for now
391 pMac->scan.countryCodeDefault[0] = 'U';
392 pMac->scan.countryCodeDefault[1] = 'S';
393 pMac->scan.countryCodeDefault[2] = 'I';
394 }
395 smsLog( pMac, LOG1, FL(" country Code from nvRam %.2s"), pMac->scan.countryCodeDefault );
396
Mihir Shetee1093ba2014-01-21 20:13:32 +0530397 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
398 pMac->scan.domainIdDefault = regId;
399 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
400 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
401 WNI_CFG_COUNTRY_CODE_LEN);
Agrawal Ashish0b6984f2014-04-05 18:35:45 +0530402 vos_mem_copy(pMac->scan.countryCodeElected, pMac->scan.countryCodeDefault,
403 WNI_CFG_COUNTRY_CODE_LEN);
Agarwal Ashishcd9b8e62014-07-21 19:48:24 +0530404 vos_mem_copy(pMac->scan.countryCode11d, pMac->scan.countryCodeDefault,
405 WNI_CFG_COUNTRY_CODE_LEN);
Mihir Shetee1093ba2014-01-21 20:13:32 +0530406 status = csrInitGetChannels( pMac );
Agrawal Ashish0b6984f2014-04-05 18:35:45 +0530407 csrClearVotesForCountryInfo(pMac);
Mihir Shetee1093ba2014-01-21 20:13:32 +0530408
409 return status;
410}
411
Mihir Shete04206452014-11-20 17:50:58 +0530412#ifdef CONFIG_ENABLE_LINUX_REG
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530413eHalStatus csrInitChannelsForCC(tpAniSirGlobal pMac, driver_load_type init)
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530414{
415 eHalStatus status = eHAL_STATUS_SUCCESS;
416 v_REGDOMAIN_t regId = REGDOMAIN_WORLD;
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530417 tANI_U8 cc[WNI_CFG_COUNTRY_CODE_LEN];
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530418
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530419 /* In case of driver load ; driver need to get channel
420 * list with default Countrycode.
421 * In case of SSR; driver need to get channel list
422 * with old country code. 0 is for init and
423 * 1 is for reinit
424 */
425 switch (init)
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530426 {
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530427 case INIT:
428 vos_mem_copy(cc, pMac->scan.countryCodeDefault,
429 WNI_CFG_COUNTRY_CODE_LEN);
430 if (!('0' == cc[0] &&
431 '0' == cc[1]))
432 {
433 csrGetRegulatoryDomainForCountry(pMac, cc,
434 &regId, COUNTRY_NV);
435 }
436 else
437 {
438 return status;
439 }
440 pMac->scan.domainIdDefault = regId;
441 break;
442 case REINIT:
443 vos_getCurrentCountryCode(&cc[0]);
444 status = csrGetRegulatoryDomainForCountry(pMac,
445 cc, &regId, COUNTRY_QUERY);
446 break;
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530447 }
448 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530449 pMac->scan.domainIdCurrent = regId;
450 vos_mem_copy(pMac->scan.countryCodeCurrent, cc,
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530451 WNI_CFG_COUNTRY_CODE_LEN);
452 status = csrInitGetChannels( pMac );
Agarwal Ashishf3298ac2014-07-26 19:34:17 +0530453
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530454 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
455 FL("Current Country is %c%c "), pMac->scan.countryCodeCurrent[0],
456 pMac->scan.countryCodeCurrent[1]);
457
Agarwal Ashishf3298ac2014-07-26 19:34:17 +0530458 /* reset info based on new cc, and we are done */
459 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE);
460 csrScanFilterResults(pMac);
461
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530462 return status;
463}
Mihir Shete04206452014-11-20 17:50:58 +0530464#endif
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530465
Jeff Johnson295189b2012-06-20 16:38:30 -0700466eHalStatus csrSetRegInfo(tHalHandle hHal, tANI_U8 *apCntryCode)
467{
468 eHalStatus status = eHAL_STATUS_SUCCESS;
469 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
470 v_REGDOMAIN_t regId;
471 v_U8_t cntryCodeLength;
Jeff Johnson295189b2012-06-20 16:38:30 -0700472 if(NULL == apCntryCode)
473 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +0530474 smsLog( pMac, LOGE, FL(" Invalid country Code Pointer") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700475 return eHAL_STATUS_FAILURE;
476 }
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +0530477 smsLog( pMac, LOG1, FL(" country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700478 /* To get correct Regulatory domain from NV table
479 * 2 character Country code should be used
480 * 3rd charater is optional for indoor/outdoor setting */
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700481 cntryCodeLength = WNI_CFG_COUNTRY_CODE_LEN;
482/*
Jeff Johnson295189b2012-06-20 16:38:30 -0700483 cntryCodeLength = strlen(apCntryCode);
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700484
485 if (cntryCodeLength > WNI_CFG_COUNTRY_CODE_LEN)
486 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800487 smsLog( pMac, LOGW, FL(" Invalid Country Code Length") );
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700488 return eHAL_STATUS_FAILURE;
489 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700490*/
Kiet Lam6c583332013-10-14 05:37:09 +0530491 status = csrGetRegulatoryDomainForCountry(pMac, apCntryCode, &regId,
492 COUNTRY_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -0700493 if (status != eHAL_STATUS_SUCCESS)
494 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700495 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700496 return status;
497 }
Abhishek Singha306a442013-11-07 18:39:01 +0530498 status = WDA_SetRegDomain(hHal, regId, eSIR_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700499 if (status != eHAL_STATUS_SUCCESS)
500 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700501 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700502 return status;
503 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700504 pMac->scan.domainIdDefault = regId;
505 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Jeff Johnson295189b2012-06-20 16:38:30 -0700506 /* Clear CC field */
Kiet Lam64c1b492013-07-12 13:56:44 +0530507 vos_mem_set(pMac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN, 0);
508
Jeff Johnson295189b2012-06-20 16:38:30 -0700509 /* Copy 2 or 3 bytes country code */
Kiet Lam64c1b492013-07-12 13:56:44 +0530510 vos_mem_copy(pMac->scan.countryCodeDefault, apCntryCode, cntryCodeLength);
511
Jeff Johnson295189b2012-06-20 16:38:30 -0700512 /* If 2 bytes country code, 3rd byte must be filled with space */
513 if((WNI_CFG_COUNTRY_CODE_LEN - 1) == cntryCodeLength)
514 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530515 vos_mem_set(pMac->scan.countryCodeDefault + 2, 1, 0x20);
Jeff Johnson295189b2012-06-20 16:38:30 -0700516 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530517 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
518 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700519 status = csrInitGetChannels( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -0700520 return status;
521}
Jeff Johnson295189b2012-06-20 16:38:30 -0700522eHalStatus csrSetChannels(tHalHandle hHal, tCsrConfigParam *pParam )
523{
524 eHalStatus status = eHAL_STATUS_SUCCESS;
525 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
526 tANI_U8 index = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +0530527 vos_mem_copy(pParam->Csr11dinfo.countryCode, pMac->scan.countryCodeCurrent,
528 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700529 for ( index = 0; index < pMac->scan.base20MHzChannels.numChannels ; index++)
530 {
531 pParam->Csr11dinfo.Channels.channelList[index] = pMac->scan.base20MHzChannels.channelList[ index ];
532 pParam->Csr11dinfo.ChnPower[index].firstChannel = pMac->scan.base20MHzChannels.channelList[ index ];
533 pParam->Csr11dinfo.ChnPower[index].numChannels = 1;
534 pParam->Csr11dinfo.ChnPower[index].maxtxPower = pMac->scan.defaultPowerTable[index].pwr;
535 }
536 pParam->Csr11dinfo.Channels.numChannels = pMac->scan.base20MHzChannels.numChannels;
537
538 return status;
539}
Jeff Johnson295189b2012-06-20 16:38:30 -0700540eHalStatus csrClose(tpAniSirGlobal pMac)
541{
542 eHalStatus status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800543
Jeff Johnson295189b2012-06-20 16:38:30 -0700544 csrRoamClose(pMac);
545 csrScanClose(pMac);
546 csrLLClose(&pMac->roam.statsClientReqList);
547 csrLLClose(&pMac->roam.peStatsReqList);
548 csrLLClose(&pMac->roam.roamCmdPendingList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700549 /* DeInit Globals */
550 csrRoamDeInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700551 return (status);
552}
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530553
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800554eHalStatus csrUpdateChannelList(tpAniSirGlobal pMac)
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530555{
556 tSirUpdateChanList *pChanList;
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800557 tCsrScanStruct *pScan = &pMac->scan;
Agarwal Ashish738843c2014-09-25 12:27:56 +0530558 tANI_U32 numChan = 0;
559 tANI_U32 bufLen ;
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530560 vos_msg_t msg;
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +0530561 tANI_U8 i, j;
562 tANI_U8 num_channel = 0;
563 tANI_U8 channel_state;
564 tANI_U8 cfgnumChannels = 0;
565 tANI_U8 *cfgChannelList = NULL;
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530566
Atul Mittalb849d5a2014-07-29 12:08:39 +0530567 limInitOperatingClasses((tHalHandle)pMac);
Agarwal Ashish738843c2014-09-25 12:27:56 +0530568 numChan = sizeof(pMac->roam.validChannelList);
569
570 if ( !HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac,
571 (tANI_U8 *)pMac->roam.validChannelList, &numChan)))
572 {
573 smsLog( pMac, LOGE, "Failed to get Channel list from CFG");
574 return eHAL_STATUS_FAILED_ALLOC;
575 }
576
577 bufLen = sizeof(tSirUpdateChanList) +
578 (sizeof(tSirUpdateChanParam) * (numChan - 1));
579
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530580 pChanList = (tSirUpdateChanList *) vos_mem_malloc(bufLen);
581 if (!pChanList)
582 {
583 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
584 "Failed to allocate memory for tSirUpdateChanList");
585 return eHAL_STATUS_FAILED_ALLOC;
586 }
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +0530587 vos_mem_zero(pChanList, bufLen);
588
589 smsLog(pMac, LOG1, FL("fEnableDFSChnlScan %d"),
590 pMac->scan.fEnableDFSChnlScan);
591
592 for (i = 0; i < numChan; i++)
593 {
594 channel_state =
595 vos_nv_getChannelEnabledState(pMac->roam.validChannelList[i]);
596
597 if((pMac->scan.fEnableDFSChnlScan == DFS_CHNL_SCAN_DISABLED)
598 && (channel_state == NV_CHANNEL_DFS))
599 {
600 continue;
601 }
602 pChanList->chanParam[num_channel].chanId =
603 pMac->roam.validChannelList[i];
604 pChanList->chanParam[num_channel].pwr =
605 cfgGetRegulatoryMaxTransmitPower(pMac,
606 pScan->defaultPowerTable[i].chanId);
Agrawal Ashishe4288772016-01-13 14:10:10 +0530607 if (pMac->scan.fcc_constraint)
608 {
609 if (pChanList->chanParam[num_channel].chanId == 12)
610 {
611 pChanList->chanParam[num_channel].pwr = MAX_PWR_FCC_CHAN_12;
612 smsLog(pMac, LOG1,
613 "fcc_constraint is set, txpower for channel 12 is 8db ");
614 }
615 if (pChanList->chanParam[num_channel].chanId == 13)
616 {
617 pChanList->chanParam[num_channel].pwr = MAX_PWR_FCC_CHAN_13;
618 smsLog(pMac, LOG1,
619 "fcc_constraint is set, txpower for channel 13 is 2db ");
620 }
621 }
622
Sushant Kaushikece4b562015-04-09 18:27:33 +0530623 if (!pChanList->chanParam[num_channel].pwr)
624 {
625 smsLog(pMac, LOGE, FL("Power level is zero for channel %d "
626 "setting to default %d"),
627 pChanList->chanParam[num_channel].chanId,
628 TX_POWER_DEFAULT);
629 pChanList->chanParam[num_channel].pwr = TX_POWER_DEFAULT;
630 }
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +0530631 if (channel_state == NV_CHANNEL_DFS)
632 pChanList->chanParam[num_channel].dfsSet = VOS_TRUE;
633 else
634 pChanList->chanParam[num_channel].dfsSet = VOS_FALSE;
635
636 /* When DFS mode is 2, mark static channels as active */
637 if (pMac->scan.fEnableDFSChnlScan == DFS_CHNL_SCAN_ENABLED_ACTIVE)
638 {
639 cfgnumChannels =
640 pMac->roam.neighborRoamInfo.cfgParams.channelInfo.numOfChannels;
641 cfgChannelList =
642 pMac->roam.neighborRoamInfo.cfgParams.channelInfo.ChannelList;
643
644 if (cfgChannelList)
645 {
646 for(j=0; j< cfgnumChannels; j++)
647 {
648 if (CSR_IS_CHANNEL_DFS(cfgChannelList[j]) &&
649 (pMac->roam.validChannelList[i] == cfgChannelList[j]))
650 {
651 pChanList->chanParam[num_channel].dfsSet = VOS_FALSE;
652 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
653 "%s Marked DFS ch %d as active\n", __func__,
654 cfgChannelList[j]);
655 }
656 }
657 }
658 else
659 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
660 "%s cfgChannelList is NULL \n", __func__);
661 }
662
663 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
664 "%s Supported Channel: %d dfsSet %d pwr: %d \n", __func__,
665 pChanList->chanParam[num_channel].chanId,
666 pChanList->chanParam[num_channel].dfsSet,
667 pChanList->chanParam[num_channel].pwr);
668 num_channel++;
669 }
670 pChanList->regId = csrGetCurrentRegulatoryDomain(pMac);
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530671
Sachin Ahuja2d15ff62015-06-30 12:46:44 +0530672 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
673 "%s : regID : %d \n", __func__,
674 pChanList->regId);
675
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530676 msg.type = WDA_UPDATE_CHAN_LIST_REQ;
677 msg.reserved = 0;
678 msg.bodyptr = pChanList;
Padma, Santhosh Kumar778d8382015-03-04 17:41:22 +0530679 pChanList->numChan = num_channel;
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +0530680 MTRACE(vos_trace(VOS_MODULE_ID_SME,
681 TRACE_CODE_SME_TX_WDA_MSG, NO_SESSION, msg.type));
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530682 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
683 {
684 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
685 "%s: Failed to post msg to WDA", __func__);
686 vos_mem_free(pChanList);
687 return eHAL_STATUS_FAILURE;
688 }
689
690 return eHAL_STATUS_SUCCESS;
691}
692
Jeff Johnson295189b2012-06-20 16:38:30 -0700693eHalStatus csrStart(tpAniSirGlobal pMac)
694{
695 eHalStatus status = eHAL_STATUS_SUCCESS;
696 tANI_U32 i;
697
698 do
699 {
700 //save the global vos context
701 pMac->roam.gVosContext = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
702 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
703 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, i );
704
705 status = csrRoamStart(pMac);
706 if(!HAL_STATUS_SUCCESS(status)) break;
707 pMac->scan.f11dInfoApplied = eANI_BOOLEAN_FALSE;
708 status = pmcRegisterPowerSaveCheck(pMac, csrCheckPSReady, pMac);
709 if(!HAL_STATUS_SUCCESS(status)) break;
710 pMac->roam.sPendingCommands = 0;
711 csrScanEnable(pMac);
712#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
713 status = csrNeighborRoamInit(pMac);
714#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
715 pMac->roam.tlStatsReqInfo.numClient = 0;
716 pMac->roam.tlStatsReqInfo.periodicity = 0;
717 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
718 //init the link quality indication also
719 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_MIN_IND;
720 if(!HAL_STATUS_SUCCESS(status))
721 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800722 smsLog(pMac, LOGW, " csrStart: Couldn't Init HO control blk ");
Jeff Johnson295189b2012-06-20 16:38:30 -0700723 break;
724 }
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530725
Jeff Johnson295189b2012-06-20 16:38:30 -0700726 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700727#if defined(ANI_LOGDUMP)
728 csrDumpInit(pMac);
729#endif //#if defined(ANI_LOGDUMP)
Jeff Johnson295189b2012-06-20 16:38:30 -0700730 return (status);
731}
732
Kiet Lama72a2322013-11-15 11:18:11 +0530733eHalStatus csrStop(tpAniSirGlobal pMac, tHalStopType stopType)
Jeff Johnson295189b2012-06-20 16:38:30 -0700734{
735 tANI_U32 sessionId;
736 tANI_U32 i;
737
738 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
739 {
mukul sharmabab477d2015-06-11 17:14:55 +0530740 csrRoamCloseSession(pMac, sessionId, TRUE, TRUE, NULL, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -0700741 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700742 csrScanDisable(pMac);
743 pMac->scan.fCancelIdleScan = eANI_BOOLEAN_FALSE;
744 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700745 csrLLPurge( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_TRUE );
746
747#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
748 csrNeighborRoamClose(pMac);
749#endif
750 csrScanFlushResult(pMac); //Do we want to do this?
Jeff Johnson295189b2012-06-20 16:38:30 -0700751 // deregister from PMC since we register during csrStart()
752 // (ignore status since there is nothing we can do if it fails)
753 (void) pmcDeregisterPowerSaveCheck(pMac, csrCheckPSReady);
Jeff Johnson295189b2012-06-20 16:38:30 -0700754 //Reset the domain back to the deault
755 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800756 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700757
758 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
759 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530760 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i );
Jeff Johnson295189b2012-06-20 16:38:30 -0700761 pMac->roam.curSubState[i] = eCSR_ROAM_SUBSTATE_NONE;
762 }
763
Kiet Lama72a2322013-11-15 11:18:11 +0530764#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
765 /* When HAL resets all the context information
766 * in HAL is lost, so we might need to send the
767 * scan offload request again when it comes
768 * out of reset for scan offload to be functional
769 */
770 if (HAL_STOP_TYPE_SYS_RESET == stopType)
771 {
772 bRoamScanOffloadStarted = VOS_FALSE;
773 }
774#endif
775
Jeff Johnson295189b2012-06-20 16:38:30 -0700776 return (eHAL_STATUS_SUCCESS);
777}
778
Jeff Johnson295189b2012-06-20 16:38:30 -0700779eHalStatus csrReady(tpAniSirGlobal pMac)
780{
781 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700782 csrScanGetSupportedChannels( pMac );
783 //WNI_CFG_VALID_CHANNEL_LIST should be set by this time
784 //use it to init the background scan list
785 csrInitBGScanChannelList(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700786 //Store the AC weights in TL for later use
787 WLANTL_GetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
Jeff Johnson295189b2012-06-20 16:38:30 -0700788 status = csrInitChannelList( pMac );
789 if ( ! HAL_STATUS_SUCCESS( status ) )
790 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800791 smsLog( pMac, LOGE, "csrInitChannelList failed during csrReady with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700792 status );
793 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700794 return (status);
795}
Jeff Johnson295189b2012-06-20 16:38:30 -0700796void csrSetDefaultDot11Mode( tpAniSirGlobal pMac )
797{
798 v_U32_t wniDot11mode = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700799 wniDot11mode = csrTranslateToWNICfgDot11Mode(pMac,pMac->roam.configParam.uCfgDot11Mode);
800 ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, wniDot11mode, NULL, eANI_BOOLEAN_FALSE);
801}
Jeff Johnson295189b2012-06-20 16:38:30 -0700802void csrSetGlobalCfgs( tpAniSirGlobal pMac )
803{
Jeff Johnsone7245742012-09-05 17:12:55 -0700804
Jeff Johnson295189b2012-06-20 16:38:30 -0700805 ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
806 ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
807 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
808 ((pMac->roam.configParam.Is11hSupportEnabled) ? pMac->roam.configParam.Is11dSupportEnabled : pMac->roam.configParam.Is11dSupportEnabled),
809 NULL, eANI_BOOLEAN_FALSE);
810 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnsone7245742012-09-05 17:12:55 -0700811 /* 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
812 * Once session is established we will use the session related params stored in PE session for CB mode
813 */
814 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, !!(pMac->roam.configParam.channelBondingMode5GHz), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700815 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, pMac->roam.configParam.HeartbeatThresh24, NULL, eANI_BOOLEAN_FALSE);
816
817 //Update the operating mode to configured value during initialization,
818 //So that client can advertise full capabilities in Probe request frame.
819 csrSetDefaultDot11Mode( pMac );
820}
821
Jeff Johnson295189b2012-06-20 16:38:30 -0700822eHalStatus csrRoamOpen(tpAniSirGlobal pMac)
823{
824 eHalStatus status = eHAL_STATUS_SUCCESS;
825 tANI_U32 i;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +0530826 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700827 do
828 {
829 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
830 {
831 pSession = CSR_GET_SESSION( pMac, i );
832 pSession->roamingTimerInfo.pMac = pMac;
833 pSession->roamingTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
834 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700835 pMac->roam.WaitForKeyTimerInfo.pMac = pMac;
836 pMac->roam.WaitForKeyTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530837 status = vos_timer_init(&pMac->roam.hTimerWaitForKey, VOS_TIMER_TYPE_SW,
838 csrRoamWaitForKeyTimeOutHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -0700839 &pMac->roam.WaitForKeyTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530840 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700841 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800842 smsLog(pMac, LOGE, FL("cannot allocate memory for WaitForKey time out timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700843 break;
844 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530845 status = vos_timer_init(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
846 VOS_TIMER_TYPE_SW, csrRoamTlStatsTimerHandler, pMac);
847 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700848 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800849 smsLog(pMac, LOGE, FL("cannot allocate memory for summary Statistics timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700850 return eHAL_STATUS_FAILURE;
851 }
852 }while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700853 return (status);
854}
855
Jeff Johnson295189b2012-06-20 16:38:30 -0700856eHalStatus csrRoamClose(tpAniSirGlobal pMac)
857{
858 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700859 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
860 {
mukul sharmabab477d2015-06-11 17:14:55 +0530861 csrRoamCloseSession(pMac, sessionId, TRUE, TRUE, NULL, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -0700862 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530863 vos_timer_stop(&pMac->roam.hTimerWaitForKey);
864 vos_timer_destroy(&pMac->roam.hTimerWaitForKey);
865 vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
866 vos_timer_destroy(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -0700867 return (eHAL_STATUS_SUCCESS);
868}
869
Jeff Johnson295189b2012-06-20 16:38:30 -0700870eHalStatus csrRoamStart(tpAniSirGlobal pMac)
871{
872 (void)pMac;
Jeff Johnson295189b2012-06-20 16:38:30 -0700873 return (eHAL_STATUS_SUCCESS);
874}
875
Jeff Johnson295189b2012-06-20 16:38:30 -0700876void csrRoamStop(tpAniSirGlobal pMac, tANI_U32 sessionId)
877{
878 csrRoamStopRoamingTimer(pMac, sessionId);
879 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
880 csrRoamDeregStatisticsReq(pMac);
881}
Jeff Johnson295189b2012-06-20 16:38:30 -0700882eHalStatus csrRoamGetConnectState(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrConnectState *pState)
883{
884 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Srinivas Girigowdac84c57c2013-02-19 17:41:56 -0800885 if ( CSR_IS_SESSION_VALID(pMac, sessionId) && (NULL != pState) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700886 {
887 status = eHAL_STATUS_SUCCESS;
888 *pState = pMac->roam.roamSession[sessionId].connectState;
889 }
890 return (status);
891}
892
Jeff Johnson295189b2012-06-20 16:38:30 -0700893eHalStatus csrRoamCopyConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
894{
895 eHalStatus status = eHAL_STATUS_FAILURE;
896 tANI_U32 size = 0;
897 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -0700898
899 if(!pSession)
900 {
901 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
902 return eHAL_STATUS_FAILURE;
903 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700904
905 if(pProfile)
906 {
907 if(pSession->pConnectBssDesc)
908 {
909 do
910 {
911 size = pSession->pConnectBssDesc->length + sizeof(pSession->pConnectBssDesc->length);
912 if(size)
913 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530914 pProfile->pBssDesc = vos_mem_malloc(size);
915 if ( NULL != pProfile->pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -0700916 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530917 vos_mem_copy(pProfile->pBssDesc,
918 pSession->pConnectBssDesc, size);
919 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700920 }
921 else
922 break;
923 }
924 else
925 {
926 pProfile->pBssDesc = NULL;
927 }
928 pProfile->AuthType = pSession->connectedProfile.AuthType;
929 pProfile->EncryptionType = pSession->connectedProfile.EncryptionType;
930 pProfile->mcEncryptionType = pSession->connectedProfile.mcEncryptionType;
931 pProfile->BSSType = pSession->connectedProfile.BSSType;
932 pProfile->operationChannel = pSession->connectedProfile.operationChannel;
933 pProfile->CBMode = pSession->connectedProfile.CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +0530934 vos_mem_copy(&pProfile->bssid, &pSession->connectedProfile.bssid,
935 sizeof(tCsrBssid));
936 vos_mem_copy(&pProfile->SSID, &pSession->connectedProfile.SSID,
937 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -0700938#ifdef WLAN_FEATURE_VOWIFI_11R
939 if (pSession->connectedProfile.MDID.mdiePresent)
940 {
941 pProfile->MDID.mdiePresent = 1;
942 pProfile->MDID.mobilityDomain = pSession->connectedProfile.MDID.mobilityDomain;
943 }
944 else
945 {
946 pProfile->MDID.mdiePresent = 0;
947 pProfile->MDID.mobilityDomain = 0;
948 }
949#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800950#ifdef FEATURE_WLAN_ESE
951 pProfile->isESEAssoc = pSession->connectedProfile.isESEAssoc;
952 if (csrIsAuthTypeESE(pSession->connectedProfile.AuthType))
Jeff Johnson295189b2012-06-20 16:38:30 -0700953 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800954 vos_mem_copy (pProfile->eseCckmInfo.krk,
955 pSession->connectedProfile.eseCckmInfo.krk,
Kiet Lam64c1b492013-07-12 13:56:44 +0530956 CSR_KRK_KEY_LEN);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800957 pProfile->eseCckmInfo.reassoc_req_num=
958 pSession->connectedProfile.eseCckmInfo.reassoc_req_num;
959 pProfile->eseCckmInfo.krk_plumbed =
960 pSession->connectedProfile.eseCckmInfo.krk_plumbed;
Jeff Johnson295189b2012-06-20 16:38:30 -0700961 }
962#endif
963 }while(0);
964 }
965 }
966
967 return (status);
968}
969
Jeff Johnson295189b2012-06-20 16:38:30 -0700970eHalStatus csrRoamGetConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
971{
972 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700973
974 if((csrIsConnStateConnected(pMac, sessionId)) ||
975 (csrIsConnStateIbss(pMac, sessionId)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700976 {
977 if(pProfile)
978 {
979 status = csrRoamCopyConnectProfile(pMac, sessionId, pProfile);
980 }
981 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700982 return (status);
983}
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700984
Jeff Johnson295189b2012-06-20 16:38:30 -0700985eHalStatus csrRoamFreeConnectProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile)
986{
987 eHalStatus status = eHAL_STATUS_SUCCESS;
988
Kiet Lam64c1b492013-07-12 13:56:44 +0530989 if (pProfile->pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -0700990 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530991 vos_mem_free(pProfile->pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700992 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530993 if (pProfile->pAddIEAssoc)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700994 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530995 vos_mem_free(pProfile->pAddIEAssoc);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700996 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530997 vos_mem_set(pProfile, sizeof(tCsrRoamConnectedProfile), 0);
998
Jeff Johnson295189b2012-06-20 16:38:30 -0700999 pProfile->AuthType = eCSR_AUTH_TYPE_UNKNOWN;
1000 return (status);
1001}
1002
Jeff Johnson295189b2012-06-20 16:38:30 -07001003static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo )
1004{
1005 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001006 if( pConnectedInfo->pbFrames )
1007 {
Kiet Lam64c1b492013-07-12 13:56:44 +05301008 vos_mem_free(pConnectedInfo->pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -07001009 pConnectedInfo->pbFrames = NULL;
1010 }
1011 pConnectedInfo->nBeaconLength = 0;
1012 pConnectedInfo->nAssocReqLength = 0;
1013 pConnectedInfo->nAssocRspLength = 0;
1014 pConnectedInfo->staId = 0;
1015#ifdef WLAN_FEATURE_VOWIFI_11R
1016 pConnectedInfo->nRICRspLength = 0;
1017#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001018#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001019 pConnectedInfo->nTspecIeLength = 0;
1020#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001021 return ( status );
1022}
1023
Jeff Johnson295189b2012-06-20 16:38:30 -07001024
1025
Jeff Johnsone7245742012-09-05 17:12:55 -07001026
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07001027void csrReleaseCommandPreauth(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1028{
1029 csrReinitPreauthCmd(pMac, pCommand);
1030 csrReleaseCommand( pMac, pCommand );
1031}
1032
Jeff Johnson295189b2012-06-20 16:38:30 -07001033void csrReleaseCommandRoam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1034{
1035 csrReinitRoamCmd(pMac, pCommand);
1036 csrReleaseCommand( pMac, pCommand );
1037}
1038
Jeff Johnson295189b2012-06-20 16:38:30 -07001039void csrReleaseCommandScan(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1040{
1041 csrReinitScanCmd(pMac, pCommand);
1042 csrReleaseCommand( pMac, pCommand );
1043}
1044
Jeff Johnson295189b2012-06-20 16:38:30 -07001045void csrReleaseCommandWmStatusChange(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1046{
1047 csrReinitWmStatusChangeCmd(pMac, pCommand);
1048 csrReleaseCommand( pMac, pCommand );
1049}
1050
Jeff Johnson295189b2012-06-20 16:38:30 -07001051void csrReinitSetKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1052{
Kiet Lam64c1b492013-07-12 13:56:44 +05301053 vos_mem_set(&pCommand->u.setKeyCmd, sizeof(tSetKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001054}
1055
Jeff Johnson295189b2012-06-20 16:38:30 -07001056void csrReinitRemoveKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1057{
Kiet Lam64c1b492013-07-12 13:56:44 +05301058 vos_mem_set(&pCommand->u.removeKeyCmd, sizeof(tRemoveKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07001059}
1060
Jeff Johnson295189b2012-06-20 16:38:30 -07001061void csrReleaseCommandSetKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1062{
1063 csrReinitSetKeyCmd(pMac, pCommand);
1064 csrReleaseCommand( pMac, pCommand );
1065}
Jeff Johnson295189b2012-06-20 16:38:30 -07001066void csrReleaseCommandRemoveKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
1067{
1068 csrReinitRemoveKeyCmd(pMac, pCommand);
1069 csrReleaseCommand( pMac, pCommand );
1070}
Abhishek Singh7b2d0812016-04-28 11:44:29 +05301071
1072/**
1073 * csr_is_disconnect_full_power_cmd() - Check if command is for
1074 * disconnect or for fullpower
1075 * @command: command to check
1076 *
1077 * Return: true if disconnect or full power command else false
1078 */
1079bool csr_is_disconnect_full_power_cmd(tSmeCmd *command)
1080{
1081 switch (command->command) {
1082 case eSmeCommandRoam:
1083 if (CSR_IS_DISCONNECT_COMMAND(command))
1084 return true;
1085 break;
1086 case eSmeCommandWmStatusChange:
1087 case eSmeCommandExitImps:
1088 case eSmeCommandExitBmps:
1089 case eSmeCommandExitUapsd:
1090 case eSmeCommandExitWowl:
1091 return true;
1092 default:
1093 return false;
1094 }
1095 return false;
1096}
1097
Jeff Johnson295189b2012-06-20 16:38:30 -07001098void csrAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping )
1099{
1100
1101 if( eSmeCsrCommandMask & pCommand->command )
1102 {
1103 switch (pCommand->command)
1104 {
1105 case eSmeCommandScan:
Jeff Johnson1250df42012-12-10 14:31:52 -08001106 // We need to inform the requester before dropping the scan command
Jeff Johnsonc7c54b12013-11-17 11:49:03 -08001107 smsLog( pMac, LOGW, "%s: Drop scan reason %d callback %p",
1108 __func__, pCommand->u.scanCmd.reason,
1109 pCommand->u.scanCmd.callback);
Jeff Johnson295189b2012-06-20 16:38:30 -07001110 if (NULL != pCommand->u.scanCmd.callback)
1111 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001112 smsLog( pMac, LOGW, "%s callback scan requester", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001113 csrScanCallCallback(pMac, pCommand, eCSR_SCAN_ABORT);
1114 }
1115 csrReleaseCommandScan( pMac, pCommand );
1116 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07001117 case eSmeCommandRoam:
1118 csrReleaseCommandRoam( pMac, pCommand );
1119 break;
1120
1121 case eSmeCommandWmStatusChange:
1122 csrReleaseCommandWmStatusChange( pMac, pCommand );
1123 break;
1124
1125 case eSmeCommandSetKey:
1126 csrReleaseCommandSetKey( pMac, pCommand );
1127 break;
1128
1129 case eSmeCommandRemoveKey:
1130 csrReleaseCommandRemoveKey( pMac, pCommand );
1131 break;
1132
1133 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001134 smsLog( pMac, LOGW, " CSR abort standard command %d", pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -07001135 csrReleaseCommand( pMac, pCommand );
1136 break;
1137 }
1138 }
1139}
1140
Jeff Johnson295189b2012-06-20 16:38:30 -07001141void csrRoamSubstateChange( tpAniSirGlobal pMac, eCsrRoamSubState NewSubstate, tANI_U32 sessionId)
1142{
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05301143 smsLog(pMac, LOG1, FL("CSR RoamSubstate: [ %s <== %s ]"),
1144 macTraceGetcsrRoamSubState(NewSubstate),
1145 macTraceGetcsrRoamSubState(pMac->roam.curSubState[sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07001146
Jeff Johnson295189b2012-06-20 16:38:30 -07001147 if(pMac->roam.curSubState[sessionId] == NewSubstate)
1148 {
1149 return;
Jeff Johnsone7245742012-09-05 17:12:55 -07001150 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001151 pMac->roam.curSubState[sessionId] = NewSubstate;
1152}
1153
Jeff Johnson295189b2012-06-20 16:38:30 -07001154eCsrRoamState csrRoamStateChange( tpAniSirGlobal pMac, eCsrRoamState NewRoamState, tANI_U8 sessionId)
1155{
1156 eCsrRoamState PreviousState;
1157
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05301158 smsLog(pMac, LOG1, FL("CSR RoamState[%hu]: [ %s <== %s ]"), sessionId,
1159 macTraceGetcsrRoamState(NewRoamState),
1160 macTraceGetcsrRoamState(pMac->roam.curState[sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07001161
1162 PreviousState = pMac->roam.curState[sessionId];
1163
1164 if ( NewRoamState != pMac->roam.curState[sessionId] )
1165 {
1166 // Whenever we transition OUT of the Roaming state, clear the Roaming substate...
1167 if ( CSR_IS_ROAM_JOINING(pMac, sessionId) )
1168 {
1169 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
1170 }
1171
1172 pMac->roam.curState[sessionId] = NewRoamState;
1173 }
1174 return( PreviousState );
1175}
1176
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001177void csrAssignRssiForCategory(tpAniSirGlobal pMac, tANI_S8 bestApRssi, tANI_U8 catOffset)
Jeff Johnson295189b2012-06-20 16:38:30 -07001178{
1179 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001180 if(catOffset)
1181 {
1182 pMac->roam.configParam.bCatRssiOffset = catOffset;
1183 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
1184 {
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001185 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 -07001186 }
1187 }
1188}
1189
Jeff Johnson295189b2012-06-20 16:38:30 -07001190static void initConfigParam(tpAniSirGlobal pMac)
1191{
1192 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001193 pMac->roam.configParam.agingCount = CSR_AGING_COUNT;
Sandeep Puligilla60342762014-01-30 21:05:37 +05301194 pMac->roam.configParam.channelBondingMode24GHz =
1195 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
1196 pMac->roam.configParam.channelBondingMode5GHz =
1197 WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001198 pMac->roam.configParam.phyMode = eCSR_DOT11_MODE_TAURUS;
1199 pMac->roam.configParam.eBand = eCSR_BAND_ALL;
1200 pMac->roam.configParam.uCfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
1201 pMac->roam.configParam.FragmentationThreshold = eCSR_DOT11_FRAG_THRESH_DEFAULT;
1202 pMac->roam.configParam.HeartbeatThresh24 = 40;
1203 pMac->roam.configParam.HeartbeatThresh50 = 40;
1204 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
1205 pMac->roam.configParam.Is11dSupportEnabledOriginal = eANI_BOOLEAN_FALSE;
1206 pMac->roam.configParam.Is11eSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001207 pMac->roam.configParam.Is11hSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001208 pMac->roam.configParam.RTSThreshold = 2346;
1209 pMac->roam.configParam.shortSlotTime = eANI_BOOLEAN_TRUE;
1210 pMac->roam.configParam.WMMSupportMode = eCsrRoamWmmAuto;
1211 pMac->roam.configParam.ProprietaryRatesEnabled = eANI_BOOLEAN_TRUE;
1212 pMac->roam.configParam.TxRate = eCSR_TX_RATE_AUTO;
1213 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1214 pMac->roam.configParam.scanAgeTimeNCNPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_NO_PS;
1215 pMac->roam.configParam.scanAgeTimeNCPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_W_PS;
1216 pMac->roam.configParam.scanAgeTimeCNPS = CSR_SCAN_AGING_TIME_CONNECT_NO_PS;
1217 pMac->roam.configParam.scanAgeTimeCPS = CSR_SCAN_AGING_TIME_CONNECT_W_PS;
1218 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
1219 {
1220 pMac->roam.configParam.BssPreferValue[i] = i;
1221 }
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001222 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, CSR_DEFAULT_RSSI_DB_GAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07001223 pMac->roam.configParam.nRoamingTime = CSR_DEFAULT_ROAMING_TIME;
1224 pMac->roam.configParam.fEnforce11dChannels = eANI_BOOLEAN_FALSE;
1225 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001226 pMac->roam.configParam.fEnforceCountryCodeMatch = eANI_BOOLEAN_FALSE;
1227 pMac->roam.configParam.fEnforceDefaultDomain = eANI_BOOLEAN_FALSE;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05301228 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001229 pMac->roam.configParam.nActiveMaxChnTime = CSR_ACTIVE_MAX_CHANNEL_TIME;
1230 pMac->roam.configParam.nActiveMinChnTime = CSR_ACTIVE_MIN_CHANNEL_TIME;
1231 pMac->roam.configParam.nPassiveMaxChnTime = CSR_PASSIVE_MAX_CHANNEL_TIME;
1232 pMac->roam.configParam.nPassiveMinChnTime = CSR_PASSIVE_MIN_CHANNEL_TIME;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001233 pMac->roam.configParam.nActiveMaxChnTimeBtc = CSR_ACTIVE_MAX_CHANNEL_TIME_BTC;
1234 pMac->roam.configParam.nActiveMinChnTimeBtc = CSR_ACTIVE_MIN_CHANNEL_TIME_BTC;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001235 pMac->roam.configParam.disableAggWithBtc = eANI_BOOLEAN_TRUE;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001236#ifdef WLAN_AP_STA_CONCURRENCY
1237 pMac->roam.configParam.nActiveMaxChnTimeConc = CSR_ACTIVE_MAX_CHANNEL_TIME_CONC;
1238 pMac->roam.configParam.nActiveMinChnTimeConc = CSR_ACTIVE_MIN_CHANNEL_TIME_CONC;
1239 pMac->roam.configParam.nPassiveMaxChnTimeConc = CSR_PASSIVE_MAX_CHANNEL_TIME_CONC;
1240 pMac->roam.configParam.nPassiveMinChnTimeConc = CSR_PASSIVE_MIN_CHANNEL_TIME_CONC;
1241 pMac->roam.configParam.nRestTimeConc = CSR_REST_TIME_CONC;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001242 pMac->roam.configParam.nNumStaChanCombinedConc = CSR_NUM_STA_CHAN_COMBINED_CONC;
1243 pMac->roam.configParam.nNumP2PChanCombinedConc = CSR_NUM_P2P_CHAN_COMBINED_CONC;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001244#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001245 pMac->roam.configParam.IsIdleScanEnabled = TRUE; //enable the idle scan by default
1246 pMac->roam.configParam.nTxPowerCap = CSR_MAX_TX_POWER;
1247 pMac->roam.configParam.statsReqPeriodicity = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD;
1248 pMac->roam.configParam.statsReqPeriodicityInPS = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001249#ifdef WLAN_FEATURE_VOWIFI_11R
1250 pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported = 0;
1251#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001252#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1253 pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries = 3;
1254 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold = 120;
1255 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold = 125;
1256 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = 20;
1257 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = 40;
1258 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod = 200;
1259 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels = 3;
1260 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[0] = 1;
1261 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[1] = 6;
1262 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[2] = 11;
1263 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod = 20000; //20 seconds
Srinivas Girigowdade697412013-02-14 16:31:48 -08001264 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod = 0;
Mukul Sharma20aa6582014-08-07 21:36:12 +05301265 pMac->roam.configParam.neighborRoamConfig.nNeighborInitialForcedRoamTo5GhEnable = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001266#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001267#ifdef WLAN_FEATURE_11AC
1268 pMac->roam.configParam.nVhtChannelWidth = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ + 1;
1269#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001270
1271 pMac->roam.configParam.addTSWhenACMIsOff = 0;
1272 pMac->roam.configParam.fScanTwice = eANI_BOOLEAN_FALSE;
Mohit Khanna349bc392012-09-11 17:24:52 -07001273
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001274 //Remove this code once SLM_Sessionization is supported
1275 //BMPS_WORKAROUND_NOT_NEEDED
Jeff Johnsone7245742012-09-05 17:12:55 -07001276 pMac->roam.configParam.doBMPSWorkaround = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001277
Jeff Johnsone7245742012-09-05 17:12:55 -07001278}
Jeff Johnson295189b2012-06-20 16:38:30 -07001279eCsrBand csrGetCurrentBand(tHalHandle hHal)
1280{
1281 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1282 return pMac->roam.configParam.bandCapability;
1283}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001284
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001285
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001286#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001287/*
1288 This function flushes the roam scan cache
1289*/
1290eHalStatus csrFlushRoamScanRoamChannelList(tpAniSirGlobal pMac)
1291{
1292 eHalStatus status = eHAL_STATUS_SUCCESS;
1293 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1294
1295 /* Free up the memory first (if required) */
1296 if (NULL != pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
1297 {
1298 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1299 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
1300 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
1301 }
1302 return status;
1303}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001304#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001305
1306
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001307#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001308/*
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001309 This function flushes the roam scan cache
Srinivas Girigowdade697412013-02-14 16:31:48 -08001310*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001311eHalStatus csrFlushCfgBgScanRoamChannelList(tpAniSirGlobal pMac)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001312{
1313 eHalStatus status = eHAL_STATUS_SUCCESS;
1314 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1315
1316 /* Free up the memory first (if required) */
1317 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1318 {
1319 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
1320 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001321 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001322 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001323 return status;
1324}
1325
1326
1327
1328/*
1329 This function flushes the roam scan cache and creates fresh cache
1330 based on the input channel list
1331*/
1332eHalStatus csrCreateBgScanRoamChannelList(tpAniSirGlobal pMac,
1333 const tANI_U8 *pChannelList,
1334 const tANI_U8 numChannels)
1335{
1336 eHalStatus status = eHAL_STATUS_SUCCESS;
1337 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1338
Srinivas Girigowdade697412013-02-14 16:31:48 -08001339 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = numChannels;
1340
1341 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
1342 vos_mem_malloc(pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1343
1344 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1345 {
1346 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
1347 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
1348 return eHAL_STATUS_RESOURCES;
1349 }
1350
1351 /* Update the roam global structure */
Kiet Lam64c1b492013-07-12 13:56:44 +05301352 vos_mem_copy(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
1353 pChannelList,
1354 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001355 return status;
1356}
1357
1358/* This function modifies the bgscan channel list set via config ini or
1359 runtime, whenever the band changes.
1360 if the band is auto, then no operation is performed on the channel list
1361 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1362 if the band is 5G, then make sure channel list contains only 5G valid channels
1363*/
1364eHalStatus csrUpdateBgScanConfigIniChannelList(tpAniSirGlobal pMac,
1365 eCsrBand eBand)
1366{
1367 eHalStatus status = eHAL_STATUS_SUCCESS;
1368 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1369 tANI_U8 outNumChannels = 0;
1370 tANI_U8 inNumChannels = 0;
1371 tANI_U8 *inPtr = NULL;
1372 tANI_U8 i = 0;
1373 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1374
1375 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1376
1377 {
1378 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1379 "No update required for channel list "
1380 "either cfg.ini channel list is not set up or "
1381 "auto band (Band %d)", eBand);
1382 return status;
1383 }
1384
1385 inNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
1386 inPtr = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
1387 if (eCSR_BAND_24 == eBand)
1388 {
1389 for (i = 0; i < inNumChannels; i++)
1390 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001391 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
Srinivas Girigowdade697412013-02-14 16:31:48 -08001392 {
1393 ChannelList[outNumChannels++] = inPtr[i];
1394 }
1395 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001396 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001397 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001398 }
1399 else if (eCSR_BAND_5G == eBand)
1400 {
1401 for (i = 0; i < inNumChannels; i++)
1402 {
1403 /* Add 5G Non-DFS channel */
1404 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
Srinivas Girigowda56076852013-08-20 14:00:50 -07001405 csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001406 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1407 {
1408 ChannelList[outNumChannels++] = inPtr[i];
1409 }
1410 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001411 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001412 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001413 }
1414 else if (eCSR_BAND_ALL == eBand)
1415 {
1416 for (i = 0; i < inNumChannels; i++)
1417 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001418 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001419 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1420 {
1421 ChannelList[outNumChannels++] = inPtr[i];
1422 }
1423 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001424 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001425 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001426 }
1427 else
1428 {
1429 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1430 "Invalid band, No operation carried out (Band %d)", eBand);
1431 status = eHAL_STATUS_INVALID_PARAMETER;
1432 }
1433
1434 return status;
1435}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001436#endif
1437
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001438#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001439/* This function modifies the roam scan channel list as per AP neighbor
1440 report; AP neighbor report may be empty or may include only other AP
1441 channels; in any case, we merge the channel list with the learned occupied
1442 channels list.
1443 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1444 if the band is 5G, then make sure channel list contains only 5G valid channels
1445*/
1446eHalStatus csrCreateRoamScanChannelList(tpAniSirGlobal pMac,
1447 tANI_U8 *pChannelList,
1448 tANI_U8 numChannels,
1449 const eCsrBand eBand)
1450{
1451 eHalStatus status = eHAL_STATUS_SUCCESS;
1452 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1453 tANI_U8 outNumChannels = 0;
1454 tANI_U8 inNumChannels = numChannels;
1455 tANI_U8 *inPtr = pChannelList;
1456 tANI_U8 i = 0;
1457 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1458 tANI_U8 tmpChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1459 tANI_U8 mergedOutputNumOfChannels = 0;
1460 tpCsrChannelInfo currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
1461
1462 /* Create a Union of occupied channel list learnt by the DUT along with the Neighbor
1463 * report Channels. This increases the chances of the DUT to get a candidate AP while
1464 * roaming even if the Neighbor Report is not able to provide sufficient information. */
1465 if (pMac->scan.occupiedChannels.numChannels)
1466 {
1467 csrNeighborRoamMergeChannelLists(pMac,
1468 &pMac->scan.occupiedChannels.channelList[0],
1469 pMac->scan.occupiedChannels.numChannels,
1470 inPtr,
1471 inNumChannels,
1472 &mergedOutputNumOfChannels);
1473 inNumChannels = mergedOutputNumOfChannels;
1474 }
1475
1476 if (eCSR_BAND_24 == eBand)
1477 {
1478 for (i = 0; i < inNumChannels; i++)
1479 {
1480 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
1481 {
1482 ChannelList[outNumChannels++] = inPtr[i];
1483 }
1484 }
1485 }
1486 else if (eCSR_BAND_5G == eBand)
1487 {
1488 for (i = 0; i < inNumChannels; i++)
1489 {
1490 /* Add 5G Non-DFS channel */
1491 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
1492 csrRoamIsChannelValid(pMac, inPtr[i]) &&
1493 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1494 {
1495 ChannelList[outNumChannels++] = inPtr[i];
1496 }
1497 }
1498 }
1499 else if (eCSR_BAND_ALL == eBand)
1500 {
1501 for (i = 0; i < inNumChannels; i++)
1502 {
1503 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
1504 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1505 {
1506 ChannelList[outNumChannels++] = inPtr[i];
1507 }
1508 }
1509 }
1510 else
1511 {
1512 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1513 "Invalid band, No operation carried out (Band %d)", eBand);
1514 return eHAL_STATUS_INVALID_PARAMETER;
1515 }
1516
1517 /* if roaming within band is enabled, then select only the
1518 in band channels .
1519 This is required only if the band capability is set to ALL,
1520 E.g., if band capability is only 2.4G then all the channels in the
1521 list are already filtered for 2.4G channels, hence ignore this check*/
1522
1523 if ((eCSR_BAND_ALL == eBand) && CSR_IS_ROAM_INTRA_BAND_ENABLED(pMac))
1524 {
Mukul Sharma20aa6582014-08-07 21:36:12 +05301525 csrNeighborRoamChannelsFilterByBand(
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001526 pMac,
1527 ChannelList,
1528 outNumChannels,
1529 tmpChannelList,
Mukul Sharma20aa6582014-08-07 21:36:12 +05301530 &outNumChannels,
1531 GetRFBand(pMac->roam.neighborRoamInfo.currAPoperationChannel));
Kiet Lamf2f201e2013-11-16 21:24:16 +05301532 vos_mem_copy(ChannelList,
1533 tmpChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001534 }
1535
1536 /* Prepare final roam scan channel list */
1537 if(outNumChannels)
1538 {
1539 /* Clear the channel list first */
1540 if (NULL != currChannelListInfo->ChannelList)
1541 {
1542 vos_mem_free(currChannelListInfo->ChannelList);
1543 currChannelListInfo->ChannelList = NULL;
1544 currChannelListInfo->numOfChannels = 0;
1545 }
1546
1547 currChannelListInfo->ChannelList = vos_mem_malloc(outNumChannels * sizeof(tANI_U8));
1548 if (NULL == currChannelListInfo->ChannelList)
1549 {
1550 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
1551 "Failed to allocate memory for roam scan channel list");
1552 currChannelListInfo->numOfChannels = 0;
1553 return VOS_STATUS_E_RESOURCES;
1554 }
Kiet Lamf2f201e2013-11-16 21:24:16 +05301555 vos_mem_copy(currChannelListInfo->ChannelList,
1556 ChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001557 }
1558 return status;
1559}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001560#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001561
Jeff Johnson295189b2012-06-20 16:38:30 -07001562eHalStatus csrSetBand(tHalHandle hHal, eCsrBand eBand)
1563{
1564 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1565 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001566 if (CSR_IS_PHY_MODE_A_ONLY(pMac) &&
1567 (eBand == eCSR_BAND_24))
1568 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001569 /* DOT11 mode configured to 11a only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001570 request to change the band to 2.4 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001571 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001572 "failed to set band cfg80211 = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001573 pMac->roam.configParam.uCfgDot11Mode, eBand);
1574 return eHAL_STATUS_INVALID_PARAMETER;
1575 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001576 if ((CSR_IS_PHY_MODE_B_ONLY(pMac) ||
1577 CSR_IS_PHY_MODE_G_ONLY(pMac)) &&
1578 (eBand == eCSR_BAND_5G))
1579 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001580 /* DOT11 mode configured to 11b/11g only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001581 request to change the band to 5 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001582 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001583 "failed to set band dot11mode = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001584 pMac->roam.configParam.uCfgDot11Mode, eBand);
1585 return eHAL_STATUS_INVALID_PARAMETER;
1586 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001587 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001588 "Band changed to %u (0 - ALL, 1 - 2.4 GHZ, 2 - 5GHZ)", eBand);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001589 pMac->roam.configParam.eBand = eBand;
1590 pMac->roam.configParam.bandCapability = eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001591 csrScanGetSupportedChannels( pMac );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001592#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -08001593 if (!csrRoamIsRoamOffloadScanEnabled(pMac))
1594 csrUpdateBgScanConfigIniChannelList( pMac, eBand );
Srinivas Girigowdade697412013-02-14 16:31:48 -08001595#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001596 status = csrInitGetChannels( pMac );
1597 if (eHAL_STATUS_SUCCESS == status)
1598 csrInitChannelList( hHal );
1599 return status;
1600}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001601
1602
Jeff Johnsone7245742012-09-05 17:12:55 -07001603/* The funcns csrConvertCBIniValueToPhyCBState and csrConvertPhyCBStateToIniValue have been
1604 * introduced to convert the ini value to the ENUM used in csr and MAC for CB state
1605 * Ideally we should have kept the ini value and enum value same and representing the same
1606 * cb values as in 11n standard i.e.
1607 * Set to 1 (SCA) if the secondary channel is above the primary channel
1608 * Set to 3 (SCB) if the secondary channel is below the primary channel
1609 * Set to 0 (SCN) if no secondary channel is present
1610 * However, since our driver is already distributed we will keep the ini definition as it is which is:
1611 * 0 - secondary none
1612 * 1 - secondary LOW
1613 * 2 - secondary HIGH
1614 * and convert to enum value used within the driver in csrChangeDefaultConfigParam using this funcn
1615 * The enum values are as follows:
1616 * PHY_SINGLE_CHANNEL_CENTERED = 0
1617 * PHY_DOUBLE_CHANNEL_LOW_PRIMARY = 1
1618 * PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
1619 */
1620ePhyChanBondState csrConvertCBIniValueToPhyCBState(v_U32_t cbIniValue)
1621{
1622
1623 ePhyChanBondState phyCbState;
1624 switch (cbIniValue) {
1625 // secondary none
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301626 case eCSR_INI_SINGLE_CHANNEL_CENTERED:
Jeff Johnsone7245742012-09-05 17:12:55 -07001627 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1628 break;
1629 // secondary LOW
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301630 case eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY:
Jeff Johnsone7245742012-09-05 17:12:55 -07001631 phyCbState = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1632 break;
1633 // secondary HIGH
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301634 case eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY:
Jeff Johnsone7245742012-09-05 17:12:55 -07001635 phyCbState = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1636 break;
1637#ifdef WLAN_FEATURE_11AC
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301638 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1639 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001640 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301641 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Jeff Johnsone7245742012-09-05 17:12:55 -07001642 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1643 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301644 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1645 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED;
1646 break;
1647 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
Jeff Johnsone7245742012-09-05 17:12:55 -07001648 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
1649 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301650 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
Jeff Johnsone7245742012-09-05 17:12:55 -07001651 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301652 break;
1653 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
Jeff Johnsone7245742012-09-05 17:12:55 -07001654 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
1655 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301656 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
Jeff Johnsone7245742012-09-05 17:12:55 -07001657 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301658 break;
1659#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001660 default:
1661 // If an invalid value is passed, disable CHANNEL BONDING
1662 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1663 break;
1664 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301665
Jeff Johnsone7245742012-09-05 17:12:55 -07001666 return phyCbState;
1667}
1668
1669v_U32_t csrConvertPhyCBStateToIniValue(ePhyChanBondState phyCbState)
1670{
1671
1672 v_U32_t cbIniValue;
1673 switch (phyCbState) {
1674 // secondary none
1675 case PHY_SINGLE_CHANNEL_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301676 cbIniValue = eCSR_INI_SINGLE_CHANNEL_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001677 break;
1678 // secondary LOW
1679 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301680 cbIniValue = eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY;
Jeff Johnsone7245742012-09-05 17:12:55 -07001681 break;
1682 // secondary HIGH
1683 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301684 cbIniValue = eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY;
Jeff Johnsone7245742012-09-05 17:12:55 -07001685 break;
1686#ifdef WLAN_FEATURE_11AC
1687 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301688 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001689 break;
1690 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301691 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001692 break;
1693 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301694 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001695 break;
1696 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301697 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
Jeff Johnsone7245742012-09-05 17:12:55 -07001698 break;
1699 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301700 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
Jeff Johnsone7245742012-09-05 17:12:55 -07001701 break;
1702 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301703 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
Jeff Johnsone7245742012-09-05 17:12:55 -07001704 break;
1705 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301706 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
Jeff Johnsone7245742012-09-05 17:12:55 -07001707 break;
1708#endif
1709 default:
1710 // return some invalid value
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301711 cbIniValue = eCSR_INI_CHANNEL_BONDING_STATE_MAX;
Jeff Johnsone7245742012-09-05 17:12:55 -07001712 break;
1713 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301714
Jeff Johnsone7245742012-09-05 17:12:55 -07001715 return cbIniValue;
1716}
Jeff Johnson295189b2012-06-20 16:38:30 -07001717
1718eHalStatus csrChangeDefaultConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1719{
1720 eHalStatus status = eHAL_STATUS_SUCCESS;
1721
1722 if(pParam)
1723 {
1724 pMac->roam.configParam.WMMSupportMode = pParam->WMMSupportMode;
1725 pMac->roam.configParam.Is11eSupportEnabled = pParam->Is11eSupportEnabled;
1726 pMac->roam.configParam.FragmentationThreshold = pParam->FragmentationThreshold;
1727 pMac->roam.configParam.Is11dSupportEnabled = pParam->Is11dSupportEnabled;
1728 pMac->roam.configParam.Is11dSupportEnabledOriginal = pParam->Is11dSupportEnabled;
1729 pMac->roam.configParam.Is11hSupportEnabled = pParam->Is11hSupportEnabled;
1730
1731 pMac->roam.configParam.fenableMCCMode = pParam->fEnableMCCMode;
Mohit Khanna7ed53f02012-09-11 17:52:10 -07001732 pMac->roam.configParam.fAllowMCCGODiffBI = pParam->fAllowMCCGODiffBI;
1733
Jeff Johnsone7245742012-09-05 17:12:55 -07001734 /* channelBondingMode5GHz plays a dual role right now
1735 * 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
1736 * This is how channelBondingMode5GHz works now and this is kept intact to avoid any cfg.ini change
1737 */
1738 if (pParam->channelBondingMode24GHz > MAX_CB_VALUE_IN_INI)
1739 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001740 smsLog( pMac, LOGW, "Invalid CB value from ini in 2.4GHz band %d, CB DISABLED", pParam->channelBondingMode24GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001741 }
1742 pMac->roam.configParam.channelBondingMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode24GHz);
1743 if (pParam->channelBondingMode5GHz > MAX_CB_VALUE_IN_INI)
1744 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001745 smsLog( pMac, LOGW, "Invalid CB value from ini in 5GHz band %d, CB DISABLED", pParam->channelBondingMode5GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001746 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301747#ifdef WLAN_FEATURE_AP_HT40_24G
1748 pMac->roam.configParam.channelBondingAPMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingAPMode24GHz);
1749#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001750 pMac->roam.configParam.channelBondingMode5GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001751 pMac->roam.configParam.RTSThreshold = pParam->RTSThreshold;
1752 pMac->roam.configParam.phyMode = pParam->phyMode;
1753 pMac->roam.configParam.shortSlotTime = pParam->shortSlotTime;
1754 pMac->roam.configParam.HeartbeatThresh24 = pParam->HeartbeatThresh24;
1755 pMac->roam.configParam.HeartbeatThresh50 = pParam->HeartbeatThresh50;
1756 pMac->roam.configParam.ProprietaryRatesEnabled = pParam->ProprietaryRatesEnabled;
1757 pMac->roam.configParam.TxRate = pParam->TxRate;
1758 pMac->roam.configParam.AdHocChannel24 = pParam->AdHocChannel24;
1759 pMac->roam.configParam.AdHocChannel5G = pParam->AdHocChannel5G;
1760 pMac->roam.configParam.bandCapability = pParam->bandCapability;
1761 pMac->roam.configParam.cbChoice = pParam->cbChoice;
1762 pMac->roam.configParam.bgScanInterval = pParam->bgScanInterval;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001763 pMac->roam.configParam.disableAggWithBtc = pParam->disableAggWithBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001764 //if HDD passed down non zero values then only update,
1765 //otherwise keep using the defaults
c_hpothu059edb02014-03-12 21:44:28 +05301766 if (pParam->nInitialDwellTime)
1767 {
1768 pMac->roam.configParam.nInitialDwellTime =
1769 pParam->nInitialDwellTime;
1770 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001771 if (pParam->nActiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001772 {
1773 pMac->roam.configParam.nActiveMaxChnTime = pParam->nActiveMaxChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301774 cfgSetInt(pMac, WNI_CFG_ACTIVE_MAXIMUM_CHANNEL_TIME,
1775 pParam->nActiveMaxChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001776 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001777 if (pParam->nActiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001778 {
1779 pMac->roam.configParam.nActiveMinChnTime = pParam->nActiveMinChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301780 cfgSetInt(pMac, WNI_CFG_ACTIVE_MINIMUM_CHANNEL_TIME,
1781 pParam->nActiveMinChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001782 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001783 if (pParam->nPassiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001784 {
1785 pMac->roam.configParam.nPassiveMaxChnTime = pParam->nPassiveMaxChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301786 cfgSetInt(pMac, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME,
1787 pParam->nPassiveMaxChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001788 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001789 if (pParam->nPassiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001790 {
1791 pMac->roam.configParam.nPassiveMinChnTime = pParam->nPassiveMinChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301792 cfgSetInt(pMac, WNI_CFG_PASSIVE_MINIMUM_CHANNEL_TIME,
1793 pParam->nPassiveMinChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001794 }
Sushant Kaushikc9682be2014-11-26 12:27:04 +05301795 if (pParam->nOBSSScanWidthTriggerInterval)
1796 {
1797 pMac->roam.configParam.nOBSSScanWidthTriggerInterval =
1798 pParam->nOBSSScanWidthTriggerInterval;
1799 cfgSetInt(pMac, WNI_CFG_OBSS_HT40_SCAN_WIDTH_TRIGGER_INTERVAL,
1800 pParam->nOBSSScanWidthTriggerInterval);
1801 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001802 if (pParam->nActiveMaxChnTimeBtc)
1803 {
1804 pMac->roam.configParam.nActiveMaxChnTimeBtc = pParam->nActiveMaxChnTimeBtc;
1805 }
1806 if (pParam->nActiveMinChnTimeBtc)
1807 {
1808 pMac->roam.configParam.nActiveMinChnTimeBtc = pParam->nActiveMinChnTimeBtc;
1809 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001810#ifdef WLAN_AP_STA_CONCURRENCY
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001811 if (pParam->nActiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001812 {
1813 pMac->roam.configParam.nActiveMaxChnTimeConc = pParam->nActiveMaxChnTimeConc;
1814 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001815 if (pParam->nActiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001816 {
1817 pMac->roam.configParam.nActiveMinChnTimeConc = pParam->nActiveMinChnTimeConc;
1818 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001819 if (pParam->nPassiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001820 {
1821 pMac->roam.configParam.nPassiveMaxChnTimeConc = pParam->nPassiveMaxChnTimeConc;
1822 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001823 if (pParam->nPassiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001824 {
1825 pMac->roam.configParam.nPassiveMinChnTimeConc = pParam->nPassiveMinChnTimeConc;
1826 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001827 if (pParam->nRestTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001828 {
1829 pMac->roam.configParam.nRestTimeConc = pParam->nRestTimeConc;
1830 }
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001831 if (pParam->nNumStaChanCombinedConc)
Vinay Malekal05fdc812012-12-17 13:04:30 -08001832 {
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001833 pMac->roam.configParam.nNumStaChanCombinedConc = pParam->nNumStaChanCombinedConc;
1834 }
1835 if (pParam->nNumP2PChanCombinedConc)
1836 {
1837 pMac->roam.configParam.nNumP2PChanCombinedConc = pParam->nNumP2PChanCombinedConc;
Vinay Malekal05fdc812012-12-17 13:04:30 -08001838 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001839#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001840 //if upper layer wants to disable idle scan altogether set it to 0
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001841 if (pParam->impsSleepTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001842 {
1843 //Change the unit from second to microsecond
1844 tANI_U32 impsSleepTime = pParam->impsSleepTime * PAL_TIMER_TO_SEC_UNIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07001845 if(CSR_IDLE_SCAN_NO_PS_INTERVAL_MIN <= impsSleepTime)
1846 {
1847 pMac->roam.configParam.impsSleepTime = impsSleepTime;
1848 }
1849 else
1850 {
1851 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1852 }
1853 }
1854 else
1855 {
1856 pMac->roam.configParam.impsSleepTime = 0;
1857 }
1858 pMac->roam.configParam.eBand = pParam->eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001859 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(NULL, pMac->roam.configParam.phyMode,
1860 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07001861 //if HDD passed down non zero values for age params, then only update,
1862 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001863 if (pParam->nScanResultAgeCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07001864 {
1865 pMac->roam.configParam.agingCount = pParam->nScanResultAgeCount;
1866 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001867 if(pParam->scanAgeTimeNCNPS)
1868 {
1869 pMac->roam.configParam.scanAgeTimeNCNPS = pParam->scanAgeTimeNCNPS;
1870 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001871 if(pParam->scanAgeTimeNCPS)
1872 {
1873 pMac->roam.configParam.scanAgeTimeNCPS = pParam->scanAgeTimeNCPS;
1874 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001875 if(pParam->scanAgeTimeCNPS)
1876 {
1877 pMac->roam.configParam.scanAgeTimeCNPS = pParam->scanAgeTimeCNPS;
1878 }
1879 if(pParam->scanAgeTimeCPS)
1880 {
1881 pMac->roam.configParam.scanAgeTimeCPS = pParam->scanAgeTimeCPS;
1882 }
c_hpothu0d5a7352014-03-22 12:30:25 +05301883 if (pParam->initialScanSkipDFSCh)
1884 {
1885 pMac->roam.configParam.initialScanSkipDFSCh =
1886 pParam->initialScanSkipDFSCh;
1887 }
1888
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001889 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, pParam->bCatRssiOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07001890 pMac->roam.configParam.nRoamingTime = pParam->nRoamingTime;
1891 pMac->roam.configParam.fEnforce11dChannels = pParam->fEnforce11dChannels;
1892 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = pParam->fSupplicantCountryCodeHasPriority;
1893 pMac->roam.configParam.fEnforceCountryCodeMatch = pParam->fEnforceCountryCodeMatch;
1894 pMac->roam.configParam.fEnforceDefaultDomain = pParam->fEnforceDefaultDomain;
Jeff Johnson295189b2012-06-20 16:38:30 -07001895 pMac->roam.configParam.vccRssiThreshold = pParam->vccRssiThreshold;
1896 pMac->roam.configParam.vccUlMacLossThreshold = pParam->vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001897 pMac->roam.configParam.IsIdleScanEnabled = pParam->IsIdleScanEnabled;
1898 pMac->roam.configParam.statsReqPeriodicity = pParam->statsReqPeriodicity;
1899 pMac->roam.configParam.statsReqPeriodicityInPS = pParam->statsReqPeriodicityInPS;
1900 //Assign this before calling CsrInit11dInfo
1901 pMac->roam.configParam.nTxPowerCap = pParam->nTxPowerCap;
Jeff Johnson295189b2012-06-20 16:38:30 -07001902 if( csrIs11dSupported( pMac ) )
1903 {
1904 status = CsrInit11dInfo(pMac, &pParam->Csr11dinfo);
1905 }
1906 else
1907 {
1908 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
1909 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001910
1911 /* Initialize the power + channel information if 11h is enabled.
1912 If 11d is enabled this information has already been initialized */
1913 if( csrIs11hSupported( pMac ) && !csrIs11dSupported( pMac ) )
1914 {
1915 csrInitChannelPowerList(pMac, &pParam->Csr11dinfo);
1916 }
1917
1918
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05301919#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05301920 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
1921 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001922 smsLog( pMac, LOG1, "IsFTResourceReqSupp = %d", pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07001923#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001924#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001925 pMac->roam.configParam.isFastTransitionEnabled = pParam->isFastTransitionEnabled;
Jeff Johnson43971f52012-07-17 12:26:56 -07001926 pMac->roam.configParam.RoamRssiDiff = pParam->RoamRssiDiff;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001927 pMac->roam.configParam.nImmediateRoamRssiDiff = pParam->nImmediateRoamRssiDiff;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001928 smsLog( pMac, LOG1, "nImmediateRoamRssiDiff = %d",
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001929 pMac->roam.configParam.nImmediateRoamRssiDiff );
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08001930 pMac->roam.configParam.nRoamPrefer5GHz = pParam->nRoamPrefer5GHz;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07001931 pMac->roam.configParam.nRoamIntraBand = pParam->nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07001932 pMac->roam.configParam.isWESModeEnabled = pParam->isWESModeEnabled;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001933 pMac->roam.configParam.nProbes = pParam->nProbes;
1934 pMac->roam.configParam.nRoamScanHomeAwayTime = pParam->nRoamScanHomeAwayTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001935#endif
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001936#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
Kapil Gupta04ab1992016-06-26 13:36:51 +05301937 pMac->roam.configParam.isRoamOffloadScanEnabled =
1938 pParam->isRoamOffloadScanEnabled;
1939 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled =
1940 pParam->bFastRoamInConIniFeatureEnabled;
1941 pMac->roam.configParam.isPERRoamEnabled =
1942 pParam->isPERRoamEnabled;
1943 pMac->roam.configParam.rateUpThreshold = pParam->rateUpThreshold;
1944 pMac->roam.configParam.rateDownThreshold = pParam->rateDownThreshold;
1945 pMac->roam.configParam.waitPeriodForNextPERScan =
1946 pParam->waitPeriodForNextPERScan;
1947 pMac->roam.configParam.PERtimerThreshold = pParam->PERtimerThreshold;
1948 pMac->roam.configParam.isPERRoamCCAEnabled =
1949 pParam->isPERRoamCCAEnabled;
Kapil Guptac69c28a2016-08-25 14:11:17 +05301950 pMac->roam.configParam.PERRoamFullScanThreshold =
1951 pParam->PERRoamFullScanThreshold;
Kapil Gupta04ab1992016-06-26 13:36:51 +05301952 pMac->roam.configParam.PERroamTriggerPercent =
1953 pParam->PERroamTriggerPercent;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001954#endif
1955#ifdef FEATURE_WLAN_LFR
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001956 pMac->roam.configParam.isFastRoamIniFeatureEnabled = pParam->isFastRoamIniFeatureEnabled;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -08001957 pMac->roam.configParam.MAWCEnabled = pParam->MAWCEnabled;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001958#endif
1959
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001960#ifdef FEATURE_WLAN_ESE
1961 pMac->roam.configParam.isEseIniFeatureEnabled = pParam->isEseIniFeatureEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001962#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001963#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301964 vos_mem_copy(&pMac->roam.configParam.neighborRoamConfig,
1965 &pParam->neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001966 smsLog( pMac, LOG1, "nNeighborScanTimerPerioid = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod);
1967 smsLog( pMac, LOG1, "nNeighborReassocRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold);
1968 smsLog( pMac, LOG1, "nNeighborLookupRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold);
1969 smsLog( pMac, LOG1, "nNeighborScanMinChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime);
1970 smsLog( pMac, LOG1, "nNeighborScanMaxChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime);
1971 smsLog( pMac, LOG1, "nMaxNeighborRetries = %d", pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries);
1972 smsLog( pMac, LOG1, "nNeighborResultsRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod);
1973 smsLog( pMac, LOG1, "nEmptyScanRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod);
Mukul Sharma20aa6582014-08-07 21:36:12 +05301974 smsLog( pMac, LOG1, "nNeighborInitialForcedRoamTo5GhEnable = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborInitialForcedRoamTo5GhEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07001975 {
1976 int i;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001977 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 -07001978 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1979 {
1980 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1981 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001982 }
1983#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001984 pMac->roam.configParam.addTSWhenACMIsOff = pParam->addTSWhenACMIsOff;
1985 pMac->scan.fValidateList = pParam->fValidateList;
1986 pMac->scan.fEnableBypass11d = pParam->fEnableBypass11d;
1987 pMac->scan.fEnableDFSChnlScan = pParam->fEnableDFSChnlScan;
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08001988 pMac->scan.scanResultCfgAgingTime = pParam->scanCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001989 pMac->roam.configParam.fScanTwice = pParam->fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001990 pMac->scan.fFirstScanOnly2GChnl = pParam->fFirstScanOnly2GChnl;
Peng Xu2446a892014-09-05 17:21:18 +05301991 pMac->scan.scanBandPreference = pParam->scanBandPreference;
Jeff Johnsone7245742012-09-05 17:12:55 -07001992 /* This parameter is not available in cfg and not passed from upper layers. Instead it is initialized here
1993 * This paramtere is used in concurrency to determine if there are concurrent active sessions.
1994 * Is used as a temporary fix to disconnect all active sessions when BMPS enabled so the active session if Infra STA
1995 * will automatically connect back and resume BMPS since resume BMPS is not working when moving from concurrent to
1996 * single session
1997 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001998 //Remove this code once SLM_Sessionization is supported
1999 //BMPS_WORKAROUND_NOT_NEEDED
Mohit Khanna349bc392012-09-11 17:24:52 -07002000 pMac->roam.configParam.doBMPSWorkaround = 0;
2001
Jeff Johnsone7245742012-09-05 17:12:55 -07002002#ifdef WLAN_FEATURE_11AC
2003 pMac->roam.configParam.nVhtChannelWidth = pParam->nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08002004 pMac->roam.configParam.txBFEnable= pParam->enableTxBF;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08002005 pMac->roam.configParam.txBFCsnValue = pParam->txBFCsnValue;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07002006 pMac->roam.configParam.enableVhtFor24GHz = pParam->enableVhtFor24GHz;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05302007 /* Consider Mu-beamformee only if SU-beamformee is enabled */
2008 if ( pParam->enableTxBF )
2009 pMac->roam.configParam.txMuBformee= pParam->enableMuBformee;
2010 else
2011 pMac->roam.configParam.txMuBformee= 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002012#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08002013 pMac->roam.configParam.txLdpcEnable = pParam->enableTxLdpc;
krunal soni5afa96c2013-09-06 22:19:02 -07002014
2015 pMac->roam.configParam.isAmsduSupportInAMPDU = pParam->isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07002016 pMac->roam.configParam.nSelect5GHzMargin = pParam->nSelect5GHzMargin;
Abhishek Singhc98534e2015-06-12 10:44:34 +05302017 pMac->roam.configParam.ignorePeerErpInfo = pParam->ignorePeerErpInfo;
Sushant Kaushikae17dd62015-08-27 17:07:04 +05302018 pMac->roam.configParam.ignorePeerHTopMode = pParam->ignorePeerHTopMode;
Abhishek Singh795e1b82015-09-25 15:35:03 +05302019 pMac->roam.configParam.disableP2PMacSpoofing =
2020 pParam->disableP2PMacSpoofing;
Abhishek Singh837adf22015-10-01 17:37:37 +05302021 pMac->roam.configParam.enableFatalEvent =
2022 pParam->enableFatalEvent;
krunal sonie9002db2013-11-25 14:24:17 -08002023 pMac->roam.configParam.isCoalesingInIBSSAllowed =
2024 pParam->isCoalesingInIBSSAllowed;
Sandeep Puligillac80f26e2014-03-11 18:36:10 +05302025 pMac->roam.configParam.allowDFSChannelRoam = pParam->allowDFSChannelRoam;
Abhishek Singhde51a412014-05-20 19:17:26 +05302026 pMac->roam.configParam.sendDeauthBeforeCon = pParam->sendDeauthBeforeCon;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05302027#ifdef WLAN_FEATURE_AP_HT40_24G
2028 pMac->roam.configParam.apHT40_24GEnabled = pParam->apHT40_24GEnabled;
2029#endif
Girish Gowli1c2fc802015-01-19 16:18:07 +05302030 pMac->roam.configParam.roamDelayStatsEnabled = pParam->roamDelayStatsEnabled;
Gupta, Kapil01be56b2015-12-30 20:36:33 +05302031 pMac->roam.configParam.max_chan_for_dwell_time_cfg =
2032 pParam->max_chan_for_dwell_time_cfg;
Abhishek Singh48cd3402016-03-30 15:20:19 +05302033
2034 pMac->roam.configParam.enable_edca_params = pParam->enable_edca_params;
2035 pMac->roam.configParam.edca_vo_cwmin = pParam->edca_vo_cwmin;
2036 pMac->roam.configParam.edca_vi_cwmin = pParam->edca_vi_cwmin;
2037 pMac->roam.configParam.edca_bk_cwmin = pParam->edca_bk_cwmin;
2038 pMac->roam.configParam.edca_be_cwmin = pParam->edca_be_cwmin;
2039
2040 pMac->roam.configParam.edca_vo_cwmax = pParam->edca_vo_cwmax;
2041 pMac->roam.configParam.edca_vi_cwmax = pParam->edca_vi_cwmax;
2042 pMac->roam.configParam.edca_bk_cwmax = pParam->edca_bk_cwmax;
2043 pMac->roam.configParam.edca_be_cwmax = pParam->edca_be_cwmax;
2044
2045 pMac->roam.configParam.edca_vo_aifs = pParam->edca_vo_aifs;
2046 pMac->roam.configParam.edca_vi_aifs = pParam->edca_vi_aifs;
2047 pMac->roam.configParam.edca_bk_aifs = pParam->edca_bk_aifs;
2048 pMac->roam.configParam.edca_be_aifs = pParam->edca_be_aifs;
Jeff Johnson295189b2012-06-20 16:38:30 -07002049 }
2050
2051 return status;
2052}
2053
Jeff Johnson295189b2012-06-20 16:38:30 -07002054eHalStatus csrGetConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
2055{
2056 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07002057 if(pParam)
2058 {
2059 pParam->WMMSupportMode = pMac->roam.configParam.WMMSupportMode;
2060 pParam->Is11eSupportEnabled = pMac->roam.configParam.Is11eSupportEnabled;
2061 pParam->FragmentationThreshold = pMac->roam.configParam.FragmentationThreshold;
2062 pParam->Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabled;
2063 pParam->Is11dSupportEnabledOriginal = pMac->roam.configParam.Is11dSupportEnabledOriginal;
2064 pParam->Is11hSupportEnabled = pMac->roam.configParam.Is11hSupportEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07002065 pParam->channelBondingMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode24GHz);
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05302066#ifdef WLAN_FEATURE_AP_HT40_24G
2067 pParam->channelBondingAPMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingAPMode24GHz);
2068#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002069 pParam->channelBondingMode5GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07002070 pParam->RTSThreshold = pMac->roam.configParam.RTSThreshold;
2071 pParam->phyMode = pMac->roam.configParam.phyMode;
2072 pParam->shortSlotTime = pMac->roam.configParam.shortSlotTime;
2073 pParam->HeartbeatThresh24 = pMac->roam.configParam.HeartbeatThresh24;
2074 pParam->HeartbeatThresh50 = pMac->roam.configParam.HeartbeatThresh50;
2075 pParam->ProprietaryRatesEnabled = pMac->roam.configParam.ProprietaryRatesEnabled;
2076 pParam->TxRate = pMac->roam.configParam.TxRate;
2077 pParam->AdHocChannel24 = pMac->roam.configParam.AdHocChannel24;
2078 pParam->AdHocChannel5G = pMac->roam.configParam.AdHocChannel5G;
2079 pParam->bandCapability = pMac->roam.configParam.bandCapability;
2080 pParam->cbChoice = pMac->roam.configParam.cbChoice;
2081 pParam->bgScanInterval = pMac->roam.configParam.bgScanInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07002082 pParam->nActiveMaxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
2083 pParam->nActiveMinChnTime = pMac->roam.configParam.nActiveMinChnTime;
2084 pParam->nPassiveMaxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
2085 pParam->nPassiveMinChnTime = pMac->roam.configParam.nPassiveMinChnTime;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07002086 pParam->nActiveMaxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
2087 pParam->nActiveMinChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
2088 pParam->disableAggWithBtc = pMac->roam.configParam.disableAggWithBtc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07002089#ifdef WLAN_AP_STA_CONCURRENCY
2090 pParam->nActiveMaxChnTimeConc = pMac->roam.configParam.nActiveMaxChnTimeConc;
2091 pParam->nActiveMinChnTimeConc = pMac->roam.configParam.nActiveMinChnTimeConc;
2092 pParam->nPassiveMaxChnTimeConc = pMac->roam.configParam.nPassiveMaxChnTimeConc;
2093 pParam->nPassiveMinChnTimeConc = pMac->roam.configParam.nPassiveMinChnTimeConc;
2094 pParam->nRestTimeConc = pMac->roam.configParam.nRestTimeConc;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07002095 pParam->nNumStaChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc;
2096 pParam->nNumP2PChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07002097#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002098 //Change the unit from microsecond to second
2099 pParam->impsSleepTime = pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_SEC_UNIT;
2100 pParam->eBand = pMac->roam.configParam.eBand;
2101 pParam->nScanResultAgeCount = pMac->roam.configParam.agingCount;
2102 pParam->scanAgeTimeNCNPS = pMac->roam.configParam.scanAgeTimeNCNPS;
2103 pParam->scanAgeTimeNCPS = pMac->roam.configParam.scanAgeTimeNCPS;
2104 pParam->scanAgeTimeCNPS = pMac->roam.configParam.scanAgeTimeCNPS;
2105 pParam->scanAgeTimeCPS = pMac->roam.configParam.scanAgeTimeCPS;
2106 pParam->bCatRssiOffset = pMac->roam.configParam.bCatRssiOffset;
2107 pParam->nRoamingTime = pMac->roam.configParam.nRoamingTime;
2108 pParam->fEnforce11dChannels = pMac->roam.configParam.fEnforce11dChannels;
2109 pParam->fSupplicantCountryCodeHasPriority = pMac->roam.configParam.fSupplicantCountryCodeHasPriority;
2110 pParam->fEnforceCountryCodeMatch = pMac->roam.configParam.fEnforceCountryCodeMatch;
2111 pParam->fEnforceDefaultDomain = pMac->roam.configParam.fEnforceDefaultDomain;
2112 pParam->vccRssiThreshold = pMac->roam.configParam.vccRssiThreshold;
2113 pParam->vccUlMacLossThreshold = pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07002114 pParam->IsIdleScanEnabled = pMac->roam.configParam.IsIdleScanEnabled;
2115 pParam->nTxPowerCap = pMac->roam.configParam.nTxPowerCap;
2116 pParam->statsReqPeriodicity = pMac->roam.configParam.statsReqPeriodicity;
2117 pParam->statsReqPeriodicityInPS = pMac->roam.configParam.statsReqPeriodicityInPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002118 pParam->addTSWhenACMIsOff = pMac->roam.configParam.addTSWhenACMIsOff;
2119 pParam->fValidateList = pMac->roam.configParam.fValidateList;
2120 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
2121 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
2122 pParam->fScanTwice = pMac->roam.configParam.fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07002123 pParam->fFirstScanOnly2GChnl = pMac->scan.fFirstScanOnly2GChnl;
Madan Mohan Koyyalamudied419512012-11-29 15:53:46 -08002124 pParam->fEnableMCCMode = pMac->roam.configParam.fenableMCCMode;
Madan Mohan Koyyalamudi057bd802012-11-29 16:02:39 -08002125 pParam->fAllowMCCGODiffBI = pMac->roam.configParam.fAllowMCCGODiffBI;
Sunil Ravi39b2e532013-01-20 23:45:53 -08002126 pParam->scanCfgAgingTime = pMac->scan.scanResultCfgAgingTime;
Peng Xu2446a892014-09-05 17:21:18 +05302127 pParam->scanBandPreference = pMac->scan.scanBandPreference;
Jeff Johnson295189b2012-06-20 16:38:30 -07002128#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05302129 vos_mem_copy(&pParam->neighborRoamConfig,
2130 &pMac->roam.configParam.neighborRoamConfig,
2131 sizeof(tCsrNeighborRoamConfigParams));
Jeff Johnson295189b2012-06-20 16:38:30 -07002132#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07002133#ifdef WLAN_FEATURE_11AC
2134 pParam->nVhtChannelWidth = pMac->roam.configParam.nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08002135 pParam->enableTxBF = pMac->roam.configParam.txBFEnable;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08002136 pParam->txBFCsnValue = pMac->roam.configParam.txBFCsnValue;
Ravi Joshiacc81822013-10-10 15:30:41 -07002137 pParam->enableVhtFor24GHz = pMac->roam.configParam.enableVhtFor24GHz;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05302138 /* Consider Mu-beamformee only if SU-beamformee is enabled */
2139 if ( pParam->enableTxBF )
2140 pParam->enableMuBformee = pMac->roam.configParam.txMuBformee;
2141 else
2142 pParam->enableMuBformee = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002143#endif
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002144#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05302145 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
2146 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002147#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002148#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002149 pParam->isFastTransitionEnabled = pMac->roam.configParam.isFastTransitionEnabled;
2150 pParam->RoamRssiDiff = pMac->roam.configParam.RoamRssiDiff;
2151 pParam->nImmediateRoamRssiDiff = pMac->roam.configParam.nImmediateRoamRssiDiff;
2152 pParam->nRoamPrefer5GHz = pMac->roam.configParam.nRoamPrefer5GHz;
2153 pParam->nRoamIntraBand = pMac->roam.configParam.nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07002154 pParam->isWESModeEnabled = pMac->roam.configParam.isWESModeEnabled;
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -07002155 pParam->nProbes = pMac->roam.configParam.nProbes;
2156 pParam->nRoamScanHomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002157#endif
2158#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
2159 pParam->isRoamOffloadScanEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
2160 pParam->bFastRoamInConIniFeatureEnabled = pMac->roam.configParam.bFastRoamInConIniFeatureEnabled;
Kapil Gupta04ab1992016-06-26 13:36:51 +05302161 pParam->isPERRoamEnabled =
2162 pMac->roam.configParam.isPERRoamEnabled;
2163 pParam->rateUpThreshold = pMac->roam.configParam.rateUpThreshold;
2164 pParam->rateDownThreshold = pMac->roam.configParam.rateDownThreshold;
2165 pParam->waitPeriodForNextPERScan =
2166 pMac->roam.configParam.waitPeriodForNextPERScan;
2167 pParam->PERtimerThreshold = pMac->roam.configParam.PERtimerThreshold;
2168 pParam->isPERRoamCCAEnabled =
2169 pMac->roam.configParam.isPERRoamCCAEnabled;
Kapil Guptac69c28a2016-08-25 14:11:17 +05302170 pParam->PERRoamFullScanThreshold =
2171 pMac->roam.configParam.PERRoamFullScanThreshold;
Kapil Gupta04ab1992016-06-26 13:36:51 +05302172 pParam->PERroamTriggerPercent =
2173 pMac->roam.configParam.PERroamTriggerPercent;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002174#endif
2175#ifdef FEATURE_WLAN_LFR
2176 pParam->isFastRoamIniFeatureEnabled = pMac->roam.configParam.isFastRoamIniFeatureEnabled;
2177#endif
2178
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002179#ifdef FEATURE_WLAN_ESE
2180 pParam->isEseIniFeatureEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002181#endif
2182#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05302183 vos_mem_copy(&pParam->neighborRoamConfig,
2184 &pMac->roam.configParam.neighborRoamConfig,
2185 sizeof(tCsrNeighborRoamConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002186 {
2187 int i;
2188 smsLog( pMac, LOG1, FL("Num of Channels in CFG Channel List: %d"), pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
2189 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
2190 {
2191 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
2192 }
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002193 }
2194#endif
2195
Venkata Prathyusha Kuntupallif2695c12013-04-17 15:41:23 -07002196 pParam->enableTxLdpc = pMac->roam.configParam.txLdpcEnable;
krunal soni4f087d22013-07-29 16:32:26 -07002197
krunal soni5afa96c2013-09-06 22:19:02 -07002198 pParam->isAmsduSupportInAMPDU = pMac->roam.configParam.isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07002199 pParam->nSelect5GHzMargin = pMac->roam.configParam.nSelect5GHzMargin;
Abhishek Singhc98534e2015-06-12 10:44:34 +05302200 pParam->ignorePeerErpInfo = pMac->roam.configParam.ignorePeerErpInfo;
Sushant Kaushikae17dd62015-08-27 17:07:04 +05302201 pParam->ignorePeerHTopMode = pMac->roam.configParam.ignorePeerHTopMode;
Abhishek Singh795e1b82015-09-25 15:35:03 +05302202 pParam->disableP2PMacSpoofing =
2203 pMac->roam.configParam.disableP2PMacSpoofing;
Abhishek Singh837adf22015-10-01 17:37:37 +05302204 pParam->enableFatalEvent = pMac->roam.configParam.enableFatalEvent;
krunal soni5afa96c2013-09-06 22:19:02 -07002205
krunal sonie9002db2013-11-25 14:24:17 -08002206 pParam->isCoalesingInIBSSAllowed =
2207 pMac->roam.configParam.isCoalesingInIBSSAllowed;
Sandeep Puligillac80f26e2014-03-11 18:36:10 +05302208 pParam->allowDFSChannelRoam =
2209 pMac->roam.configParam.allowDFSChannelRoam;
Abhishek Singhde51a412014-05-20 19:17:26 +05302210 pParam->sendDeauthBeforeCon = pMac->roam.configParam.sendDeauthBeforeCon;
Jeff Johnson295189b2012-06-20 16:38:30 -07002211 csrSetChannels(pMac, pParam);
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05302212#ifdef WLAN_FEATURE_AP_HT40_24G
2213 pParam->apHT40_24GEnabled = pMac->roam.configParam.apHT40_24GEnabled;
2214#endif
Gupta, Kapil01be56b2015-12-30 20:36:33 +05302215 pParam->max_chan_for_dwell_time_cfg =
2216 pMac->roam.configParam.max_chan_for_dwell_time_cfg;
Jeff Johnson295189b2012-06-20 16:38:30 -07002217
Abhishek Singh48cd3402016-03-30 15:20:19 +05302218 pParam->enable_edca_params = pMac->roam.configParam.enable_edca_params;
2219 pParam->edca_vo_cwmin = pMac->roam.configParam.edca_vo_cwmin;
2220 pParam->edca_vi_cwmin = pMac->roam.configParam.edca_vi_cwmin;
2221 pParam->edca_bk_cwmin = pMac->roam.configParam.edca_bk_cwmin;
2222 pParam->edca_be_cwmin = pMac->roam.configParam.edca_be_cwmin;
2223
2224 pParam->edca_vo_cwmax = pMac->roam.configParam.edca_vo_cwmax;
2225 pParam->edca_vi_cwmax = pMac->roam.configParam.edca_vi_cwmax;
2226 pParam->edca_bk_cwmax = pMac->roam.configParam.edca_bk_cwmax;
2227 pParam->edca_be_cwmax = pMac->roam.configParam.edca_be_cwmax;
2228
2229 pParam->edca_vo_aifs = pMac->roam.configParam.edca_vo_aifs;
2230 pParam->edca_vi_aifs = pMac->roam.configParam.edca_vi_aifs;
2231 pParam->edca_bk_aifs = pMac->roam.configParam.edca_bk_aifs;
2232 pParam->edca_be_aifs = pMac->roam.configParam.edca_be_aifs;
2233
Jeff Johnson295189b2012-06-20 16:38:30 -07002234 status = eHAL_STATUS_SUCCESS;
2235 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002236 return (status);
2237}
2238
Jeff Johnson295189b2012-06-20 16:38:30 -07002239eHalStatus csrSetPhyMode(tHalHandle hHal, tANI_U32 phyMode, eCsrBand eBand, tANI_BOOLEAN *pfRestartNeeded)
2240{
2241 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
2242 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2243 tANI_BOOLEAN fRestartNeeded = eANI_BOOLEAN_FALSE;
2244 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07002245 do
2246 {
2247 if(eCSR_BAND_24 == eBand)
2248 {
2249 if(CSR_IS_RADIO_A_ONLY(pMac)) break;
2250 if((eCSR_DOT11_MODE_11a & phyMode) || (eCSR_DOT11_MODE_11a_ONLY & phyMode)) break;
2251 }
2252 if(eCSR_BAND_5G == eBand)
2253 {
2254 if(CSR_IS_RADIO_BG_ONLY(pMac)) break;
2255 if((eCSR_DOT11_MODE_11b & phyMode) || (eCSR_DOT11_MODE_11b_ONLY & phyMode) ||
2256 (eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11g_ONLY & phyMode)
2257 )
2258 {
2259 break;
2260 }
2261 }
2262 if((0 == phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
2263 {
2264 newPhyMode = eCSR_DOT11_MODE_TAURUS;
2265 }
2266 else if(eCSR_DOT11_MODE_AUTO & phyMode)
2267 {
2268 newPhyMode = eCSR_DOT11_MODE_AUTO;
2269 }
2270 else
2271 {
2272 //Check for dual band and higher capability first
2273 if(eCSR_DOT11_MODE_11n_ONLY & phyMode)
2274 {
2275 if(eCSR_DOT11_MODE_11n_ONLY != phyMode) break;
2276 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
2277 }
2278 else if(eCSR_DOT11_MODE_11a_ONLY & phyMode)
2279 {
2280 if(eCSR_DOT11_MODE_11a_ONLY != phyMode) break;
2281 if(eCSR_BAND_24 == eBand) break;
2282 newPhyMode = eCSR_DOT11_MODE_11a_ONLY;
2283 eBand = eCSR_BAND_5G;
2284 }
2285 else if(eCSR_DOT11_MODE_11g_ONLY & phyMode)
2286 {
2287 if(eCSR_DOT11_MODE_11g_ONLY != phyMode) break;
2288 if(eCSR_BAND_5G == eBand) break;
2289 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
2290 eBand = eCSR_BAND_24;
2291 }
2292 else if(eCSR_DOT11_MODE_11b_ONLY & phyMode)
2293 {
2294 if(eCSR_DOT11_MODE_11b_ONLY != phyMode) break;
2295 if(eCSR_BAND_5G == eBand) break;
2296 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
2297 eBand = eCSR_BAND_24;
2298 }
2299 else if(eCSR_DOT11_MODE_11n & phyMode)
2300 {
2301 newPhyMode = eCSR_DOT11_MODE_11n;
2302 }
2303 else if(eCSR_DOT11_MODE_abg & phyMode)
2304 {
2305 newPhyMode = eCSR_DOT11_MODE_abg;
2306 }
2307 else if(eCSR_DOT11_MODE_11a & phyMode)
2308 {
2309 if((eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11b & phyMode))
2310 {
2311 if(eCSR_BAND_ALL == eBand)
2312 {
2313 newPhyMode = eCSR_DOT11_MODE_abg;
2314 }
2315 else
2316 {
2317 //bad setting
2318 break;
2319 }
2320 }
2321 else
2322 {
2323 newPhyMode = eCSR_DOT11_MODE_11a;
2324 eBand = eCSR_BAND_5G;
2325 }
2326 }
2327 else if(eCSR_DOT11_MODE_11g & phyMode)
2328 {
2329 newPhyMode = eCSR_DOT11_MODE_11g;
2330 eBand = eCSR_BAND_24;
2331 }
2332 else if(eCSR_DOT11_MODE_11b & phyMode)
2333 {
2334 newPhyMode = eCSR_DOT11_MODE_11b;
2335 eBand = eCSR_BAND_24;
2336 }
2337 else
2338 {
2339 //We will never be here
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002340 smsLog( pMac, LOGE, FL(" cannot recognize the phy mode 0x%08X"), phyMode );
Jeff Johnson295189b2012-06-20 16:38:30 -07002341 newPhyMode = eCSR_DOT11_MODE_AUTO;
2342 }
2343 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002344 //Done validating
2345 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002346 //Now we need to check whether a restart is needed.
2347 if(eBand != pMac->roam.configParam.eBand)
2348 {
2349 fRestartNeeded = eANI_BOOLEAN_TRUE;
2350 break;
2351 }
2352 if(newPhyMode != pMac->roam.configParam.phyMode)
2353 {
2354 fRestartNeeded = eANI_BOOLEAN_TRUE;
2355 break;
2356 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002357 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002358 if(HAL_STATUS_SUCCESS(status))
2359 {
2360 pMac->roam.configParam.eBand = eBand;
2361 pMac->roam.configParam.phyMode = newPhyMode;
2362 if(pfRestartNeeded)
2363 {
2364 *pfRestartNeeded = fRestartNeeded;
2365 }
2366 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002367 return (status);
2368}
2369
Jeff Johnson295189b2012-06-20 16:38:30 -07002370void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList )
2371{
2372 tANI_U8 Index;
2373 tANI_U8 cChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07002374 // for dual band NICs, don't need to trim the channel list....
2375 if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) )
2376 {
2377 // 2.4 GHz band operation requires the channel list to be trimmed to
2378 // the 2.4 GHz channels only...
2379 if ( CSR_IS_24_BAND_ONLY( pMac ) )
2380 {
2381 for( Index = 0, cChannels = 0; Index < pChannelList->numChannels;
2382 Index++ )
2383 {
2384 if ( CSR_IS_CHANNEL_24GHZ(pChannelList->channelList[ Index ]) )
2385 {
2386 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2387 cChannels++;
2388 }
2389 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002390 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2391 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2392 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2393 // only if we need to.
2394 //
2395 // The amount of memory to clear is the number of channesl that we trimmed
2396 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2397
2398 if ( pChannelList->numChannels > cChannels )
2399 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302400 vos_mem_set(&pChannelList->channelList[ cChannels ],
2401 sizeof( pChannelList->channelList[ 0 ] ) *
2402 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002403 }
2404
2405 pChannelList->numChannels = cChannels;
2406 }
2407 else if ( CSR_IS_5G_BAND_ONLY( pMac ) )
2408 {
2409 for ( Index = 0, cChannels = 0; Index < pChannelList->numChannels; Index++ )
2410 {
2411 if ( CSR_IS_CHANNEL_5GHZ(pChannelList->channelList[ Index ]) )
2412 {
2413 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2414 cChannels++;
2415 }
2416 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002417 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2418 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2419 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2420 // only if we need to.
2421 //
2422 // The amount of memory to clear is the number of channesl that we trimmed
2423 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2424 if ( pChannelList->numChannels > cChannels )
2425 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302426 vos_mem_set(&pChannelList->channelList[ cChannels ],
2427 sizeof( pChannelList->channelList[ 0 ] ) *
2428 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002429 }
2430
2431 pChannelList->numChannels = cChannels;
2432 }
2433 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002434}
Jeff Johnson295189b2012-06-20 16:38:30 -07002435#define INFRA_AP_DEFAULT_CHANNEL 6
2436eHalStatus csrIsValidChannel(tpAniSirGlobal pMac, tANI_U8 chnNum)
2437{
2438 tANI_U8 index= 0;
2439 eHalStatus status = eHAL_STATUS_FAILURE;
2440 for (index=0; index < pMac->scan.base20MHzChannels.numChannels ;index++)
2441 {
2442 if(pMac->scan.base20MHzChannels.channelList[ index ] == chnNum){
2443 status = eHAL_STATUS_SUCCESS;
2444 break;
2445 }
2446 }
2447 return status;
2448}
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002449
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002450
Jeff Johnson295189b2012-06-20 16:38:30 -07002451eHalStatus csrInitGetChannels(tpAniSirGlobal pMac)
2452{
2453 eHalStatus status = eHAL_STATUS_SUCCESS;
2454 tANI_U8 num20MHzChannelsFound = 0;
2455 VOS_STATUS vosStatus;
2456 tANI_U8 Index = 0;
2457 tANI_U8 num40MHzChannelsFound = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002458
Jeff Johnson295189b2012-06-20 16:38:30 -07002459
2460 //TODO: this interface changed to include the 40MHz channel list
2461 // this needs to be tied into the adapter structure somehow and referenced appropriately for CB operation
2462 // Read the scan channel list (including the power limit) from EEPROM
2463 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
2464 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
2465 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
2466 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002467 smsLog( pMac, LOGE, FL("failed to get channels "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002468 status = eHAL_STATUS_FAILURE;
2469 }
2470 else
2471 {
2472 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
2473 {
2474 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2475 }
2476 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
2477 // Move the channel list to the global data
2478 // structure -- this will be used as the scan list
2479 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
2480 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002481 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[ Index ].chanId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002482 }
2483 pMac->scan.base20MHzChannels.numChannels = num20MHzChannelsFound;
2484 if(num40MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN)
2485 {
2486 num40MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2487 }
2488 for ( Index = 0; Index < num40MHzChannelsFound; Index++)
2489 {
2490 pMac->scan.base40MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable40MHz[ Index ].chanId;
2491 }
2492 pMac->scan.base40MHzChannels.numChannels = num40MHzChannelsFound;
2493 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002494 return (status);
2495}
Jeff Johnson295189b2012-06-20 16:38:30 -07002496eHalStatus csrInitChannelList( tHalHandle hHal )
2497{
2498 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2499 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002500 csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels);
2501 csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels);
Kiran4a17ebe2013-01-31 10:43:43 -08002502 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE);
2503 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002504 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002505 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Atul Mittalb849d5a2014-07-29 12:08:39 +05302506 limInitOperatingClasses(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07002507 return (status);
2508}
Jeff Johnson295189b2012-06-20 16:38:30 -07002509eHalStatus csrChangeConfigParams(tpAniSirGlobal pMac,
2510 tCsrUpdateConfigParam *pUpdateConfigParam)
2511{
2512 eHalStatus status = eHAL_STATUS_FAILURE;
2513 tCsr11dinfo *ps11dinfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002514 ps11dinfo = &pUpdateConfigParam->Csr11dinfo;
2515 status = CsrInit11dInfo(pMac, ps11dinfo);
2516 return status;
2517}
2518
Jeff Johnson295189b2012-06-20 16:38:30 -07002519static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2520{
2521 eHalStatus status = eHAL_STATUS_FAILURE;
2522 tANI_U8 index;
2523 tANI_U32 count=0;
2524 tSirMacChanInfo *pChanInfo;
2525 tSirMacChanInfo *pChanInfoStart;
2526 tANI_BOOLEAN applyConfig = TRUE;
2527
Mihir Shetebc866f62014-02-13 16:08:53 +05302528 pMac->scan.currentCountryRSSI = -128;
2529
Jeff Johnson295189b2012-06-20 16:38:30 -07002530 if(!ps11dinfo)
2531 {
2532 return (status);
2533 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002534 if ( ps11dinfo->Channels.numChannels && ( WNI_CFG_VALID_CHANNEL_LIST_LEN >= ps11dinfo->Channels.numChannels ) )
2535 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302536 pMac->scan.base20MHzChannels.numChannels = ps11dinfo->Channels.numChannels;
2537 vos_mem_copy(pMac->scan.base20MHzChannels.channelList,
2538 ps11dinfo->Channels.channelList,
2539 ps11dinfo->Channels.numChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07002540 }
2541 else
2542 {
2543 //No change
2544 return (eHAL_STATUS_SUCCESS);
2545 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002546 //legacy maintenance
Kiet Lam64c1b492013-07-12 13:56:44 +05302547
2548 vos_mem_copy(pMac->scan.countryCodeDefault, ps11dinfo->countryCode,
2549 WNI_CFG_COUNTRY_CODE_LEN);
2550
2551
Jeff Johnson295189b2012-06-20 16:38:30 -07002552 //Tush: at csropen get this initialized with default, during csr reset if this
2553 // already set with some value no need initilaize with default again
2554 if(0 == pMac->scan.countryCodeCurrent[0])
2555 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302556 vos_mem_copy(pMac->scan.countryCodeCurrent, ps11dinfo->countryCode,
2557 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002558 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002559 // need to add the max power channel list
Kiet Lam64c1b492013-07-12 13:56:44 +05302560 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2561 if (pChanInfo != NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002562 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302563 vos_mem_set(pChanInfo,
2564 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN ,
2565 0);
2566
Jeff Johnson295189b2012-06-20 16:38:30 -07002567 pChanInfoStart = pChanInfo;
Jeff Johnsone7245742012-09-05 17:12:55 -07002568 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2569 {
2570 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2571 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2572 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2573 pChanInfo++;
2574 count++;
2575 }
2576 if(count)
2577 {
2578 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2579 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302580 vos_mem_free(pChanInfoStart);
Jeff Johnsone7245742012-09-05 17:12:55 -07002581 }
2582 //Only apply them to CFG when not in STOP state. Otherwise they will be applied later
2583 if( HAL_STATUS_SUCCESS(status) )
2584 {
2585 for( index = 0; index < CSR_ROAM_SESSION_MAX; index++ )
2586 {
2587 if((CSR_IS_SESSION_VALID(pMac, index)) && CSR_IS_ROAM_STOP(pMac, index))
2588 {
2589 applyConfig = FALSE;
2590 }
2591 }
2592
2593 if(TRUE == applyConfig)
2594 {
2595 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002596 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnsone7245742012-09-05 17:12:55 -07002597 }
2598
2599 }
2600 return (status);
2601}
2602/* Initialize the Channel + Power List in the local cache and in the CFG */
2603eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2604{
2605 tANI_U8 index;
2606 tANI_U32 count=0;
2607 tSirMacChanInfo *pChanInfo;
2608 tSirMacChanInfo *pChanInfoStart;
2609
2610 if(!ps11dinfo || !pMac)
2611 {
2612 return eHAL_STATUS_FAILURE;
2613 }
2614
Kiet Lam64c1b492013-07-12 13:56:44 +05302615 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2616 if (pChanInfo != NULL)
Jeff Johnsone7245742012-09-05 17:12:55 -07002617 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302618 vos_mem_set(pChanInfo,
2619 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN,
2620 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07002621 pChanInfoStart = pChanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002622
2623 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2624 {
2625 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2626 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2627 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2628 pChanInfo++;
2629 count++;
2630 }
2631 if(count)
2632 {
2633 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2634 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302635 vos_mem_free(pChanInfoStart);
Jeff Johnson295189b2012-06-20 16:38:30 -07002636 }
2637
Jeff Johnsone7245742012-09-05 17:12:55 -07002638 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002639}
2640
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302641/**
2642 * csr_roam_remove_duplicate_cmd_from_list()- Remove duplicate roam cmd from
2643 * list
2644 *
2645 * @pMac: pointer to global mac
2646 * @sessionId: session id for the cmd
2647 * @pList: pending list from which cmd needs to be removed
2648 * @pCommand: cmd to be removed, can be NULL
2649 * @eRoamReason: cmd with reason to be removed
2650 *
2651 * Remove duplicate command from the pending list.
2652 *
2653 * Return: void
2654 */
2655void csr_roam_remove_duplicate_cmd_from_list(tpAniSirGlobal pMac,
2656 tANI_U32 sessionId, tDblLinkList *pList,
2657 tSmeCmd *pCommand, eCsrRoamReason eRoamReason)
Jeff Johnson295189b2012-06-20 16:38:30 -07002658{
2659 tListElem *pEntry, *pNextEntry;
2660 tSmeCmd *pDupCommand;
2661 tDblLinkList localList;
2662
2663 vos_mem_zero(&localList, sizeof(tDblLinkList));
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302664 if (!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
Jeff Johnson295189b2012-06-20 16:38:30 -07002665 {
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302666 smsLog(pMac, LOGE, FL("failed to open list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002667 return;
2668 }
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302669 csrLLLock(pList);
2670 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
2671 while (pEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -07002672 {
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302673 pNextEntry = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
2674 pDupCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
2675 /*
2676 * Remove the previous command if..
2677 * - the new roam command is for the same RoamReason...
2678 * - the new roam command is a NewProfileList.
2679 * - the new roam command is a Forced Dissoc
2680 * - the new roam command is from an 802.11 OID
2681 * (OID_SSID or OID_BSSID).
2682 */
2683 if ((pCommand && (pCommand->sessionId == pDupCommand->sessionId) &&
2684 ((pCommand->command == pDupCommand->command) &&
2685 /*
2686 * This peermac check is requried for Softap/GO scenarios
2687 * For STA scenario below OR check will suffice as pCommand
2688 * will always be NULL for STA scenarios
2689 */
2690 (vos_mem_compare(pDupCommand->u.roamCmd.peerMac,
2691 pCommand->u.roamCmd.peerMac, sizeof(v_MACADDR_t))) &&
2692 ((pCommand->u.roamCmd.roamReason ==
2693 pDupCommand->u.roamCmd.roamReason) ||
2694 (eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason) ||
2695 (eCsrHddIssued == pCommand->u.roamCmd.roamReason)))) ||
2696 /* OR if pCommand is NULL */
2697 ((sessionId == pDupCommand->sessionId) &&
2698 (eSmeCommandRoam == pDupCommand->command) &&
2699 ((eCsrForcedDisassoc == eRoamReason) ||
2700 (eCsrHddIssued == eRoamReason))))
Jeff Johnson295189b2012-06-20 16:38:30 -07002701 {
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302702 smsLog(pMac, LOGW, FL("RoamReason = %d"),
2703 pDupCommand->u.roamCmd.roamReason);
2704 /* Remove the 'stale' roam command from the pending list */
2705 if (csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
Jeff Johnson295189b2012-06-20 16:38:30 -07002706 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
Jeff Johnson295189b2012-06-20 16:38:30 -07002707 }
2708 pEntry = pNextEntry;
2709 }
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302710 csrLLUnlock(pList);
Jeff Johnson295189b2012-06-20 16:38:30 -07002711
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302712 while ((pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)))
Jeff Johnson295189b2012-06-20 16:38:30 -07002713 {
2714 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302715 /* Tell caller that the command is cancelled */
2716 csrRoamCallCallback(pMac, pDupCommand->sessionId, NULL,
2717 pDupCommand->u.roamCmd.roamId,
2718 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002719 csrReleaseCommandRoam(pMac, pDupCommand);
2720 }
2721 csrLLClose(&localList);
2722}
Abhishek Singh2d0f1502015-12-23 11:45:45 +05302723
2724/**
2725 * csrRoamRemoveDuplicateCommand()- Remove duplicate roam cmd
2726 * from pending lists.
2727 *
2728 * @pMac: pointer to global mac
2729 * @sessionId: session id for the cmd
2730 * @pCommand: cmd to be removed, can be null
2731 * @eRoamReason: cmd with reason to be removed
2732 *
2733 * Remove duplicate command from the sme and roam pending list.
2734 *
2735 * Return: void
2736 */
2737void csrRoamRemoveDuplicateCommand(tpAniSirGlobal pMac,
2738 tANI_U32 sessionId, tSmeCmd *pCommand,
2739 eCsrRoamReason eRoamReason)
2740{
2741 /* Always lock active list before locking pending lists */
2742 csrLLLock(&pMac->sme.smeCmdActiveList);
2743 csr_roam_remove_duplicate_cmd_from_list(pMac,
2744 sessionId, &pMac->sme.smeCmdPendingList,
2745 pCommand, eRoamReason);
2746 csr_roam_remove_duplicate_cmd_from_list(pMac,
2747 sessionId, &pMac->roam.roamCmdPendingList,
2748 pCommand, eRoamReason);
2749 csrLLUnlock(&pMac->sme.smeCmdActiveList);
2750}
2751
Jeff Johnson295189b2012-06-20 16:38:30 -07002752eHalStatus csrRoamCallCallback(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo,
2753 tANI_U32 roamId, eRoamCmdStatus u1, eCsrRoamResult u2)
2754{
2755 eHalStatus status = eHAL_STATUS_SUCCESS;
2756#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2757 WLAN_VOS_DIAG_EVENT_DEF(connectionStatus, vos_event_wlan_status_payload_type);
2758#endif
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05302759 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002760 if( CSR_IS_SESSION_VALID( pMac, sessionId) )
2761 {
2762 pSession = CSR_GET_SESSION( pMac, sessionId );
2763 }
2764 else
2765 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002766 smsLog(pMac, LOGE, "Session ID:%d is not valid", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002767 VOS_ASSERT(0);
2768 return eHAL_STATUS_FAILURE;
2769 }
krunal soni587bf012014-02-04 12:35:11 -08002770
2771 if (eANI_BOOLEAN_FALSE == pSession->sessionActive)
2772 {
2773 smsLog(pMac, LOG1, "%s Session is not Active", __func__);
2774 return eHAL_STATUS_FAILURE;
2775 }
krunal soni7f7d2c92014-02-06 15:08:43 -08002776
krunal soni587bf012014-02-04 12:35:11 -08002777 smsLog(pMac, LOG4, "Recieved RoamCmdStatus %d with Roam Result %d", u1, u2);
2778
krunal soni7f7d2c92014-02-06 15:08:43 -08002779 if(eCSR_ROAM_ASSOCIATION_COMPLETION == u1 && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002780 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002781 smsLog(pMac, LOGW, " Assoc complete result = %d statusCode = %d reasonCode = %d", u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002782 }
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07002783 if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED) && (pSession->bRefAssocStartCnt)) {
2784 /*
2785 * Decrement bRefAssocStartCnt for FT reassoc failure.
2786 * Reason: For FT reassoc failures, we first call
2787 * csrRoamCallCallback before notifying a failed roam
2788 * completion through csrRoamComplete. The latter in
2789 * turn calls csrRoamProcessResults which tries to
2790 * once again call csrRoamCallCallback if bRefAssocStartCnt
2791 * is non-zero. Since this is redundant for FT reassoc
2792 * failure, decrement bRefAssocStartCnt.
2793 */
2794 pSession->bRefAssocStartCnt--;
2795 }
2796
Jeff Johnson295189b2012-06-20 16:38:30 -07002797 if(NULL != pSession->callback)
2798 {
2799 if( pRoamInfo )
2800 {
2801 pRoamInfo->sessionId = (tANI_U8)sessionId;
2802 }
2803
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302804 /* avoid holding the global lock when making the roaming callback, original change came
2805 from a raised CR (CR304874). Since this callback is in HDD a potential deadlock
2806 is possible on other OS ports where the callback may need to take locks to protect
2807 HDD state
Jeff Johnson295189b2012-06-20 16:38:30 -07002808 UPDATE : revert this change but keep the comments here. Need to revisit as there are callbacks
2809 that may actually depend on the lock being held */
2810 // TODO: revisit: sme_ReleaseGlobalLock( &pMac->sme );
2811 status = pSession->callback(pSession->pContext, pRoamInfo, roamId, u1, u2);
2812 // TODO: revisit: sme_AcquireGlobalLock( &pMac->sme );
2813 }
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05302814 //EVENT_WLAN_STATUS_V2: eCSR_ROAM_ASSOCIATION_COMPLETION,
2815 // eCSR_ROAM_LOSTLINK, eCSR_ROAM_DISASSOCIATED,
Jeff Johnson295189b2012-06-20 16:38:30 -07002816#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiet Lam64c1b492013-07-12 13:56:44 +05302817 vos_mem_set(&connectionStatus,
2818 sizeof(vos_event_wlan_status_payload_type), 0);
2819
krunal soni7f7d2c92014-02-06 15:08:43 -08002820 if((eCSR_ROAM_ASSOCIATION_COMPLETION == u1) && (eCSR_ROAM_RESULT_ASSOCIATED == u2) && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002821 {
2822 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
2823 connectionStatus.bssType = pRoamInfo->u.pConnectedProfile->BSSType;
2824 if(NULL != pRoamInfo->pBssDesc)
2825 {
2826 connectionStatus.rssi = pRoamInfo->pBssDesc->rssi * (-1);
2827 connectionStatus.channel = pRoamInfo->pBssDesc->channelId;
2828 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002829 connectionStatus.qosCapability = pRoamInfo->u.pConnectedProfile->qosConnection;
2830 connectionStatus.authType = (v_U8_t)diagAuthTypeFromCSRType(pRoamInfo->u.pConnectedProfile->AuthType);
2831 connectionStatus.encryptionType = (v_U8_t)diagEncTypeFromCSRType(pRoamInfo->u.pConnectedProfile->EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05302832 vos_mem_copy(connectionStatus.ssid,
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05302833 pRoamInfo->u.pConnectedProfile->SSID.ssId,
2834 pRoamInfo->u.pConnectedProfile->SSID.length);
Kiet Lam64c1b492013-07-12 13:56:44 +05302835
Jeff Johnson295189b2012-06-20 16:38:30 -07002836 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05302837 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS_V2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002838 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002839 if((eCSR_ROAM_MIC_ERROR_IND == u1) || (eCSR_ROAM_RESULT_MIC_FAILURE == u2))
2840 {
2841 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2842 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05302843 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS_V2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002844 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002845 if(eCSR_ROAM_RESULT_FORCED == u2)
2846 {
2847 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2848 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05302849 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS_V2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002850 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002851 if(eCSR_ROAM_RESULT_DISASSOC_IND == u2)
2852 {
2853 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2854 connectionStatus.reason = eCSR_REASON_DISASSOC;
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05302855 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS_V2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002856 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002857 if(eCSR_ROAM_RESULT_DEAUTH_IND == u2)
2858 {
2859 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2860 connectionStatus.reason = eCSR_REASON_DEAUTH;
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05302861 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS_V2);
Jeff Johnson295189b2012-06-20 16:38:30 -07002862 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002863#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
2864
2865 return (status);
2866}
Jeff Johnson295189b2012-06-20 16:38:30 -07002867// Returns whether handoff is currently in progress or not
2868tANI_BOOLEAN csrRoamIsHandoffInProgress(tpAniSirGlobal pMac)
2869{
2870#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2871 return csrNeighborRoamIsHandoffInProgress(pMac);
2872#else
2873 return eANI_BOOLEAN_FALSE;
2874#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002875}
Jeff Johnson295189b2012-06-20 16:38:30 -07002876eHalStatus csrRoamIssueDisassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
2877 eCsrRoamSubState NewSubstate, tANI_BOOLEAN fMICFailure )
2878{
2879 eHalStatus status = eHAL_STATUS_SUCCESS;
2880 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2881 tANI_U16 reasonCode;
2882 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002883
2884 if(!pSession)
2885 {
2886 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2887 return eHAL_STATUS_FAILURE;
2888 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002889
2890 //Restore AC weight in case we change it
2891 if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
2892 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07002893 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 -07002894 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
2895 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
2896 }
2897
2898 if ( fMICFailure )
2899 {
2900 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
2901 }
2902 else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)
2903 {
2904 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002905 }
2906 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002907 {
2908 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
2909 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002910#ifdef WLAN_FEATURE_VOWIFI_11R
2911 if ( (csrRoamIsHandoffInProgress(pMac)) &&
2912 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF))
2913 {
2914 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05302915 vos_mem_copy(&bssId,
2916 pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid,
2917 sizeof(tSirMacAddr));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002918 }
2919 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002920#endif
2921 if(pSession->pConnectBssDesc)
2922 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302923 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002924 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002925
Jeff Johnson295189b2012-06-20 16:38:30 -07002926
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05302927 smsLog(pMac, LOG2, FL("CSR Attempting to Disassociate Bssid="MAC_ADDRESS_STR
2928 " subState = %s reason=%d"),
2929 MAC_ADDR_ARRAY(bssId), macTraceGetcsrRoamSubState(NewSubstate),
2930 reasonCode);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08002931
Jeff Johnson295189b2012-06-20 16:38:30 -07002932 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2933
2934 status = csrSendMBDisassocReqMsg( pMac, sessionId, bssId, reasonCode );
2935
2936 if(HAL_STATUS_SUCCESS(status))
2937 {
2938 csrRoamLinkDown(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002939#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2940 //no need to tell QoS that we are disassociating, it will be taken care off in assoc req for HO
2941 if(eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate)
2942 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002943 //notify QoS module that disassoc happening
Jeff Johnson295189b2012-06-20 16:38:30 -07002944 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
2945 }
2946#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002947 }
2948 else
2949 {
2950 smsLog(pMac, LOGW, FL("csrSendMBDisassocReqMsg failed with status %d"), status);
2951 }
2952
Jeff Johnson295189b2012-06-20 16:38:30 -07002953 return (status);
2954}
Jeff Johnson295189b2012-06-20 16:38:30 -07002955
Jeff Johnson295189b2012-06-20 16:38:30 -07002956/* ---------------------------------------------------------------------------
2957 \fn csrRoamIssueDisassociateStaCmd
2958 \brief csr function that HDD calls to disassociate a associated station
2959 \param sessionId - session Id for Soft AP
2960 \param pPeerMacAddr - MAC of associated station to delete
2961 \param reason - reason code, be one of the tSirMacReasonCodes
2962 \return eHalStatus
2963 ---------------------------------------------------------------------------*/
2964eHalStatus csrRoamIssueDisassociateStaCmd( tpAniSirGlobal pMac,
Anand N Sunkadc205d952015-07-30 15:36:03 +05302965 tANI_U32 sessionId,
2966#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
2967 const tANI_U8 *pPeerMacAddr,
2968#else
Jeff Johnson295189b2012-06-20 16:38:30 -07002969 tANI_U8 *pPeerMacAddr,
Anand N Sunkadc205d952015-07-30 15:36:03 +05302970#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002971 tANI_U32 reason)
2972{
2973 eHalStatus status = eHAL_STATUS_SUCCESS;
2974 tSmeCmd *pCommand;
2975
2976 do
2977 {
2978 pCommand = csrGetCommandBuffer( pMac );
2979 if ( !pCommand )
2980 {
2981 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2982 status = eHAL_STATUS_RESOURCES;
2983 break;
2984 }
2985 pCommand->command = eSmeCommandRoam;
2986 pCommand->sessionId = (tANI_U8)sessionId;
2987 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
2988 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2989 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2990 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2991 if( !HAL_STATUS_SUCCESS( status ) )
2992 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002993 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002994 csrReleaseCommandRoam( pMac, pCommand );
2995 }
2996 }while(0);
2997
2998 return status;
2999}
3000
3001
Jeff Johnson295189b2012-06-20 16:38:30 -07003002/* ---------------------------------------------------------------------------
3003 \fn csrRoamIssueDeauthSta
3004 \brief csr function that HDD calls to delete a associated station
3005 \param sessionId - session Id for Soft AP
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05303006 \param pDelStaParams- Pointer to parameters of the station to deauthenticate
Jeff Johnson295189b2012-06-20 16:38:30 -07003007 \return eHalStatus
3008 ---------------------------------------------------------------------------*/
3009eHalStatus csrRoamIssueDeauthStaCmd( tpAniSirGlobal pMac,
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05303010 tANI_U32 sessionId,
3011 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -07003012{
3013 eHalStatus status = eHAL_STATUS_SUCCESS;
3014 tSmeCmd *pCommand;
3015
3016 do
3017 {
3018 pCommand = csrGetCommandBuffer( pMac );
3019 if ( !pCommand )
3020 {
3021 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
3022 status = eHAL_STATUS_RESOURCES;
3023 break;
3024 }
3025 pCommand->command = eSmeCommandRoam;
3026 pCommand->sessionId = (tANI_U8)sessionId;
3027 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05303028 vos_mem_copy(pCommand->u.roamCmd.peerMac, pDelStaParams->peerMacAddr,
3029 sizeof(tSirMacAddr));
3030 pCommand->u.roamCmd.reason =
3031 (tSirMacReasonCodes)pDelStaParams->reason_code;
Jeff Johnson295189b2012-06-20 16:38:30 -07003032 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
3033 if( !HAL_STATUS_SUCCESS( status ) )
3034 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003035 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07003036 csrReleaseCommandRoam( pMac, pCommand );
3037 }
3038 }while(0);
3039
3040 return status;
3041}
Jeff Johnson295189b2012-06-20 16:38:30 -07003042eHalStatus
3043csrRoamIssueTkipCounterMeasures( tpAniSirGlobal pMac, tANI_U32 sessionId,
3044 tANI_BOOLEAN bEnable )
3045{
3046 eHalStatus status = eHAL_STATUS_FAILURE;
3047 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
3048 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07003049 if (!pSession)
3050 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003051 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07003052 return (status);
3053 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003054 if (pSession->pConnectBssDesc)
3055 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303056 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003057 }
3058 else
3059 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003060 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07003061 return (status);
3062 }
Arif Hussain24bafea2013-11-15 15:10:03 -08003063 smsLog( pMac, LOG2, "CSR issuing tkip counter measures for Bssid = "MAC_ADDRESS_STR", Enable = %d",
3064 MAC_ADDR_ARRAY(bssId), bEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07003065 status = csrSendMBTkipCounterMeasuresReqMsg( pMac, sessionId, bEnable, bssId );
3066 return (status);
3067}
Jeff Johnson295189b2012-06-20 16:38:30 -07003068eHalStatus
3069csrRoamGetAssociatedStas( tpAniSirGlobal pMac, tANI_U32 sessionId,
3070 VOS_MODULE_ID modId, void *pUsrContext,
3071 void *pfnSapEventCallback, v_U8_t *pAssocStasBuf )
3072{
3073 eHalStatus status = eHAL_STATUS_SUCCESS;
3074 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
3075 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07003076 if (!pSession)
3077 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003078 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07003079 return (status);
3080 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003081 if(pSession->pConnectBssDesc)
3082 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303083 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003084 }
3085 else
3086 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003087 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07003088 return (status);
3089 }
Arif Hussain24bafea2013-11-15 15:10:03 -08003090 smsLog( pMac, LOG2, "CSR getting associated stations for Bssid = "MAC_ADDRESS_STR,
3091 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07003092 status = csrSendMBGetAssociatedStasReqMsg( pMac, sessionId, modId, bssId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
3093 return (status);
3094}
Jeff Johnson295189b2012-06-20 16:38:30 -07003095eHalStatus
3096csrRoamGetWpsSessionOverlap( tpAniSirGlobal pMac, tANI_U32 sessionId,
3097 void *pUsrContext, void *pfnSapEventCallback, v_MACADDR_t pRemoveMac )
3098{
3099 eHalStatus status = eHAL_STATUS_SUCCESS;
3100 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
3101 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
3102
3103 if (!pSession)
3104 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003105 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07003106 return (status);
3107 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003108 if(pSession->pConnectBssDesc)
3109 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303110 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003111 }
3112 else
3113 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003114 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07003115 return (status);
3116 }
Arif Hussain24bafea2013-11-15 15:10:03 -08003117 smsLog( pMac, LOG2, "CSR getting WPS Session Overlap for Bssid = "MAC_ADDRESS_STR,
3118 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07003119
3120 status = csrSendMBGetWPSPBCSessions( pMac, sessionId, bssId, pUsrContext, pfnSapEventCallback, pRemoveMac);
3121
3122 return (status);
3123}
Jeff Johnson295189b2012-06-20 16:38:30 -07003124eHalStatus csrRoamIssueDeauth( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
3125{
3126 eHalStatus status = eHAL_STATUS_SUCCESS;
3127 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
3128 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003129
3130 if (!pSession)
3131 {
3132 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3133 return eHAL_STATUS_FAILURE;
3134 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003135
3136 if(pSession->pConnectBssDesc)
3137 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303138 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003139 }
Arif Hussain24bafea2013-11-15 15:10:03 -08003140 smsLog( pMac, LOG2, "CSR Attempting to Deauth Bssid= "MAC_ADDRESS_STR,
3141 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07003142 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
3143
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05303144 status = csrSendMBDeauthReqMsg( pMac, sessionId, bssId, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON );
Mukul Sharma45049182014-06-17 23:34:10 +05303145 if(HAL_STATUS_SUCCESS(status))
3146 {
3147 csrRoamLinkDown(pMac, sessionId);
3148 }
3149 else
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08003150 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05303151 smsLog(pMac, LOGE, FL("csrSendMBDeauthReqMsg failed with status %d Session ID: %d"
3152 MAC_ADDRESS_STR ), status, sessionId, MAC_ADDR_ARRAY(bssId));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08003153 }
3154
Jeff Johnson295189b2012-06-20 16:38:30 -07003155 return (status);
3156}
3157
Jeff Johnson295189b2012-06-20 16:38:30 -07003158eHalStatus csrRoamSaveConnectedBssDesc( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDesc )
3159{
3160 eHalStatus status = eHAL_STATUS_SUCCESS;
3161 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
3162 tANI_U32 size;
Jeff Johnson32d95a32012-09-10 13:15:23 -07003163
3164 if(!pSession)
3165 {
3166 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3167 return eHAL_STATUS_FAILURE;
3168 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003169
3170 // If no BSS description was found in this connection (happens with start IBSS), then
3171 // nix the BSS description that we keep around for the connected BSS) and get out...
3172 if(NULL == pBssDesc)
3173 {
3174 csrFreeConnectBssDesc(pMac, sessionId);
3175 }
3176 else
3177 {
3178 size = pBssDesc->length + sizeof( pBssDesc->length );
3179 if(NULL != pSession->pConnectBssDesc)
3180 {
3181 if(((pSession->pConnectBssDesc->length) + sizeof(pSession->pConnectBssDesc->length)) < size)
3182 {
3183 //not enough room for the new BSS, pMac->roam.pConnectBssDesc is freed inside
3184 csrFreeConnectBssDesc(pMac, sessionId);
3185 }
3186 }
3187 if(NULL == pSession->pConnectBssDesc)
3188 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303189 pSession->pConnectBssDesc = vos_mem_malloc(size);
Jeff Johnson295189b2012-06-20 16:38:30 -07003190 }
Kiet Lam64c1b492013-07-12 13:56:44 +05303191 if (NULL == pSession->pConnectBssDesc)
3192 status = eHAL_STATUS_FAILURE;
3193 else
3194 vos_mem_copy(pSession->pConnectBssDesc, pBssDesc, size);
3195 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003196 return (status);
3197}
3198
Jeff Johnson295189b2012-06-20 16:38:30 -07003199eHalStatus csrRoamPrepareBssConfig(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
3200 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
3201 tDot11fBeaconIEs *pIes)
3202{
3203 eHalStatus status = eHAL_STATUS_SUCCESS;
3204 eCsrCfgDot11Mode cfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003205 VOS_ASSERT( pIes != NULL );
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +05303206 if (pIes == NULL)
3207 return eHAL_STATUS_FAILURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07003208
Jeff Johnson295189b2012-06-20 16:38:30 -07003209 do
3210 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303211 vos_mem_copy(&pBssConfig->BssCap, &pBssDesc->capabilityInfo,
3212 sizeof(tSirMacCapabilityInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07003213 //get qos
3214 pBssConfig->qosType = csrGetQoSFromBssDesc(pMac, pBssDesc, pIes);
3215 //get SSID
3216 if(pIes->SSID.present)
3217 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303218 vos_mem_copy(&pBssConfig->SSID.ssId, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07003219 pBssConfig->SSID.length = pIes->SSID.num_ssid;
3220 }
3221 else
3222 pBssConfig->SSID.length = 0;
3223 if(csrIsNULLSSID(pBssConfig->SSID.ssId, pBssConfig->SSID.length))
3224 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003225 smsLog(pMac, LOGW, " BSS desc SSID is a wildcard");
Jeff Johnson295189b2012-06-20 16:38:30 -07003226 //Return failed if profile doesn't have an SSID either.
3227 if(pProfile->SSIDs.numOfSSIDs == 0)
3228 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003229 smsLog(pMac, LOGW, " Both BSS desc and profile doesn't have SSID");
Jeff Johnson295189b2012-06-20 16:38:30 -07003230 status = eHAL_STATUS_FAILURE;
3231 break;
3232 }
3233 }
3234 if(CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
3235 {
3236 pBssConfig->eBand = eCSR_BAND_5G;
3237 }
3238 else
3239 {
3240 pBssConfig->eBand = eCSR_BAND_24;
3241 }
3242 //phymode
3243 if(csrIsPhyModeMatch( pMac, pProfile->phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes ))
3244 {
3245 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
3246 }
3247 else
3248 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003249 smsLog(pMac, LOGW, " Can not find match phy mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07003250 //force it
3251 if(eCSR_BAND_24 == pBssConfig->eBand)
3252 {
3253 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
3254 }
3255 else
3256 {
3257 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
3258 }
3259 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003260 //Qos
3261 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
3262 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos))
3263 {
3264 //Joining BSS is not 11n capable and WMM is disabled on client.
3265 //Disable QoS and WMM
3266 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3267 }
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05303268
3269 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
Pratik Bhalgat8d461642012-11-22 16:55:42 +05303270 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC)) &&
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05303271 ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP) ||
3272 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF) ||
3273 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF) ))
3274 {
3275 //Joining BSS is 11n capable and WMM is disabled on AP.
3276 //Assume all HT AP's are QOS AP's and enable WMM
3277 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3278 }
3279
Jeff Johnson295189b2012-06-20 16:38:30 -07003280 //auth type
3281 switch( pProfile->negotiatedAuthType )
3282 {
3283 default:
3284 case eCSR_AUTH_TYPE_WPA:
3285 case eCSR_AUTH_TYPE_WPA_PSK:
3286 case eCSR_AUTH_TYPE_WPA_NONE:
3287 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3288 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3289 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003290 case eCSR_AUTH_TYPE_SHARED_KEY:
3291 pBssConfig->authType = eSIR_SHARED_KEY;
3292 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003293 case eCSR_AUTH_TYPE_AUTOSWITCH:
3294 pBssConfig->authType = eSIR_AUTO_SWITCH;
3295 break;
3296 }
3297 //short slot time
3298 if( eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode )
3299 {
3300 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3301 }
3302 else
3303 {
3304 pBssConfig->uShortSlotTime = 0;
3305 }
3306 if(pBssConfig->BssCap.ibss)
3307 {
3308 //We don't support 11h on IBSS
3309 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3310 }
3311 else
3312 {
3313 pBssConfig->f11hSupport = pMac->roam.configParam.Is11hSupportEnabled;
3314 }
3315 //power constraint
3316 pBssConfig->uPowerLimit = csrGet11hPowerConstraint(pMac, &pIes->PowerConstraints);
3317 //heartbeat
3318 if ( CSR_IS_11A_BSS( pBssDesc ) )
3319 {
3320 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3321 }
3322 else
3323 {
3324 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3325 }
3326 //Join timeout
3327 // if we find a BeaconInterval in the BssDescription, then set the Join Timeout to
Jeff Johnsone7245742012-09-05 17:12:55 -07003328 // be 10 x the BeaconInterval.
Jeff Johnson295189b2012-06-20 16:38:30 -07003329 if ( pBssDesc->beaconInterval )
3330 {
3331 //Make sure it is bigger than the minimal
Jeff Johnsone7245742012-09-05 17:12:55 -07003332 pBssConfig->uJoinTimeOut = CSR_ROAM_MAX(10 * pBssDesc->beaconInterval, CSR_JOIN_FAILURE_TIMEOUT_MIN);
Jeff Johnson295189b2012-06-20 16:38:30 -07003333 }
3334 else
3335 {
3336 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
3337 }
3338 //validate CB
3339 pBssConfig->cbMode = csrGetCBModeFromIes(pMac, pBssDesc->channelId, pIes);
Sushant Kaushik2a1fcc82015-01-22 19:32:44 +05303340 smsLog(pMac, LOG1, FL("Bss Cb is %d, join timeout is %d, HB thresh is %d,"),
3341 pBssConfig->cbMode, pBssConfig->uJoinTimeOut, pBssConfig->uHeartBeatThresh);
Jeff Johnson295189b2012-06-20 16:38:30 -07003342 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003343 return (status);
3344}
3345
Jeff Johnson295189b2012-06-20 16:38:30 -07003346static eHalStatus csrRoamPrepareBssConfigFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
3347 tBssConfigParam *pBssConfig, tSirBssDescription *pBssDesc)
3348{
3349 eHalStatus status = eHAL_STATUS_SUCCESS;
3350 tANI_U8 operationChannel = 0;
3351 tANI_U8 qAPisEnabled = FALSE;
3352 //SSID
3353 pBssConfig->SSID.length = 0;
3354 if(pProfile->SSIDs.numOfSSIDs)
3355 {
3356 //only use the first one
Kiet Lam64c1b492013-07-12 13:56:44 +05303357 vos_mem_copy(&pBssConfig->SSID, &pProfile->SSIDs.SSIDList[0].SSID,
3358 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003359 }
3360 else
3361 {
3362 //SSID must present
3363 return eHAL_STATUS_FAILURE;
3364 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003365 //Settomg up the capabilities
3366 if( csrIsBssTypeIBSS(pProfile->BSSType) )
3367 {
3368 pBssConfig->BssCap.ibss = 1;
3369 }
3370 else
3371 {
3372 pBssConfig->BssCap.ess = 1;
3373 }
3374 if( eCSR_ENCRYPT_TYPE_NONE != pProfile->EncryptionType.encryptionType[0] )
3375 {
3376 pBssConfig->BssCap.privacy = 1;
3377 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003378 pBssConfig->eBand = pMac->roam.configParam.eBand;
3379 //phymode
3380 if(pProfile->ChannelInfo.ChannelList)
3381 {
3382 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3383 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003384 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, operationChannel,
3385 &pBssConfig->eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07003386 //QOS
3387 //Is this correct to always set to this //***
Jeff Johnson295189b2012-06-20 16:38:30 -07003388 if ( pBssConfig->BssCap.ess == 1 )
3389 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003390 /*For Softap case enable WMM*/
3391 if(CSR_IS_INFRA_AP(pProfile) && (eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode )){
3392 qAPisEnabled = TRUE;
3393 }
3394 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003395 if (csrRoamGetQosInfoFromBss(pMac, pBssDesc) == eHAL_STATUS_SUCCESS) {
3396 qAPisEnabled = TRUE;
3397 } else {
3398 qAPisEnabled = FALSE;
3399 }
3400 } else {
3401 qAPisEnabled = TRUE;
3402 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003403 if (( eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode && qAPisEnabled) ||
3404 (( eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode && qAPisEnabled) ||
3405 ( eCSR_CFG_DOT11_MODE_TAURUS == pBssConfig->uCfgDot11Mode ) ) //For 11n, need QoS
3406 )
3407 {
3408 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3409 } else {
3410 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3411 }
3412
3413 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08003414 switch( pProfile->AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07003415 {
3416 default:
3417 case eCSR_AUTH_TYPE_WPA:
3418 case eCSR_AUTH_TYPE_WPA_PSK:
3419 case eCSR_AUTH_TYPE_WPA_NONE:
3420 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3421 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3422 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003423 case eCSR_AUTH_TYPE_SHARED_KEY:
3424 pBssConfig->authType = eSIR_SHARED_KEY;
3425 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003426 case eCSR_AUTH_TYPE_AUTOSWITCH:
3427 pBssConfig->authType = eSIR_AUTO_SWITCH;
3428 break;
3429 }
3430 //short slot time
3431 if( WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode )
3432 {
3433 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3434 }
3435 else
3436 {
3437 pBssConfig->uShortSlotTime = 0;
3438 }
3439 //power constraint. We don't support 11h on IBSS
3440 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3441 pBssConfig->uPowerLimit = 0;
3442 //heartbeat
3443 if ( eCSR_BAND_5G == pBssConfig->eBand )
3444 {
3445 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3446 }
3447 else
3448 {
3449 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3450 }
3451 //Join timeout
3452 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07003453
Jeff Johnson295189b2012-06-20 16:38:30 -07003454 return (status);
3455}
Jeff Johnson295189b2012-06-20 16:38:30 -07003456static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc)
3457{
3458 eHalStatus status = eHAL_STATUS_FAILURE;
3459 tDot11fBeaconIEs *pIes = NULL;
3460
3461 do
3462 {
3463 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
3464 {
3465 //err msg
3466 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003467 "csrRoamGetQosInfoFromBss() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07003468 break;
3469 }
3470 //check if the AP is QAP & it supports APSD
3471 if( CSR_IS_QOS_BSS(pIes) )
3472 {
Kiet Lamb537cfb2013-11-07 12:56:49 +05303473 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07003474 }
3475 } while (0);
Kiet Lamb537cfb2013-11-07 12:56:49 +05303476
3477 if (NULL != pIes)
3478 {
3479 vos_mem_free(pIes);
3480 }
3481
Jeff Johnson295189b2012-06-20 16:38:30 -07003482 return status;
3483}
3484
Jeff Johnson295189b2012-06-20 16:38:30 -07003485void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
3486{
Jeff Johnson295189b2012-06-20 16:38:30 -07003487 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
3488 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
3489 // See !!Note: below in this function...
3490 tANI_U32 PrivacyEnabled = 0;
3491 tANI_U32 RsnEnabled = 0;
3492 tANI_U32 WepDefaultKeyId = 0;
3493 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
3494 tANI_U32 Key0Length = 0;
3495 tANI_U32 Key1Length = 0;
3496 tANI_U32 Key2Length = 0;
3497 tANI_U32 Key3Length = 0;
3498
3499 // Reserve for the biggest key
3500 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
3501 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
3502 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
3503 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
3504
3505 switch ( pProfile->negotiatedUCEncryptionType )
3506 {
3507 case eCSR_ENCRYPT_TYPE_NONE:
3508
3509 // for NO encryption, turn off Privacy and Rsn.
3510 PrivacyEnabled = 0;
3511 RsnEnabled = 0;
3512
3513 // WEP key length and Wep Default Key ID don't matter in this case....
3514
3515 // clear out the WEP keys that may be hanging around.
3516 Key0Length = 0;
3517 Key1Length = 0;
3518 Key2Length = 0;
3519 Key3Length = 0;
3520
3521 break;
3522
3523 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303524 case eCSR_ENCRYPT_TYPE_WEP40:
Jeff Johnson295189b2012-06-20 16:38:30 -07003525
3526 // Privacy is ON. NO RSN for Wep40 static key.
3527 PrivacyEnabled = 1;
3528 RsnEnabled = 0;
3529
3530 // Set the Wep default key ID.
3531 WepDefaultKeyId = pProfile->Keys.defaultIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07003532 // Wep key size if 5 bytes (40 bits).
3533 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
3534
3535 // set encryption keys in the CFG database or clear those that are not present in this profile.
3536 if ( pProfile->Keys.KeyLength[0] )
3537 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303538 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[0],
3539 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003540 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
3541 }
3542 else
3543 {
3544 Key0Length = 0;
3545 }
3546
3547 if ( pProfile->Keys.KeyLength[1] )
3548 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303549 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[1],
3550 WNI_CFG_WEP_KEY_LENGTH_5);
3551 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
Jeff Johnson295189b2012-06-20 16:38:30 -07003552 }
3553 else
3554 {
3555 Key1Length = 0;
3556 }
3557
3558 if ( pProfile->Keys.KeyLength[2] )
3559 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303560 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[2],
3561 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003562 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
3563 }
3564 else
3565 {
3566 Key2Length = 0;
3567 }
3568
3569 if ( pProfile->Keys.KeyLength[3] )
3570 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303571 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[3],
3572 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003573 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
3574 }
3575 else
3576 {
3577 Key3Length = 0;
3578 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003579 break;
3580
3581 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303582 case eCSR_ENCRYPT_TYPE_WEP104:
Jeff Johnson295189b2012-06-20 16:38:30 -07003583
3584 // Privacy is ON. NO RSN for Wep40 static key.
3585 PrivacyEnabled = 1;
3586 RsnEnabled = 0;
3587
3588 // Set the Wep default key ID.
3589 WepDefaultKeyId = pProfile->Keys.defaultIndex;
3590
3591 // Wep key size if 13 bytes (104 bits).
3592 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
3593
3594 // set encryption keys in the CFG database or clear those that are not present in this profile.
3595 if ( pProfile->Keys.KeyLength[0] )
3596 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303597 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[ 0 ],
3598 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003599 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
3600 }
3601 else
3602 {
3603 Key0Length = 0;
3604 }
3605
3606 if ( pProfile->Keys.KeyLength[1] )
3607 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303608 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[ 1 ],
3609 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003610 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
3611 }
3612 else
3613 {
3614 Key1Length = 0;
3615 }
3616
3617 if ( pProfile->Keys.KeyLength[2] )
3618 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303619 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[ 2 ],
3620 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003621 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
3622 }
3623 else
3624 {
3625 Key2Length = 0;
3626 }
3627
3628 if ( pProfile->Keys.KeyLength[3] )
3629 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303630 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[ 3 ],
3631 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003632 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
3633 }
3634 else
3635 {
3636 Key3Length = 0;
3637 }
3638
3639 break;
3640
Jeff Johnson295189b2012-06-20 16:38:30 -07003641 case eCSR_ENCRYPT_TYPE_TKIP:
3642 case eCSR_ENCRYPT_TYPE_AES:
3643#ifdef FEATURE_WLAN_WAPI
3644 case eCSR_ENCRYPT_TYPE_WPI:
3645#endif /* FEATURE_WLAN_WAPI */
3646 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
3647 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
3648 PrivacyEnabled = (0 != fPrivacy);
3649
3650 // turn on RSN enabled for WPA associations
3651 RsnEnabled = 1;
3652
3653 // WEP key length and Wep Default Key ID don't matter in this case....
3654
3655 // clear out the static WEP keys that may be hanging around.
3656 Key0Length = 0;
3657 Key1Length = 0;
3658 Key2Length = 0;
3659 Key3Length = 0;
3660
3661 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003662 default:
3663 PrivacyEnabled = 0;
3664 RsnEnabled = 0;
3665 break;
3666 }
3667
3668 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
3669 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
3670 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
3671 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
3672 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
3673 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
3674 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
3675 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
3676}
3677
Jeff Johnson295189b2012-06-20 16:38:30 -07003678static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
3679{
3680 tANI_U32 len = 0;
3681 if(pSSID->length <= WNI_CFG_SSID_LEN)
3682 {
3683 len = pSSID->length;
3684 }
3685 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
3686}
3687
Jeff Johnson295189b2012-06-20 16:38:30 -07003688eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
3689{
3690 eHalStatus status = eHAL_STATUS_SUCCESS;
3691 tANI_U32 QoSEnabled;
3692 tANI_U32 WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003693 // set the CFG enable/disable variables based on the qosType being configured...
3694 switch( qosType )
3695 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003696 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
3697 QoSEnabled = FALSE;
3698 WmeEnabled = TRUE;
3699 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003700 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
3701 QoSEnabled = FALSE;
3702 WmeEnabled = TRUE;
3703 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003704 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
3705 QoSEnabled = FALSE;
3706 WmeEnabled = TRUE;
3707 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003708 case eCSR_MEDIUM_ACCESS_11e_eDCF:
3709 QoSEnabled = TRUE;
3710 WmeEnabled = FALSE;
3711 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003712 case eCSR_MEDIUM_ACCESS_11e_HCF:
3713 QoSEnabled = TRUE;
3714 WmeEnabled = FALSE;
3715 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003716 default:
3717 case eCSR_MEDIUM_ACCESS_DCF:
3718 QoSEnabled = FALSE;
3719 WmeEnabled = FALSE;
3720 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003721 }
3722 //save the WMM setting for later use
3723 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
Sandeep Puligillaaea98a22013-12-04 13:36:32 +05303724 pMac->roam.roamSession[sessionId].fQOSConnection = (tANI_BOOLEAN)QoSEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003725 return (status);
3726}
Jeff Johnson295189b2012-06-20 16:38:30 -07003727static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05303728 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet, tANI_U16 *pRateBitmap)
Jeff Johnson295189b2012-06-20 16:38:30 -07003729{
3730 eHalStatus status = eHAL_STATUS_FAILURE;
3731 int i;
3732 eCsrCfgDot11Mode cfgDot11Mode;
3733 tANI_U8 *pDstRate;
Masti, Narayanraddi3f5affe2015-01-08 12:10:08 +05303734 tANI_U16 rateBitmap = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05303735 vos_mem_set(pOpRateSet, sizeof(tSirMacRateSet), 0);
3736 vos_mem_set(pExRateSet, sizeof(tSirMacRateSet), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003737 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003738
3739 if( NULL != pIes )
3740 {
3741 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003742 // Originally, we thought that for 11a networks, the 11a rates are always
3743 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3744 // appear in the Operational Rate set. Consequently, in either case, we
3745 // would blindly put the rates we support into our Operational Rate set
3746 // (including the basic rates, which we have already verified are
3747 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003748 // However, it turns out that this is not always the case. Some AP's
3749 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3750 // too. Now, we're a little more careful:
3751 pDstRate = pOpRateSet->rate;
3752 if(pIes->SuppRates.present)
3753 {
3754 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3755 {
3756 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
3757 {
Paul Zhang4f9d1da2015-08-13 13:48:11 +08003758 if ( !csrIsRateAlreadyPresent(pIes->SuppRates.rates[ i ], rateBitmap) )
3759 {
3760 csrAddRateBitmap(pIes->SuppRates.rates[ i ], &rateBitmap);
3761 *pDstRate++ = pIes->SuppRates.rates[ i ];
3762 pOpRateSet->numRates++;
3763 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003764 }
3765 }
3766 }
Abhishek Singh5e0e77d2015-09-07 11:50:18 +05303767 /* If there are Extended Rates in the beacon, we will reflect those
3768 * extended rates that we support in out Extended Operational Rate
3769 * set*/
3770 pDstRate = pExRateSet->rate;
3771 if(pIes->ExtSuppRates.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07003772 {
Abhishek Singh5e0e77d2015-09-07 11:50:18 +05303773 for (i = 0; i < pIes->ExtSuppRates.num_rates; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07003774 {
Abhishek Singh5e0e77d2015-09-07 11:50:18 +05303775 if (csrRatesIsDot11RateSupported(pMac,
3776 pIes->ExtSuppRates.rates[ i ]))
Jeff Johnson295189b2012-06-20 16:38:30 -07003777 {
Abhishek Singh5e0e77d2015-09-07 11:50:18 +05303778 if (!csrIsRateAlreadyPresent(pIes->ExtSuppRates.rates[i],
3779 rateBitmap))
Jeff Johnson295189b2012-06-20 16:38:30 -07003780 {
Abhishek Singh5e0e77d2015-09-07 11:50:18 +05303781 csrAddRateBitmap(pIes->ExtSuppRates.rates[i],
3782 &rateBitmap);
3783 *pDstRate++ = pIes->ExtSuppRates.rates[i];
3784 pExRateSet->numRates++;
Jeff Johnson295189b2012-06-20 16:38:30 -07003785 }
3786 }
3787 }
3788 }
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +05303789 *pRateBitmap = rateBitmap;
Jeff Johnson295189b2012-06-20 16:38:30 -07003790 }//Parsing BSSDesc
3791 else
3792 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003793 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003794 }
3795 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
3796 return status;
3797}
3798
3799static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
3800 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3801{
3802 int i;
3803 tANI_U8 *pDstRate;
3804 eCsrCfgDot11Mode cfgDot11Mode;
3805 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3806 tANI_U32 OperationalRatesLength = 0;
3807 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3808 tANI_U32 ExtendedOperationalRatesLength = 0;
3809 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3810 tANI_U32 ProprietaryOperationalRatesLength = 0;
3811 tANI_U32 PropRatesEnable = 0;
3812 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
3813 tANI_U32 MCSRateLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003814 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003815 if( NULL != pIes )
3816 {
3817 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003818 // Originally, we thought that for 11a networks, the 11a rates are always
3819 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3820 // appear in the Operational Rate set. Consequently, in either case, we
3821 // would blindly put the rates we support into our Operational Rate set
3822 // (including the basic rates, which we have already verified are
3823 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003824 // However, it turns out that this is not always the case. Some AP's
3825 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3826 // too. Now, we're a little more careful:
3827 pDstRate = OperationalRates;
3828 if(pIes->SuppRates.present)
3829 {
3830 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3831 {
3832 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
3833 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
3834 {
3835 *pDstRate++ = pIes->SuppRates.rates[ i ];
3836 OperationalRatesLength++;
3837 }
3838 }
3839 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003840 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3841 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3842 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3843 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3844 {
3845 // If there are Extended Rates in the beacon, we will reflect those
3846 // extended rates that we support in out Extended Operational Rate
3847 // set:
3848 pDstRate = ExtendedOperationalRates;
3849 if(pIes->ExtSuppRates.present)
3850 {
3851 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3852 {
3853 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
3854 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
3855 {
3856 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3857 ExtendedOperationalRatesLength++;
3858 }
3859 }
3860 }
3861 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003862 // Enable proprietary MAC features if peer node is Airgo node and STA
3863 // user wants to use them
3864 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
3865 {
3866 PropRatesEnable = 1;
3867 }
3868 else
3869 {
3870 PropRatesEnable = 0;
3871 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003872 // For ANI network companions, we need to populate the proprietary rate
3873 // set with any proprietary rates we found in the beacon, only if user
3874 // allows them...
3875 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
3876 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
3877 {
3878 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
3879 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
3880 {
3881 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
3882 }
Kiet Lam64c1b492013-07-12 13:56:44 +05303883 vos_mem_copy(ProprietaryOperationalRates,
3884 pIes->Airgo.PropSuppRates.rates,
3885 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003886 }
3887 else {
3888 // No proprietary modes...
3889 ProprietaryOperationalRatesLength = 0;
3890 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003891 /* Get MCS Rate */
3892 pDstRate = MCSRateIdxSet;
3893 if ( pIes->HTCaps.present )
3894 {
3895 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
3896 {
3897 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
3898 {
3899 MCSRateLength++;
3900 *pDstRate++ = i;
3901 }
3902 }
3903 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003904 // Set the operational rate set CFG variables...
3905 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3906 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3907 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3908 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3909 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3910 ProprietaryOperationalRates,
3911 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3912 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
3913 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
3914 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
3915 }//Parsing BSSDesc
3916 else
3917 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003918 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003919 }
3920}
3921
Jeff Johnson295189b2012-06-20 16:38:30 -07003922static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
3923 tCsrRoamProfile *pProfile )
3924{
3925 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
3926 { 8,
3927 { SIR_MAC_RATE_6,
3928 SIR_MAC_RATE_9,
3929 SIR_MAC_RATE_12,
3930 SIR_MAC_RATE_18,
3931 SIR_MAC_RATE_24,
3932 SIR_MAC_RATE_36,
3933 SIR_MAC_RATE_48,
3934 SIR_MAC_RATE_54 } } };
Jeff Johnson295189b2012-06-20 16:38:30 -07003935 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
3936 { 4,
3937 { SIR_MAC_RATE_1,
3938 SIR_MAC_RATE_2,
3939 SIR_MAC_RATE_5_5,
3940 SIR_MAC_RATE_11 } } };
3941
3942
3943 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
3944 { SIR_MAC_RATE_72,
3945 SIR_MAC_RATE_96,
3946 SIR_MAC_RATE_108 } };
3947 eCsrCfgDot11Mode cfgDot11Mode;
3948 eCsrBand eBand;
3949 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3950 tANI_U32 OperationalRatesLength = 0;
3951 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3952 tANI_U32 ExtendedOperationalRatesLength = 0;
3953 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3954 tANI_U32 ProprietaryOperationalRatesLength = 0;
3955 tANI_U32 PropRatesEnable = 0;
3956 tANI_U8 operationChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003957 if(pProfile->ChannelInfo.ChannelList)
3958 {
3959 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3960 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003961 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -07003962 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
3963 // networks, the 11b rates appear in the Operational Rate set. In either case,
3964 // we can blindly put the rates we support into our Operational Rate set
3965 // (including the basic rates, which we have already verified are supported
3966 // earlier in the roaming decision).
3967 if ( eCSR_BAND_5G == eBand )
3968 {
3969 // 11a rates into the Operational Rate Set.
3970 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3971 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303972 vos_mem_copy(OperationalRates,
3973 DefaultSupportedRates11a.supportedRateSet.rate,
3974 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003975
3976 // Nothing in the Extended rate set.
3977 ExtendedOperationalRatesLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003978 // populate proprietary rates if user allows them
3979 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3980 {
3981 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3982 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303983 vos_mem_copy(ProprietaryOperationalRates,
3984 DefaultSupportedPropRates.propRate,
3985 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003986 }
3987 else
3988 {
3989 // No proprietary modes
3990 ProprietaryOperationalRatesLength = 0;
3991 }
3992 }
3993 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
3994 {
3995 // 11b rates into the Operational Rate Set.
3996 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3997 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303998 vos_mem_copy(OperationalRates,
3999 DefaultSupportedRates11b.supportedRateSet.rate,
4000 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004001 // Nothing in the Extended rate set.
4002 ExtendedOperationalRatesLength = 0;
4003 // No proprietary modes
4004 ProprietaryOperationalRatesLength = 0;
4005 }
4006 else
4007 {
4008 // 11G
4009
4010 // 11b rates into the Operational Rate Set.
4011 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
4012 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05304013 vos_mem_copy(OperationalRates,
4014 DefaultSupportedRates11b.supportedRateSet.rate,
4015 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004016
4017 // 11a rates go in the Extended rate set.
4018 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
4019 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05304020 vos_mem_copy(ExtendedOperationalRates,
4021 DefaultSupportedRates11a.supportedRateSet.rate,
4022 ExtendedOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004023
4024 // populate proprietary rates if user allows them
4025 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
4026 {
4027 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
4028 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05304029 vos_mem_copy(ProprietaryOperationalRates,
4030 DefaultSupportedPropRates.propRate,
4031 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07004032 }
4033 else
4034 {
4035 // No proprietary modes
4036 ProprietaryOperationalRatesLength = 0;
4037 }
4038 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004039 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
4040 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
4041 {
4042 PropRatesEnable = 1;
4043 }
4044 else
4045 {
4046 PropRatesEnable = 0;
4047 }
4048
4049 // Set the operational rate set CFG variables...
4050 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
4051 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
4052 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
4053 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
4054 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
4055 ProprietaryOperationalRates,
4056 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
4057 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004058}
Jeff Johnson295189b2012-06-20 16:38:30 -07004059void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
4060{
4061 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07004062
Jeff Johnson295189b2012-06-20 16:38:30 -07004063 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
4064 tANI_U32 sessionId;
4065 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004066 if(NULL == pEntry)
4067 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004068 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07004069 return;
4070 }
4071 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
4072 sessionId = pCommand->sessionId;
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05304073 smsLog(pMac, LOG1, FL("CCM CFG return value is %d, "
4074 " current state : %d sub state : %d "),
4075 result, pMac->roam.curState[sessionId],
4076 pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004077 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
4078 {
4079 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
4080 }
4081}
4082
Jeff Johnson295189b2012-06-20 16:38:30 -07004083//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
4084tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
4085{
4086 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
4087 {
4088 return (WNI_CFG_PHY_MODE_11B);
4089 }
4090 else
4091 {
4092 if(eCSR_BAND_24 == band)
4093 return (WNI_CFG_PHY_MODE_11G);
4094 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004095 return (WNI_CFG_PHY_MODE_11A);
4096}
Jeff Johnson295189b2012-06-20 16:38:30 -07004097
Jeff Johnsone7245742012-09-05 17:12:55 -07004098
4099#ifdef WLAN_FEATURE_11AC
4100ePhyChanBondState csrGetHTCBStateFromVHTCBState(ePhyChanBondState aniCBMode)
4101{
4102 switch ( aniCBMode )
4103 {
4104 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
4105 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
4106 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
4107 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
4108 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
4109 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
4110 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
4111 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
4112 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004113 default :
Jeff Johnsone7245742012-09-05 17:12:55 -07004114 return PHY_SINGLE_CHANNEL_CENTERED;
4115 }
4116}
4117#endif
4118
Jeff Johnson295189b2012-06-20 16:38:30 -07004119//pIes may be NULL
4120eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
4121 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304122 tDot11fBeaconIEs *pIes, tANI_BOOLEAN resetCountry)
Jeff Johnson295189b2012-06-20 16:38:30 -07004123{
4124 eHalStatus status = eHAL_STATUS_SUCCESS;
4125 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
4126 tANI_U8 channel = 0;
4127 //Make sure we have the domain info for the BSS we try to connect to.
4128 //Do we need to worry about sequence for OSs that are not Windows??
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304129 if (pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -07004130 {
Chandrasekaran, Manishekar90c49322014-06-24 13:26:14 +05304131 if (csrLearnCountryInformation(pMac, pBssDesc, pIes, eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07004132 {
4133 //Make sure the 11d info from this BSSDesc can be applied
4134 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304135 if (VOS_TRUE == resetCountry)
4136 {
4137 csrApplyCountryInformation(pMac, FALSE);
4138 }
4139 else
4140 {
4141 csrApplyCountryInformation(pMac, TRUE);
4142 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004143 }
Kiran4a17ebe2013-01-31 10:43:43 -08004144 if ((csrIs11dSupported (pMac)) && pIes)
4145 {
4146 if (!pIes->Country.present)
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07004147 {
Kiran4a17ebe2013-01-31 10:43:43 -08004148 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE );
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07004149 }
4150 else
4151 {
4152 //Let's also update the below to make sure we don't update CC while
4153 //connected to an AP which is advertising some CC
Kiet Lamf2f201e2013-11-16 21:24:16 +05304154 vos_mem_copy(pMac->scan.currentCountryBssid,
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07004155 pBssDesc->bssId, sizeof(tSirMacAddr));
4156 }
Kiran4a17ebe2013-01-31 10:43:43 -08004157 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004158 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004159 //Qos
4160 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
4161 //SSID
4162 csrSetCfgSsid(pMac, &pBssConfig->SSID );
4163 //fragment threshold
4164 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
4165 //RTS threshold
4166 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
4167
4168 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004169 //Auth type
4170 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
4171 //encryption type
4172 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
4173 //short slot time
4174 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004175 //11d
4176 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
4177 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
4178 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004179 /*//11h
4180 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
4181 */
4182 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
4183 //CB
Jeff Johnsone7245742012-09-05 17:12:55 -07004184
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07004185 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile) || CSR_IS_IBSS(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004186 {
4187 channel = pProfile->operationChannel;
4188 }
4189 else
4190 {
4191 if(pBssDesc)
4192 {
4193 channel = pBssDesc->channelId;
4194 }
4195 }
4196 if(0 != channel)
4197 {
Sandeep Puligilla60342762014-01-30 21:05:37 +05304198 if(CSR_IS_CHANNEL_24GHZ(channel) &&
4199 !pMac->roam.configParam.channelBondingMode24GHz &&
4200 !WDA_getFwWlanFeatCaps(HT40_OBSS_SCAN))
4201 {//On 2.4 Ghz, CB will be disabled if it is not configured through .ini
Jeff Johnson295189b2012-06-20 16:38:30 -07004202 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Sandeep Puligilla60342762014-01-30 21:05:37 +05304203 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
4204 " cbMode disabled cfgCb = %d channelBondingMode24GHz %d",
4205 __func__, cfgCb, pMac->roam.configParam.channelBondingMode24GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07004206 }
4207 else
4208 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004209 cfgCb = pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004210 }
4211 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004212#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudia0d88932012-11-13 10:51:26 -08004213 // cbMode = 1 in cfg.ini is mapped to PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
4214 // in function csrConvertCBIniValueToPhyCBState()
4215 // So, max value for cbMode in 40MHz mode is 3 (MAC\src\include\sirParams.h)
4216 if(cfgCb > PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
Jeff Johnsone7245742012-09-05 17:12:55 -07004217 {
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004218 if(!WDA_getFwWlanFeatCaps(DOT11AC)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07004219 cfgCb = csrGetHTCBStateFromVHTCBState(cfgCb);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004220 }
Sandeep Puligilla60342762014-01-30 21:05:37 +05304221 else
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004222 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004223 ccmCfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, pMac->roam.configParam.nVhtChannelWidth, NULL, eANI_BOOLEAN_FALSE);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07004224 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004225 }
4226 else
4227#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004228 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
4229 //Rate
4230 //Fixed Rate
4231 if(pBssDesc)
4232 {
4233 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
4234 }
4235 else
4236 {
4237 csrSetCfgRateSetFromProfile(pMac, pProfile);
4238 }
4239 //Make this the last CFG to set. The callback will trigger a join_req
4240 //Join time out
4241 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
4242
4243 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004244 return (status);
4245}
4246
Jeff Johnson295189b2012-06-20 16:38:30 -07004247eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
4248 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
4249{
4250 eHalStatus status;
4251 tBssConfigParam *pBssConfig;
4252 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004253
4254 if(!pSession)
4255 {
4256 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4257 return eHAL_STATUS_FAILURE;
4258 }
4259
Kiet Lam64c1b492013-07-12 13:56:44 +05304260 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
4261 if ( NULL == pBssConfig )
4262 status = eHAL_STATUS_FAILURE;
4263 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004264 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304265 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004266 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
4267 if(HAL_STATUS_SUCCESS(status))
4268 {
4269 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07004270 /* This will allow to pass cbMode during join req */
4271 pSession->bssParams.cbMode= pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004272 //For IBSS, we need to prepare some more information
4273 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004274 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07004275 )
4276 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004277 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07004278 }
4279 // If we are in an IBSS, then stop the IBSS...
4280 ////Not worry about WDS connection for now
4281 if ( csrIsConnStateIbss( pMac, sessionId ) )
4282 {
4283 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
4284 }
4285 else
4286 {
4287 // if we are in an Infrastructure association....
4288 if ( csrIsConnStateInfra( pMac, sessionId ) )
4289 {
4290 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
4291 // across SSIDs (roaming to a new SSID)... //
4292 //Not worry about WDS connection for now
4293 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304294 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004295 {
4296 // then we need to disassociate from the Infrastructure network...
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304297 status = csrRoamIssueDisassociate( pMac, sessionId,
4298 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07004299 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304300 else
4301 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004302 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
4303 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304304 if ( pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -07004305 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304306 // Set parameters for this Bss.
4307 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4308 pBssDesc, pBssConfig,
4309 pIes, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004310 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304311 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004312 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304313 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004314 {
4315 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
4316 // Nothing to stop.
4317 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004318 || CSR_IS_INFRA_AP(pProfile)
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304319 )
4320 {
4321 tANI_BOOLEAN is11rRoamingFlag = eANI_BOOLEAN_FALSE;
4322 is11rRoamingFlag = csrRoamIs11rAssoc(pMac);
4323 // Set parameters for this Bss.
4324 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4325 pBssDesc, pBssConfig,
4326 pIes, is11rRoamingFlag);
4327 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004328 }
4329 }
4330 }//Success getting BSS config info
Kiet Lam64c1b492013-07-12 13:56:44 +05304331 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -07004332 }//Allocate memory
Jeff Johnson295189b2012-06-20 16:38:30 -07004333 return (status);
4334}
4335
Jeff Johnson295189b2012-06-20 16:38:30 -07004336eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
4337 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
4338{
4339 eCsrJoinState eRoamState = eCsrContinueRoaming;
4340 eHalStatus status;
4341 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
4342 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
4343 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004344
4345 if(!pSession)
4346 {
4347 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4348 return (eCsrStopRoaming);
4349 }
4350
Jeff Johnson295189b2012-06-20 16:38:30 -07004351 if( CSR_IS_WDS_STA( pProfile ) )
4352 {
4353 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
4354 if( !HAL_STATUS_SUCCESS( status ) )
4355 {
4356 eRoamState = eCsrStopRoaming;
4357 }
4358 }
4359 else
4360 {
4361 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
4362 {
4363 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
4364 return (eCsrStopRoaming);
4365 }
4366 if ( csrIsInfraBssDesc( pBssDesc ) )
4367 {
4368 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
4369 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
4370 // have changed and handle the changes (without disturbing the current association).
4371
4372 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
4373 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
4374 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
4375 )
4376 {
4377 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
4378 // with Authenticating first. To force this, stop the current association (Disassociate) and
4379 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
4380 // a new Association.
4381 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4382 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07004383 smsLog(pMac, LOGW, FL(" detect same profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004384 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
4385 {
4386 eRoamState = eCsrReassocToSelfNoCapChange;
4387 }
4388 else
4389 {
4390 tBssConfigParam bssConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004391 //The key changes
Kiet Lam64c1b492013-07-12 13:56:44 +05304392 vos_mem_set(&bssConfig, sizeof(bssConfig), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004393 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
4394 if(HAL_STATUS_SUCCESS(status))
4395 {
4396 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07004397 pSession->bssParams.cbMode = bssConfig.cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004398 //Reapply the config including Keys so reassoc is happening.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304399 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4400 pBssDesc, &bssConfig,
4401 pIesLocal, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004402 if(!HAL_STATUS_SUCCESS(status))
4403 {
4404 eRoamState = eCsrStopRoaming;
4405 }
4406 }
4407 else
4408 {
4409 eRoamState = eCsrStopRoaming;
4410 }
4411 }//same profile
4412 }
4413 else
4414 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304415 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004416 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
4417 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05304418 smsLog(pMac, LOGE, FL(" fail to issue disassociate with Session ID %d"),
4419 sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004420 eRoamState = eCsrStopRoaming;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304421 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004422 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304423 }
4424 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004425 {
4426 // 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 -07004427 // stop the existing network before attempting to join the new network...
4428 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4429 {
4430 eRoamState = eCsrStopRoaming;
4431 }
4432 }
4433 }//Infra
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304434 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004435 {
4436 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4437 {
4438 eRoamState = eCsrStopRoaming;
4439 }
4440 }
4441 if( pIesLocal && !pScanResult->pvIes )
4442 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304443 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004444 }
4445 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004446 return( eRoamState );
4447}
4448
Jeff Johnson295189b2012-06-20 16:38:30 -07004449eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
4450 tSirBssDescription *pBssDesc, tANI_U32 roamId)
4451{
4452 eHalStatus status = eHAL_STATUS_SUCCESS;
4453 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05304454 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004455 roamInfo.pBssDesc = pBssDesc;
4456 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
4457 return (status);
4458}
Jeff Johnson295189b2012-06-20 16:38:30 -07004459//In case no matching BSS is found, use whatever default we can find
4460static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4461{
4462 //Need to get all negotiated types in place first
4463 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08004464 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07004465 {
4466 default:
4467 case eCSR_AUTH_TYPE_WPA:
4468 case eCSR_AUTH_TYPE_WPA_PSK:
4469 case eCSR_AUTH_TYPE_WPA_NONE:
4470 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4471 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4472 break;
4473
4474 case eCSR_AUTH_TYPE_SHARED_KEY:
4475 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
4476 break;
4477
4478 case eCSR_AUTH_TYPE_AUTOSWITCH:
4479 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
4480 break;
4481 }
4482 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4483 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4484 //In this case, the multicast encryption needs to follow the uncast ones.
4485 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4486 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4487}
4488
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004489
4490static void csrSetAbortRoamingCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4491{
4492 switch(pCommand->u.roamCmd.roamReason)
4493 {
4494 case eCsrLostLink1:
4495 pCommand->u.roamCmd.roamReason = eCsrLostLink1Abort;
4496 break;
4497 case eCsrLostLink2:
4498 pCommand->u.roamCmd.roamReason = eCsrLostLink2Abort;
4499 break;
4500 case eCsrLostLink3:
4501 pCommand->u.roamCmd.roamReason = eCsrLostLink3Abort;
4502 break;
4503 default:
4504 smsLog(pMac, LOGE, FL(" aborting roaming reason %d not recognized"),
4505 pCommand->u.roamCmd.roamReason);
4506 break;
4507 }
4508}
4509
Jeff Johnson295189b2012-06-20 16:38:30 -07004510static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
4511{
4512 eHalStatus status;
4513 tCsrScanResult *pScanResult = NULL;
4514 eCsrJoinState eRoamState = eCsrStopRoaming;
4515 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
4516 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
4517 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
4518#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4519 v_U8_t acm_mask = 0;
4520#endif
4521 tANI_U32 sessionId = pCommand->sessionId;
4522 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4523 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4524 tANI_U8 concurrentChannel = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004525
4526 if(!pSession)
4527 {
4528 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4529 return (eCsrStopRoaming);
4530 }
4531
Jeff Johnson295189b2012-06-20 16:38:30 -07004532 do
4533 {
4534 // Check for Cardbus eject condition, before trying to Roam to any BSS
4535 //***if( !balIsCardPresent(pAdapter) ) break;
4536
Kiet Lam64c1b492013-07-12 13:56:44 +05304537 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Rajesh Babu Prathipati20cdffa2014-07-01 22:24:59 +05304538 vos_mem_copy (&roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004539 if(NULL != pBSSList)
4540 {
4541 // When handling AP's capability change, continue to associate to
4542 // same BSS and make sure pRoamBssEntry is not Null.
4543 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
4544 {
4545 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
4546 {
4547 //Try the first BSS
4548 pCommand->u.roamCmd.pLastRoamBss = NULL;
4549 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
4550 }
4551 else
4552 {
4553 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4554 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4555 {
4556 //Done with all the BSSs
4557 //In this case, will tell HDD the completion
4558 break;
4559 }
4560 else
4561 {
4562 //We need to indicate to HDD that we are done with this one.
Kiet Lam64c1b492013-07-12 13:56:44 +05304563 //vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004564 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
4565 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4566 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4567 pRoamInfo = &roamInfo;
4568 }
4569 }
4570 while(pCommand->u.roamCmd.pRoamBssEntry)
4571 {
4572 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Jeff Johnson295189b2012-06-20 16:38:30 -07004573 /*If concurrency enabled take the concurrent connected channel first. */
4574 /* Valid multichannel concurrent sessions exempted */
Agarwal Ashish5974ed32014-06-16 16:59:54 +05304575 if (vos_concurrent_open_sessions_running() &&
4576 !csrIsValidMcConcurrentSession(pMac, sessionId,
4577 &pScanResult->Result.BssDescriptor))
Jeff Johnson295189b2012-06-20 16:38:30 -07004578 {
4579 concurrentChannel =
4580 csrGetConcurrentOperationChannel(pMac);
4581 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004582 " csr Concurrent Channel = %d", __func__, concurrentChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07004583 if ((concurrentChannel) &&
4584 (concurrentChannel ==
4585 pScanResult->Result.BssDescriptor.channelId))
4586 {
4587 //make this 0 because we do not want the
4588 //below check to pass as we don't want to
4589 //connect on other channel
4590 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4591 FL("Concurrent channel match =%d"),
4592 concurrentChannel);
4593 concurrentChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004594 }
4595 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004596
4597 if (!concurrentChannel)
4598 {
4599
4600 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
4601 sessionId, &pScanResult->Result.BssDescriptor,
4602 pCommand->u.roamCmd.roamId)))
4603 {
4604 //Ok to roam this
4605 break;
4606 }
4607 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004608 else
4609 {
4610 eRoamState = eCsrStopRoamingDueToConcurrency;
4611 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004612 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4613 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4614 {
4615 //Done with all the BSSs
4616 fDone = eANI_BOOLEAN_TRUE;
4617 break;
4618 }
4619 }
4620 if(fDone)
4621 {
4622 break;
4623 }
4624 }
4625 }
4626 //We have something to roam, tell HDD when it is infra.
4627 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
4628 //For WDS, the indication is eCSR_ROAM_WDS_IND
4629 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4630 {
4631 if(pRoamInfo)
4632 {
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004633 if(pSession->bRefAssocStartCnt)
4634 {
4635 pSession->bRefAssocStartCnt--;
4636 //Complete the last association attemp because a new one is about to be tried
4637 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4638 eCSR_ROAM_ASSOCIATION_COMPLETION,
Jeff Johnson295189b2012-06-20 16:38:30 -07004639 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004640 }
4641 }
4642 /* If the roaming has stopped, not to continue the roaming command*/
4643 if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
4644 {
4645 //No need to complete roaming here as it already completes
4646 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed"),
4647 pCommand->u.roamCmd.roamReason);
4648 eRoamState = eCsrStopRoaming;
4649 csrSetAbortRoamingCommand(pMac, pCommand);
4650 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004651 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304652 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004653 if(pScanResult)
4654 {
4655 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07004656 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
4657 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004658 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004659 fDone = eANI_BOOLEAN_TRUE;
4660 eRoamState = eCsrStopRoaming;
4661 break;
4662 }
4663 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
4664 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
4665 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
4666 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
4667 CSR_IS_QOS_BSS(pIesLocal) &&
4668 CSR_IS_UAPSD_BSS(pIesLocal) )
4669 {
4670#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Jeff Johnson295189b2012-06-20 16:38:30 -07004671 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
4672 pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004673#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004674 }
4675 else
4676 {
4677 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4678 }
4679 if( pIesLocal && !pScanResult->Result.pvIes)
4680 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304681 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004682 }
4683 }
4684 else
4685 {
4686 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4687 }
4688 roamInfo.pProfile = pProfile;
4689 pSession->bRefAssocStartCnt++;
4690 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4691 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4692 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004693 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
4694 {
4695 // If this is a start IBSS profile, then we need to start the IBSS.
4696 if ( CSR_IS_START_IBSS(pProfile) )
4697 {
4698 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004699 // Attempt to start this IBSS...
4700 csrRoamAssignDefaultParam( pMac, pCommand );
4701 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
4702 if(HAL_STATUS_SUCCESS(status))
4703 {
4704 if ( fSameIbss )
4705 {
4706 eRoamState = eCsrStartIbssSameIbss;
4707 }
4708 else
4709 {
4710 eRoamState = eCsrContinueRoaming;
4711 }
4712 }
4713 else
4714 {
4715 //it somehow fail need to stop
4716 eRoamState = eCsrStopRoaming;
4717 }
4718 break;
4719 }
4720 else if ( (CSR_IS_WDS_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004721 || (CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004722 )
4723 {
4724 // Attempt to start this WDS...
4725 csrRoamAssignDefaultParam( pMac, pCommand );
4726 /* For AP WDS, we dont have any BSSDescription */
4727 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
4728 if(HAL_STATUS_SUCCESS(status))
4729 {
4730 eRoamState = eCsrContinueRoaming;
4731 }
4732 else
4733 {
4734 //it somehow fail need to stop
4735 eRoamState = eCsrStopRoaming;
4736 }
4737 }
4738 else
4739 {
4740 //Nothing we can do
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004741 smsLog(pMac, LOGW, FL("cannot continue without BSS list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004742 eRoamState = eCsrStopRoaming;
4743 break;
4744 }
4745 }
4746 else //We have BSS
4747 {
4748 //Need to assign these value because they are used in csrIsSameProfile
4749 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Leela Venkata Kiran Kumar Reddy Chirala909b8812014-05-16 22:09:05 -07004750 /* The OSEN IE doesn't provide the cipher suite.
4751 * Therefore set to constant value of AES */
4752 if(pCommand->u.roamCmd.roamProfile.bOSENAssociation)
4753 {
4754 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4755 eCSR_ENCRYPT_TYPE_AES;
4756 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4757 eCSR_ENCRYPT_TYPE_AES;
4758 }
4759 else
4760 {
4761 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4762 pScanResult->ucEncryptionType; //Negotiated while building scan result.
4763 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4764 pScanResult->mcEncryptionType;
4765 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004766 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
4767 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
4768 {
4769 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4770 {
4771 eRoamState = eCsrStartIbssSameIbss;
4772 break;
4773 }
4774 }
4775 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
4776 {
4777 //trying to connect to the one already connected
4778 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
4779 eRoamState = eCsrReassocToSelfNoCapChange;
4780 break;
4781 }
4782 // Attempt to Join this Bss...
4783 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
4784 break;
4785 }
4786
4787 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004788 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
4789 {
4790 //Need to indicate association_completion if association_start has been done
4791 if(pSession->bRefAssocStartCnt > 0)
4792 {
4793 pSession->bRefAssocStartCnt--;
4794 //Complete the last association attemp because a new one is about to be tried
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004795 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07004796 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4797 eCSR_ROAM_ASSOCIATION_COMPLETION,
4798 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4799 }
4800 }
4801
4802 return( eRoamState );
4803}
4804
Jeff Johnson295189b2012-06-20 16:38:30 -07004805static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4806{
4807 eHalStatus status = eHAL_STATUS_SUCCESS;
4808 eCsrJoinState RoamState;
4809 tANI_U32 sessionId = pCommand->sessionId;
4810
Jeff Johnson295189b2012-06-20 16:38:30 -07004811 //***if( hddIsRadioStateOn( pAdapter ) )
4812 {
4813 // Attept to join a Bss...
4814 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07004815
Jeff Johnson295189b2012-06-20 16:38:30 -07004816 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07004817 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004818 {
4819 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004820 // and if connected in Infrastructure mode...
4821 if ( csrIsConnStateInfra(pMac, sessionId) )
4822 {
4823 //... then we need to issue a disassociation
4824 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
4825 if(!HAL_STATUS_SUCCESS(status))
4826 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004827 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004828 //roam command is completed by caller in the failed case
4829 fComplete = eANI_BOOLEAN_TRUE;
4830 }
4831 }
4832 else if( csrIsConnStateIbss(pMac, sessionId) )
4833 {
4834 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4835 if(!HAL_STATUS_SUCCESS(status))
4836 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004837 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004838 //roam command is completed by caller in the failed case
4839 fComplete = eANI_BOOLEAN_TRUE;
4840 }
4841 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004842 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
4843 {
4844 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4845 if(!HAL_STATUS_SUCCESS(status))
4846 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004847 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004848 //roam command is completed by caller in the failed case
4849 fComplete = eANI_BOOLEAN_TRUE;
4850 }
4851 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004852 else
4853 {
4854 fComplete = eANI_BOOLEAN_TRUE;
4855 }
4856 if(fComplete)
4857 {
4858 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07004859 if(eCsrStopRoamingDueToConcurrency == RoamState)
4860 {
4861 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
4862 }
4863 else
4864 {
4865 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
4866 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004867 }
4868 }
4869 else if ( eCsrReassocToSelfNoCapChange == RoamState )
4870 {
4871 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
4872 }
4873 else if ( eCsrStartIbssSameIbss == RoamState )
4874 {
4875 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
4876 }
4877 }//hddIsRadioStateOn
4878
4879 return status;
4880}
Jeff Johnson295189b2012-06-20 16:38:30 -07004881eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4882{
4883 tANI_U32 sessionId;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05304884 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004885 tCsrScanResult *pScanResult = NULL;
4886 tSirBssDescription *pBssDesc = NULL;
4887 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004888 sessionId = pCommand->sessionId;
4889 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004890
4891 if(!pSession)
4892 {
4893 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4894 return eHAL_STATUS_FAILURE;
4895 }
4896
Jeff Johnson295189b2012-06-20 16:38:30 -07004897 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
4898 {
4899 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004900 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004901 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4902 return eHAL_STATUS_FAILURE;
4903 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004904 if (pCommand->u.roamCmd.pRoamBssEntry)
4905 {
4906 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4907 pBssDesc = &pScanResult->Result.BssDescriptor;
4908 }
4909 else
4910 {
4911 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004912 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004913 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4914 return eHAL_STATUS_FAILURE;
4915 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004916 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
4917 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
4918 return status;
4919}
4920
Jeff Johnson295189b2012-06-20 16:38:30 -07004921eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4922{
4923 eHalStatus status = eHAL_STATUS_SUCCESS;
4924 tCsrRoamInfo roamInfo;
4925 tANI_U32 sessionId = pCommand->sessionId;
4926 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004927
4928 if(!pSession)
4929 {
4930 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4931 return eHAL_STATUS_FAILURE;
4932 }
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05304933 smsLog(pMac, LOG1, FL("Roam Reason : %d, sessionId: %d"),
4934 pCommand->u.roamCmd.roamReason, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004935 switch ( pCommand->u.roamCmd.roamReason )
4936 {
4937 case eCsrForcedDisassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07004938 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004939 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004940 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004941 case eCsrSmeIssuedDisassocForHandoff:
4942 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
4943#if 0 // TODO : Confirm this change
4944 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
4945#else
4946 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4947#endif
4948
4949 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004950 case eCsrForcedDisassocMICFailure:
Jeff Johnson295189b2012-06-20 16:38:30 -07004951 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004952 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004953 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004954 case eCsrForcedDeauth:
Jeff Johnson295189b2012-06-20 16:38:30 -07004955 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004956 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004957 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004958 case eCsrHddIssuedReassocToSameAP:
4959 case eCsrSmeIssuedReassocToSameAP:
4960 {
4961 tDot11fBeaconIEs *pIes = NULL;
4962
Jeff Johnson295189b2012-06-20 16:38:30 -07004963 if( pSession->pConnectBssDesc )
4964 {
4965 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
4966 if(!HAL_STATUS_SUCCESS(status) )
4967 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004968 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004969 }
4970 else
4971 {
4972 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
4973 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
4974 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07004975 roamInfo.pBssDesc = pSession->pConnectBssDesc;
4976 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
4977 pSession->bRefAssocStartCnt++;
4978 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4979 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4980
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004981 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004982 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
4983 &pCommand->u.roamCmd.roamProfile );
4984 if(!HAL_STATUS_SUCCESS(status))
4985 {
4986 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08004987 csrReleaseCommandRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004988 }
4989
Kiet Lam64c1b492013-07-12 13:56:44 +05304990 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07004991 pIes = NULL;
4992 }
4993 }
Padma, Santhosh Kumar3d8d5762014-07-22 14:52:23 +05304994 else
4995 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004996 break;
4997 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004998 case eCsrCapsChange:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004999 smsLog(pMac, LOGE, FL("received eCsrCapsChange "));
Jeff Johnson295189b2012-06-20 16:38:30 -07005000 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
5001 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
5002 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005003 case eCsrSmeIssuedFTReassoc:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005004 smsLog(pMac, LOG1, FL("received FT Reassoc Req "));
Jeff Johnson295189b2012-06-20 16:38:30 -07005005 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
5006 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07005007
Jeff Johnson295189b2012-06-20 16:38:30 -07005008 case eCsrStopBss:
5009 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
5010 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
5011 break;
5012
5013 case eCsrForcedDisassocSta:
5014 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
5015 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
5016 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
5017 pCommand->u.roamCmd.reason);
5018 break;
5019
5020 case eCsrForcedDeauthSta:
5021 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
5022 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
5023 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
5024 pCommand->u.roamCmd.reason);
5025 break;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005026
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07005027 case eCsrPerformPreauth:
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08005028 smsLog(pMac, LOG1, FL("Attempting FT PreAuth Req"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07005029 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
5030 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005031 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005032
5033 default:
5034 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
5035
5036 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
5037 {
5038 //Remember the roaming profile
5039 csrFreeRoamProfile(pMac, sessionId);
Kiet Lam64c1b492013-07-12 13:56:44 +05305040 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
5041 if ( NULL != pSession->pCurRoamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07005042 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305043 vos_mem_set(pSession->pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005044 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
5045 }
5046 }
5047
5048 //At this point, original uapsd_mask is saved in pCurRoamProfile
5049 //uapsd_mask in the pCommand may change from this point on.
5050
5051 // Attempt to roam with the new scan results (if we need to..)
5052 status = csrRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005053 if(!HAL_STATUS_SUCCESS(status))
5054 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005055 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X"), status);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005056 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005057 break;
5058 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005059 return (status);
5060}
5061
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07005062void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
5063{
5064 pCommand->u.roamCmd.pLastRoamBss = NULL;
5065 pCommand->u.roamCmd.pRoamBssEntry = NULL;
5066 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05305067 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07005068}
5069
Jeff Johnson295189b2012-06-20 16:38:30 -07005070void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
5071{
5072 if(pCommand->u.roamCmd.fReleaseBssList)
5073 {
5074 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
5075 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
5076 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
5077 }
5078 if(pCommand->u.roamCmd.fReleaseProfile)
5079 {
5080 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
5081 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
5082 }
5083 pCommand->u.roamCmd.pRoamBssEntry = NULL;
5084 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05305085 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005086}
5087
Jeff Johnson295189b2012-06-20 16:38:30 -07005088void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
5089{
Kiet Lam64c1b492013-07-12 13:56:44 +05305090 vos_mem_set(&pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005091}
Jeff Johnson295189b2012-06-20 16:38:30 -07005092void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
5093{
5094 tListElem *pEntry;
5095 tSmeCmd *pCommand;
5096 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005097 smsLog( pMac, LOG2, "Roam Completion ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07005098 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
5099 if ( pEntry )
5100 {
5101 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07005102 // If the head of the queue is Active and it is a ROAM command, remove
5103 // and put this on the Free queue.
5104 if ( eSmeCommandRoam == pCommand->command )
5105 {
5106 //we need to process the result first before removing it from active list because state changes
5107 //still happening insides roamQProcessRoamResults so no other roam command should be issued
5108 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
5109 if( fReleaseCommand )
5110 {
5111 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
5112 {
5113 csrReleaseCommandRoam( pMac, pCommand );
5114 }
5115 else
5116 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005117 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005118 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07005119 }
5120 }
5121 else
5122 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005123 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08005124 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07005125 }
5126 }
5127 else
5128 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005129 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07005130 }
5131 }
5132 else
5133 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005134 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07005135 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005136 if( fReleaseCommand )
5137 {
5138 smeProcessPendingQueue( pMac );
5139 }
5140}
5141
Jeff Johnson295189b2012-06-20 16:38:30 -07005142void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
5143{
5144 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07005145 if(!pSession)
5146 {
5147 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5148 return;
5149 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305150 vos_mem_set(&(pSession->PmkidCandidateInfo[0]),
5151 sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005152 pSession->NumPmkidCandidate = 0;
5153}
Jeff Johnson295189b2012-06-20 16:38:30 -07005154#ifdef FEATURE_WLAN_WAPI
5155void csrResetBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
5156{
5157 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07005158 if(!pSession)
5159 {
5160 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5161 return;
5162 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305163 vos_mem_set(&(pSession->BkidCandidateInfo[0]),
5164 sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005165 pSession->NumBkidCandidate = 0;
5166}
5167#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07005168extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
5169
Jeff Johnson295189b2012-06-20 16:38:30 -07005170static eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrAuthType authType,
5171 tSirBssDescription *pSirBssDesc,
5172 tDot11fBeaconIEs *pIes)
5173{
5174 eHalStatus status = eHAL_STATUS_SUCCESS;
5175 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5176 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07005177
5178 if(!pSession)
5179 {
5180 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5181 return eHAL_STATUS_FAILURE;
5182 }
5183
Jeff Johnson295189b2012-06-20 16:38:30 -07005184 if((eCSR_AUTH_TYPE_WPA == authType) ||
5185 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
5186 (eCSR_AUTH_TYPE_RSN == authType) ||
5187 (eCSR_AUTH_TYPE_RSN_PSK == authType)
5188#if defined WLAN_FEATURE_VOWIFI_11R
5189 ||
5190 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
5191 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
5192#endif /* FEATURE_WLAN_WAPI */
5193#ifdef FEATURE_WLAN_WAPI
5194 ||
5195 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
5196 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
5197#endif /* FEATURE_WLAN_WAPI */
Chet Lanctot186b5732013-03-18 10:26:30 -07005198#ifdef WLAN_FEATURE_11W
5199 ||
Abhishek Singhae408032014-09-25 17:22:04 +05305200 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
5201 (eCSR_AUTH_TYPE_RSN_8021X_SHA256 == authType)
Chet Lanctot186b5732013-03-18 10:26:30 -07005202#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07005203 )
5204 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005205 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
5206 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005207 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005208 }
5209 if( pIesLocal )
5210 {
5211 tANI_U32 nIeLen;
5212 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07005213 if((eCSR_AUTH_TYPE_RSN == authType) ||
5214#if defined WLAN_FEATURE_VOWIFI_11R
5215 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
5216 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
5217#endif /* WLAN_FEATURE_VOWIFI_11R */
Chet Lanctot186b5732013-03-18 10:26:30 -07005218#if defined WLAN_FEATURE_11W
5219 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
Abhishek Singhae408032014-09-25 17:22:04 +05305220 (eCSR_AUTH_TYPE_RSN_8021X_SHA256 == authType) ||
Chet Lanctot186b5732013-03-18 10:26:30 -07005221#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005222 (eCSR_AUTH_TYPE_RSN_PSK == authType))
5223 {
5224 if(pIesLocal->RSN.present)
5225 {
5226 //Calculate the actual length
5227 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
5228 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
5229 + 2 //akm_suite_count
5230 + pIesLocal->RSN.akm_suite_count * 4 //akm_suites
5231 + 2; //reserved
5232 if( pIesLocal->RSN.pmkid_count )
5233 {
5234 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
5235 }
5236 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305237 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
5238 if (NULL == pSession->pWpaRsnRspIE)
5239 status = eHAL_STATUS_FAILURE;
5240 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005241 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305242 vos_mem_set(pSession->pWpaRsnRspIE, nIeLen + 2, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005243 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
5244 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
5245 //copy upto akm_suites
5246 pIeBuf = pSession->pWpaRsnRspIE + 2;
Kiet Lam64c1b492013-07-12 13:56:44 +05305247 vos_mem_copy(pIeBuf, &pIesLocal->RSN.version,
5248 sizeof(pIesLocal->RSN.version));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07005249 pIeBuf += sizeof(pIesLocal->RSN.version);
Kiet Lam64c1b492013-07-12 13:56:44 +05305250 vos_mem_copy(pIeBuf, &pIesLocal->RSN.gp_cipher_suite,
5251 sizeof(pIesLocal->RSN.gp_cipher_suite));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07005252 pIeBuf += sizeof(pIesLocal->RSN.gp_cipher_suite);
Kiet Lam64c1b492013-07-12 13:56:44 +05305253 vos_mem_copy(pIeBuf, &pIesLocal->RSN.pwise_cipher_suite_count,
5254 sizeof(pIesLocal->RSN.pwise_cipher_suite_count));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07005255 pIeBuf += sizeof(pIesLocal->RSN.pwise_cipher_suite_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07005256 if( pIesLocal->RSN.pwise_cipher_suite_count )
5257 {
5258 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305259 vos_mem_copy(pIeBuf,
5260 pIesLocal->RSN.pwise_cipher_suites,
5261 pIesLocal->RSN.pwise_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005262 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
5263 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305264 vos_mem_copy(pIeBuf, &pIesLocal->RSN.akm_suite_count, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005265 pIeBuf += 2;
5266 if( pIesLocal->RSN.akm_suite_count )
5267 {
5268 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305269 vos_mem_copy(pIeBuf,
5270 pIesLocal->RSN.akm_suites,
5271 pIesLocal->RSN.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005272 pIeBuf += pIesLocal->RSN.akm_suite_count * 4;
5273 }
5274 //copy the rest
Kiet Lam64c1b492013-07-12 13:56:44 +05305275 vos_mem_copy(pIeBuf,
5276 pIesLocal->RSN.akm_suites + pIesLocal->RSN.akm_suite_count * 4,
5277 2 + pIesLocal->RSN.pmkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005278 pSession->nWpaRsnRspIeLength = nIeLen + 2;
5279 }
5280 }
5281 }
5282 else if((eCSR_AUTH_TYPE_WPA == authType) ||
5283 (eCSR_AUTH_TYPE_WPA_PSK == authType))
5284 {
5285 if(pIesLocal->WPA.present)
5286 {
5287 //Calculate the actual length
5288 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
5289 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
5290 + 2 //auth_suite_count
5291 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
5292 // The WPA capabilities follows the Auth Suite (two octects)--
5293 // this field is optional, and we always "send" zero, so just
5294 // remove it. This is consistent with our assumptions in the
5295 // frames compiler; c.f. bug 15234:
5296 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305297
5298 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
5299 if ( NULL == pSession->pWpaRsnRspIE )
5300 status = eHAL_STATUS_FAILURE;
5301 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005302 {
5303 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
5304 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
5305 pIeBuf = pSession->pWpaRsnRspIE + 2;
5306 //Copy WPA OUI
Kiet Lam64c1b492013-07-12 13:56:44 +05305307 vos_mem_copy(pIeBuf, &csrWpaOui[1], 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005308 pIeBuf += 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305309 vos_mem_copy(pIeBuf, &pIesLocal->WPA.version,
5310 8 + pIesLocal->WPA.unicast_cipher_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005311 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305312 vos_mem_copy(pIeBuf, &pIesLocal->WPA.auth_suite_count,
5313 2 + pIesLocal->WPA.auth_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005314 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
5315 pSession->nWpaRsnRspIeLength = nIeLen + 2;
5316 }
5317 }
5318 }
5319#ifdef FEATURE_WLAN_WAPI
5320 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
5321 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
5322 {
5323 if(pIesLocal->WAPI.present)
5324 {
5325 //Calculate the actual length
5326 nIeLen = 4 //version + akm_suite_count
5327 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
5328 + 2 //pwise_cipher_suite_count
5329 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
5330 + 6; //gp_cipher_suite + preauth + reserved
5331 if( pIesLocal->WAPI.bkid_count )
5332 {
5333 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
5334 }
5335
5336 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305337 pSession->pWapiRspIE = vos_mem_malloc(nIeLen + 2);
5338 if ( NULL == pSession->pWapiRspIE )
5339 status = eHAL_STATUS_FAILURE;
5340 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005341 {
5342 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
5343 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
5344 pIeBuf = pSession->pWapiRspIE + 2;
5345 //copy upto akm_suite_count
Kiet Lam64c1b492013-07-12 13:56:44 +05305346 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.version, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005347 pIeBuf += 4;
5348 if( pIesLocal->WAPI.akm_suite_count )
5349 {
5350 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305351 vos_mem_copy(pIeBuf, pIesLocal->WAPI.akm_suites,
5352 pIesLocal->WAPI.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005353 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305354 }
5355 vos_mem_copy(pIeBuf,
5356 &pIesLocal->WAPI.unicast_cipher_suite_count,
5357 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005358 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005359 if( pIesLocal->WAPI.unicast_cipher_suite_count )
5360 {
5361 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305362 vos_mem_copy( pIeBuf,
5363 pIesLocal->WAPI.unicast_cipher_suites,
5364 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005365 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
5366 }
lukez3c809222013-05-03 10:23:02 -07005367 //gp_cipher_suite
Kiet Lam64c1b492013-07-12 13:56:44 +05305368 vos_mem_copy(pIeBuf,
5369 pIesLocal->WAPI.multicast_cipher_suite,
5370 4);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005371 pIeBuf += 4;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305372 //preauth + reserved
Kiet Lam64c1b492013-07-12 13:56:44 +05305373 vos_mem_copy(pIeBuf,
5374 pIesLocal->WAPI.multicast_cipher_suite + 4,
5375 2);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005376 pIeBuf += 2;
Sushant Kaushik58d321d2014-12-29 16:10:54 +05305377 if ( pIesLocal->WAPI.bkid_count )
Jeff Johnson295189b2012-06-20 16:38:30 -07005378 {
Sushant Kaushik58d321d2014-12-29 16:10:54 +05305379 //bkid_count
5380 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.bkid_count, 2);
5381 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005382 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305383 vos_mem_copy(pIeBuf, pIesLocal->WAPI.bkid,
5384 pIesLocal->WAPI.bkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005385 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
5386 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305387 pSession->nWapiRspIeLength = nIeLen + 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005388 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005389 }
5390 }
5391#endif /* FEATURE_WLAN_WAPI */
5392 if( !pIes )
5393 {
5394 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05305395 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07005396 }
5397 }
5398 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005399 return (status);
5400}
5401
Jeff Johnson295189b2012-06-20 16:38:30 -07005402static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
5403{
5404 v_U8_t bACWeights[WLANTL_MAX_AC];
5405 v_U8_t paramBk, paramBe, paramVi, paramVo;
5406 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005407 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
5408 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
5409 //of the higher AC one, make the higher AC has the same weight as the lower AC.
5410 //This doesn't address the case where the lower AC needs a real higher weight
5411 if( pIEs->WMMParams.present )
5412 {
5413 //no change to the lowest ones
5414 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
5415 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
5416 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
5417 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
5418 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
5419 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
5420 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
5421 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
5422 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
5423 {
5424 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
5425 fWeightChange = VOS_TRUE;
5426 }
5427 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
5428 {
5429 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
5430 fWeightChange = VOS_TRUE;
5431 }
5432 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
5433 {
5434 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
5435 fWeightChange = VOS_TRUE;
5436 }
5437 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
5438 {
5439 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
5440 fWeightChange = VOS_TRUE;
5441 }
5442 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
5443 {
5444 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
5445 fWeightChange = VOS_TRUE;
5446 }
5447 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
5448 {
5449 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
5450 fWeightChange = VOS_TRUE;
5451 }
5452 if(fWeightChange)
5453 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005454 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)"), bACWeights[0], bACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07005455 bACWeights[2], bACWeights[3]);
5456 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
5457 }
5458 }
5459}
Jeff Johnson295189b2012-06-20 16:38:30 -07005460#ifdef WLAN_FEATURE_VOWIFI_11R
5461//Returns whether the current association is a 11r assoc or not
5462tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
5463{
5464#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5465 return csrNeighborRoamIs11rAssoc(pMac);
5466#else
5467 return eANI_BOOLEAN_FALSE;
5468#endif
5469}
5470#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005471#ifdef FEATURE_WLAN_ESE
5472//Returns whether the current association is a ESE assoc or not
5473tANI_BOOLEAN csrRoamIsESEAssoc(tpAniSirGlobal pMac)
Jeff Johnson295189b2012-06-20 16:38:30 -07005474{
5475#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005476 return csrNeighborRoamIsESEAssoc(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07005477#else
5478 return eANI_BOOLEAN_FALSE;
5479#endif
5480}
5481#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005482#ifdef FEATURE_WLAN_LFR
5483//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305484tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005485{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305486 tCsrRoamSession *pSession = NULL;
5487
5488 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
5489 {
5490 pSession = CSR_GET_SESSION( pMac, sessionId );
5491 if (NULL != pSession->pCurRoamProfile)
5492 {
5493 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
5494 {
5495 return eANI_BOOLEAN_FALSE;
5496 }
5497 }
5498 }
5499
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005500#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5501 if (eANI_BOOLEAN_TRUE == CSR_IS_FASTROAM_IN_CONCURRENCY_INI_FEATURE_ENABLED(pMac))
5502 {
5503 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled);
5504 }
5505 else
5506#endif
5507 {
5508 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07005509 (!csrIsConcurrentSessionRunning(pMac)));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005510 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005511}
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005512
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005513#ifdef FEATURE_WLAN_ESE
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005514/* ---------------------------------------------------------------------------
5515
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005516 \fn csrNeighborRoamIsESEAssoc
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005517
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005518 \brief This function returns whether the current association is a ESE assoc or not
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005519
5520 \param pMac - The handle returned by macOpen.
5521
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005522 \return eANI_BOOLEAN_TRUE if current assoc is ESE, eANI_BOOLEAN_FALSE otherwise
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005523
5524---------------------------------------------------------------------------*/
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005525tANI_BOOLEAN csrNeighborRoamIsESEAssoc(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005526{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005527 return pMac->roam.neighborRoamInfo.isESEAssoc;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005528}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005529#endif /* FEATURE_WLAN_ESE */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005530
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005531#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5532//Returns whether "FW based BG scan" is currently enabled...or not
5533tANI_BOOLEAN csrRoamIsRoamOffloadScanEnabled(tpAniSirGlobal pMac)
5534{
5535 return (pMac->roam.configParam.isRoamOffloadScanEnabled);
5536}
5537#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005538#endif
5539
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005540#if defined(FEATURE_WLAN_ESE)
5541tANI_BOOLEAN csrRoamIsEseIniFeatureEnabled(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005542{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005543 return pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005544}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005545#endif /*FEATURE_WLAN_ESE*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005546
Jeff Johnson295189b2012-06-20 16:38:30 -07005547//Return true means the command can be release, else not
5548static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
5549 eCsrRoamCompleteResult Result, void *Context )
5550{
5551 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
5552 tSirBssDescription *pSirBssDesc = NULL;
5553 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
5554 tCsrScanResult *pScanResult = NULL;
5555 tCsrRoamInfo roamInfo;
5556 sme_QosAssocInfo assocInfo;
5557 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
5558 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
5559 tDot11fBeaconIEs *pIes = NULL;
5560 tANI_U32 sessionId = pCommand->sessionId;
5561 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5562 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
5563 eRoamCmdStatus roamStatus;
5564 eCsrRoamResult roamResult;
5565 eHalStatus status;
5566 tANI_U32 key_timeout_interval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005567 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005568
Jeff Johnson32d95a32012-09-10 13:15:23 -07005569 if(!pSession)
5570 {
5571 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5572 return eANI_BOOLEAN_FALSE;
5573 }
5574
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005575 smsLog( pMac, LOG1, FL("Processing ROAM results..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07005576 switch( Result )
5577 {
5578 case eCsrJoinSuccess:
5579 // reset the IDLE timer
5580 // !!
5581 // !! fall through to the next CASE statement here is intentional !!
5582 // !!
5583 case eCsrReassocSuccess:
5584 if(eCsrReassocSuccess == Result)
5585 {
5586 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
5587 }
5588 else
5589 {
5590 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
5591 }
5592 // Success Join Response from LIM. Tell NDIS we are connected and save the
5593 // Connected state...
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005594 smsLog(pMac, LOGW, FL("receives association indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305595 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005596 //always free the memory here
5597 if(pSession->pWpaRsnRspIE)
5598 {
5599 pSession->nWpaRsnRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305600 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005601 pSession->pWpaRsnRspIE = NULL;
5602 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005603#ifdef FEATURE_WLAN_WAPI
5604 if(pSession->pWapiRspIE)
5605 {
5606 pSession->nWapiRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305607 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005608 pSession->pWapiRspIE = NULL;
5609 }
5610#endif /* FEATURE_WLAN_WAPI */
5611#ifdef FEATURE_WLAN_BTAMP_UT_RF
5612 //Reset counter so no join retry is needed.
5613 pSession->maxRetryCount = 0;
5614 csrRoamStopJoinRetryTimer(pMac, sessionId);
5615#endif
5616 /* This creates problem since we have not saved the connected profile.
5617 So moving this after saving the profile
5618 */
5619 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
Abhishek Singh36abbcb2014-03-20 13:04:09 +05305620
5621 /* Reset remainInPowerActiveTillDHCP as it might have been set
5622 * by last failed secured connection.
5623 * It should be set only for secured connection.
5624 */
5625 pMac->pmc.remainInPowerActiveTillDHCP = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005626 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
5627 {
5628 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
5629 }
5630 else
5631 {
5632 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
5633 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005634 //Use the last connected bssdesc for reassoc-ing to the same AP.
5635 //NOTE: What to do when reassoc to a different AP???
5636 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5637 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5638 {
5639 pSirBssDesc = pSession->pConnectBssDesc;
5640 if(pSirBssDesc)
5641 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305642 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5643 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005644 }
5645 }
5646 else
5647 {
5648
5649 if(pCommand->u.roamCmd.pRoamBssEntry)
5650 {
5651 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
5652 if(pScanResult != NULL)
5653 {
5654 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5655 //this can be NULL
5656 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
Kiet Lam64c1b492013-07-12 13:56:44 +05305657 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5658 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005659 }
5660 }
5661 }
5662 if( pSirBssDesc )
5663 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005664 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07005665 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5666 //Save WPA/RSN IE
5667 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005668#ifdef FEATURE_WLAN_ESE
5669 roamInfo.isESEAssoc = pSession->connectedProfile.isESEAssoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005670#endif
Mukul Sharma9ca96b22014-11-15 19:40:04 +05305671#ifdef WLAN_FEATURE_VOWIFI_11R
5672 if (pSirBssDesc->mdiePresent)
5673 {
5674 if(csrIsAuthType11r(pProfile->negotiatedAuthType, VOS_TRUE)
5675#ifdef FEATURE_WLAN_ESE
5676 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
5677 (pIes->ESEVersion.present) && (pMac->roam.configParam.isEseIniFeatureEnabled))
5678#endif
5679 )
5680 {
5681 // is11Rconnection;
5682 roamInfo.is11rAssoc = VOS_TRUE;
5683 }
5684 else
5685 {
5686 // is11Rconnection;
5687 roamInfo.is11rAssoc = VOS_FALSE;
5688 }
5689 }
5690#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005691 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
5692 // substate change.
5693 // Moving even save profile above so that below mentioned conditon is also met.
5694 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
5695 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005696 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
5697 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
5698 // will be dropped for the security context may not be set properly.
5699 //
5700 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
5701 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
5702 //
5703 // this reordering was done on titan_prod_usb branch and is being replicated here.
5704 //
5705
5706 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
5707 !pProfile->bWPSAssociation)
5708 {
5709 // Issue the set Context request to LIM to establish the Unicast STA context
5710 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
5711 pProfile->negotiatedUCEncryptionType,
5712 pSirBssDesc, &(pSirBssDesc->bssId),
5713 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
5714 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005715 smsLog( pMac, LOGE, FL(" Set context for unicast fail") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005716 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5717 }
5718 // Issue the set Context request to LIM to establish the Broadcast STA context
5719 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
5720 pSirBssDesc, &BroadcastMac,
5721 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5722 }
Abhishek Singh06c4b8b2016-04-05 10:27:07 +05305723 else if (!pSession->abortConnection)
Jeff Johnson295189b2012-06-20 16:38:30 -07005724 {
5725 //Need to wait for supplicant authtication
5726 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005727 //Set the subestate to WaitForKey in case authentiation is needed
5728 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
5729
Jeff Johnson295189b2012-06-20 16:38:30 -07005730 if(pProfile->bWPSAssociation)
5731 {
5732 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
5733 }
5734 else
5735 {
5736 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
5737 }
5738
5739 //Save sessionId in case of timeout
5740 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
5741 //This time should be long enough for the rest of the process plus setting key
5742 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
5743 {
5744 //Reset our state so nothting is blocked.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005745 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005746 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
5747 }
5748 }
5749
5750 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
5751 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005752 if(Context)
5753 {
5754 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
5755 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07005756 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5757 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
5758#ifdef WLAN_FEATURE_VOWIFI_11R
5759 len += pJoinRsp->parsedRicRspLen;
5760#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005761#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005762 len += pJoinRsp->tspecIeLen;
5763#endif
5764 if(len)
5765 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305766 pSession->connectedInfo.pbFrames = vos_mem_malloc(len);
5767 if ( pSession->connectedInfo.pbFrames != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07005768 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305769 vos_mem_copy(pSession->connectedInfo.pbFrames,
5770 pJoinRsp->frames, len);
5771 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5772 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5773 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
Jeff Johnson295189b2012-06-20 16:38:30 -07005774#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05305775 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005776#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005777#ifdef FEATURE_WLAN_ESE
Kiet Lam64c1b492013-07-12 13:56:44 +05305778 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005779#endif
Kiet Lam64c1b492013-07-12 13:56:44 +05305780 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5781 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5782 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
5783 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
Jeff Johnson295189b2012-06-20 16:38:30 -07005784 }
5785 }
5786 if(pCommand->u.roamCmd.fReassoc)
5787 {
5788 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5789 }
5790 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5791 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5792 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
5793 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
c_hpothu44ff4e02014-05-08 00:13:57 +05305794 roamInfo.maxRateFlags = pJoinRsp->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -07005795 }
5796 else
5797 {
5798 if(pCommand->u.roamCmd.fReassoc)
5799 {
5800 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5801 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5802 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5803 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5804 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5805 }
5806 }
Sandeep Puligillad91dccb2014-06-18 11:51:48 +05305807 /* Update the staId from the previous connected profile info
5808 as the reassociation is triggred at SME/HDD */
5809 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5810 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5811 {
5812 roamInfo.staId = pSession->connectedInfo.staId;
5813 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005814#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5815 // Indicate SME-QOS with reassoc success event, only after
5816 // copying the frames
5817 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
5818#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005819 roamInfo.pBssDesc = pSirBssDesc;
5820 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5821 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5822#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5823 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
5824#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
5825 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005826 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
5827 //It may be better to let QoS do this????
5828 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
5829 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005830 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now",
Jeff Johnson295189b2012-06-20 16:38:30 -07005831 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
5832 pmcStartUapsd( pMac, NULL, NULL );
5833 }
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05305834 pSession->connectedProfile.dot11Mode = pSession->bssParams.uCfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005835 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5836 if( pSession->bRefAssocStartCnt > 0 )
5837 {
5838 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005839 //Remove this code once SLM_Sessionization is supported
5840 //BMPS_WORKAROUND_NOT_NEEDED
5841 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005842 {
5843 pMac->roam.configParam.doBMPSWorkaround = 1;
5844 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005845 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5846 }
5847
5848 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005849 // reset the PMKID candidate list
5850 csrResetPMKIDCandidateList( pMac, sessionId );
5851 //Update TL's AC weight base on the current EDCA parameters
5852 //These parameters may change in the course of the connection, that sictuation
5853 //is not taken care here. This change is mainly to address a WIFI WMM test where
5854 //BE has a equal or higher TX priority than VI.
5855 //We only do this for infra link
5856 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
5857 {
5858 csrCheckAndUpdateACWeight(pMac, pIes);
5859 }
5860#ifdef FEATURE_WLAN_WAPI
5861 // reset the BKID candidate list
5862 csrResetBKIDCandidateList( pMac, sessionId );
5863#endif /* FEATURE_WLAN_WAPI */
5864 }
5865 else
5866 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005867 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc");
Jeff Johnson295189b2012-06-20 16:38:30 -07005868 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005869 csrScanCancelIdleScan(pMac);
5870 //Not to signal link up because keys are yet to be set.
5871 //The linkup function will overwrite the sub-state that we need to keep at this point.
5872 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
5873 {
5874 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
5875 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005876 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
5877 //enough to let security and DHCP handshake succeed before entry into BMPS
5878 if (pmcShouldBmpsTimerRun(pMac))
5879 {
Abhishek Singh65d939e2014-04-25 13:33:07 +05305880 /* Set remainInPowerActiveTillDHCP to make sure we wait for
5881 * until keys are set before going into BMPS.
5882 */
5883 if(eANI_BOOLEAN_TRUE == roamInfo.fAuthRequired)
5884 {
5885 pMac->pmc.remainInPowerActiveTillDHCP = TRUE;
5886 smsLog(pMac, LOG1, FL("Set remainInPowerActiveTillDHCP "
5887 "to make sure we wait until keys are set before"
5888 " going to BMPS"));
5889 }
5890
Jeff Johnson295189b2012-06-20 16:38:30 -07005891 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
5892 != eHAL_STATUS_SUCCESS)
5893 {
5894 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
5895 }
5896 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
5897 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005898 break;
5899
Jeff Johnson295189b2012-06-20 16:38:30 -07005900 case eCsrStartBssSuccess:
5901 // on the StartBss Response, LIM is returning the Bss Description that we
5902 // are beaconing. Add this Bss Description to our scan results and
5903 // chain the Profile to this Bss Description. On a Start BSS, there was no
5904 // detected Bss description (no partner) so we issued the Start Bss to
5905 // start the Ibss without any Bss description. Lim was kind enough to return
5906 // the Bss Description that we start beaconing for the newly started Ibss.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005907 smsLog(pMac, LOG2, FL("receives start BSS ok indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005908 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005909 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
Kiet Lam64c1b492013-07-12 13:56:44 +05305910 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005911 if( CSR_IS_IBSS( pProfile ) )
5912 {
5913 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
5914 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005915 else if (CSR_IS_INFRA_AP(pProfile))
5916 {
5917 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
5918 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005919 else
5920 {
5921 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
5922 }
5923 if( !CSR_IS_WDS_STA( pProfile ) )
5924 {
5925 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005926 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
Jeff Johnson295189b2012-06-20 16:38:30 -07005927 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
5928 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05305929 smsLog(pMac, LOGW, FL("cannot parse IBSS IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005930 roamInfo.pBssDesc = pSirBssDesc;
5931 //We need to associate_complete it first, becasue Associate_start already indicated.
5932 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5933 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
5934 break;
5935 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005936 if (!CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07005937 {
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07005938 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005939 }
5940 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
5941 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5942 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5943 if(pSirBssDesc)
5944 {
5945 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
Kiet Lam64c1b492013-07-12 13:56:44 +05305946 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5947 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005948 }
5949 //We are doen with the IEs so free it
Kiet Lam64c1b492013-07-12 13:56:44 +05305950 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005951#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5952 {
5953 vos_log_ibss_pkt_type *pIbssLog;
5954 tANI_U32 bi;
5955
5956 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5957 if(pIbssLog)
5958 {
5959 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5960 {
5961 //We start the IBSS (didn't find any matched IBSS out there)
5962 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
5963 }
5964 else
5965 {
5966 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
5967 }
5968 if(pSirBssDesc)
5969 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305970 vos_mem_copy(pIbssLog->bssid, pSirBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07005971 pIbssLog->operatingChannel = pSirBssDesc->channelId;
5972 }
5973 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
5974 {
5975 //***U8 is not enough for beacon interval
5976 pIbssLog->beaconInterval = (v_U8_t)bi;
5977 }
5978 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5979 }
5980 }
5981#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5982 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
5983 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07005984 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
5985 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005986 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
5987 csrRoamIssueSetContextReq( pMac, sessionId,
5988 pProfile->negotiatedMCEncryptionType,
5989 pSirBssDesc, &BroadcastMac,
5990 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5991 }
5992 }
5993 else
5994 {
5995 //Keep the state to eCSR_ROAMING_STATE_JOINING
5996 //Need to send join_req.
5997 if(pCommand->u.roamCmd.pRoamBssEntry)
5998 {
5999 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
6000 {
6001 pSirBssDesc = &pScanResult->Result.BssDescriptor;
6002 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
6003 // Set the roaming substate to 'join attempt'...
6004 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08006005 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006006 }
6007 }
6008 else
6009 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006010 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc" );
Jeff Johnson295189b2012-06-20 16:38:30 -07006011 VOS_ASSERT( 0 );
6012 }
6013 }
6014 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
6015 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
6016 //trigger the connection start indication in Vista
6017 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
6018 {
6019 roamStatus = eCSR_ROAM_IBSS_IND;
6020 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
6021 if( CSR_IS_WDS( pProfile ) )
6022 {
6023 roamStatus = eCSR_ROAM_WDS_IND;
6024 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
6025 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006026 if( CSR_IS_INFRA_AP( pProfile ) )
6027 {
6028 roamStatus = eCSR_ROAM_INFRA_IND;
6029 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
6030 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006031
6032 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
6033 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
6034 //trigger the connection start indication in Vista
Kiet Lam64c1b492013-07-12 13:56:44 +05306035 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006036 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
6037 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
krunal soni3fc26642013-10-08 22:41:42 -07006038 //We start the IBSS (didn't find any matched IBSS out there)
6039 roamInfo.pBssDesc = pSirBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -07006040 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
Kiet Lam64c1b492013-07-12 13:56:44 +05306041 vos_mem_copy(roamInfo.bssid, pSirBssDesc->bssId,
6042 sizeof(tCsrBssid));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07006043 //Remove this code once SLM_Sessionization is supported
6044 //BMPS_WORKAROUND_NOT_NEEDED
6045 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07006046 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07006047 {
6048 pMac->roam.configParam.doBMPSWorkaround = 1;
6049 }
Mohit Khanna349bc392012-09-11 17:24:52 -07006050
Jeff Johnson295189b2012-06-20 16:38:30 -07006051 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
6052 }
6053
6054 csrScanCancelIdleScan(pMac);
Ravi Joshi414b14c2013-10-04 16:33:26 -07006055
6056 if( CSR_IS_WDS_STA( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006057 {
6058 //need to send stop BSS because we fail to send join_req
6059 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
6060 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6061 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
6062 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006063 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006064 case eCsrStartBssFailure:
6065#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
6066 {
6067 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07006068 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
6069 if(pIbssLog)
6070 {
6071 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
6072 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
6073 }
6074 }
6075#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07006076 roamStatus = eCSR_ROAM_IBSS_IND;
6077 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
6078 if( CSR_IS_WDS( pProfile ) )
6079 {
6080 roamStatus = eCSR_ROAM_WDS_IND;
6081 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
6082 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006083 if( CSR_IS_INFRA_AP( pProfile ) )
6084 {
6085 roamStatus = eCSR_ROAM_INFRA_IND;
6086 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
6087 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006088 if(Context)
6089 {
6090 pSirBssDesc = (tSirBssDescription *)Context;
6091 }
6092 else
6093 {
6094 pSirBssDesc = NULL;
6095 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306096 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006097 roamInfo.pBssDesc = pSirBssDesc;
6098 //We need to associate_complete it first, becasue Associate_start already indicated.
6099 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
6100 csrSetDefaultDot11Mode( pMac );
6101 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006102 case eCsrSilentlyStopRoaming:
6103 // We are here because we try to start the same IBSS
6104 //No message to PE
6105 // return the roaming state to Joined.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006106 smsLog(pMac, LOGW, FL("receives silently roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006107 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
6108 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05306109 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006110 roamInfo.pBssDesc = pSession->pConnectBssDesc;
6111 if( roamInfo.pBssDesc )
6112 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306113 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
6114 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006115 }
6116 //Since there is no change in the current state, simply pass back no result otherwise
6117 //HDD may be mistakenly mark to disconnected state.
6118 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6119 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07006120 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006121 case eCsrSilentlyStopRoamingSaveState:
6122 //We are here because we try to connect to the same AP
6123 //No message to PE
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006124 smsLog(pMac, LOGW, FL("receives silently stop roaming indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05306125 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006126
6127 //to aviod resetting the substate to NONE
6128 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
6129 //No need to change substate to wai_for_key because there is no state change
6130 roamInfo.pBssDesc = pSession->pConnectBssDesc;
6131 if( roamInfo.pBssDesc )
6132 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306133 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
6134 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006135 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006136 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
6137 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
6138 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
6139 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
6140 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
6141 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
6142 roamInfo.staId = pSession->connectedInfo.staId;
6143 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07006144 VOS_ASSERT( roamInfo.staId != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006145 pSession->bRefAssocStartCnt--;
6146 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6147 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
6148 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
6149 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006150 case eCsrReassocFailure:
6151#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6152 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
6153#endif
6154 case eCsrJoinWdsFailure:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006155 smsLog(pMac, LOGW, FL("failed to join WDS"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006156 csrFreeConnectBssDesc(pMac, sessionId);
6157 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
6158 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
Kiet Lam64c1b492013-07-12 13:56:44 +05306159 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006160 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
6161 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
6162 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
6163 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6164 eCSR_ROAM_WDS_IND,
6165 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
6166 //Need to issue stop_bss
6167 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006168 case eCsrJoinFailure:
6169 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07006170 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07006171 default:
6172 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006173 smsLog(pMac, LOGW, FL("receives no association indication"));
6174 smsLog(pMac, LOG1, FL("Assoc ref count %d"),
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07006175 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07006176 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
6177 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
6178 {
6179 //do not free for the other profiles as we need to send down stop BSS later
6180 csrFreeConnectBssDesc(pMac, sessionId);
6181 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
6182 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
6183 csrSetDefaultDot11Mode( pMac );
6184 }
6185
6186 switch( pCommand->u.roamCmd.roamReason )
6187 {
6188 // If this transition is because of an 802.11 OID, then we transition
6189 // back to INIT state so we sit waiting for more OIDs to be issued and
6190 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07006191 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07006192 case eCsrSmeIssuedAssocToSimilarAP:
6193 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08006194 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07006195 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05306196 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006197 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
6198 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
6199 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Kiet Lam64c1b492013-07-12 13:56:44 +05306200 vos_mem_copy(&roamInfo.bssid,
6201 &pSession->joinFailStatusCode.bssId,
6202 sizeof(tCsrBssid));
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07006203
Jeff Johnson295189b2012-06-20 16:38:30 -07006204 /* Defeaturize this later if needed */
6205#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
6206 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
6207 if (csrRoamIsHandoffInProgress(pMac))
6208 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006209 /* Should indicate neighbor roam algorithm about the connect failure here */
6210 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
6211 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006212#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006213 if(pSession->bRefAssocStartCnt > 0)
6214 {
6215 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07006216 if(eCsrJoinFailureDueToConcurrency == Result)
6217 {
6218 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
6219 eCSR_ROAM_ASSOCIATION_COMPLETION,
6220 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
6221 }
6222 else
6223 {
6224 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07006225 eCSR_ROAM_ASSOCIATION_COMPLETION,
6226 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07006227 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006228 }
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08006229 else
6230 {
6231 /* bRefAssocStartCnt is not incremented when
6232 * eRoamState == eCsrStopRoamingDueToConcurrency
6233 * in csrRoamJoinNextBss API. so handle this in
6234 * else case by sending assoc failure
6235 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07006236 csrRoamCallCallback(pMac, sessionId, &roamInfo,
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08006237 pCommand->u.scanCmd.roamId,
6238 eCSR_ROAM_ASSOCIATION_FAILURE,
6239 eCSR_ROAM_RESULT_FAILURE);
6240 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006241 smsLog(pMac, LOG1, FL(" roam(reason %d) failed"), pCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07006242#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Mukul Sharma5960ac82014-01-09 20:31:35 +05306243 sme_QosUpdateHandOff((tANI_U8)sessionId, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006244 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
6245#endif
6246 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6247 csrScanStartIdleScan(pMac);
6248#ifdef FEATURE_WLAN_BTAMP_UT_RF
6249 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
6250 //BT activity and not able to recevie WLAN traffic. Retry the join
6251 if( CSR_IS_WDS_STA(pProfile) )
6252 {
6253 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
6254 }
6255#endif
6256 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006257 case eCsrHddIssuedReassocToSameAP:
6258 case eCsrSmeIssuedReassocToSameAP:
6259 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
6260
6261 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
6262#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6263 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
6264#endif
6265 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6266 csrScanStartIdleScan(pMac);
6267 break;
6268 case eCsrForcedDisassoc:
6269 case eCsrForcedDeauth:
6270 case eCsrSmeIssuedIbssJoinFailure:
6271 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
6272
6273 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
6274 {
6275 // Notify HDD that IBSS join failed
6276 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
6277 }
6278 else
6279 {
6280 csrRoamCallCallback(pMac, sessionId, NULL,
6281 pCommand->u.roamCmd.roamId,
6282 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
6283 }
6284#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6285 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
6286#endif
6287 csrRoamLinkDown(pMac, sessionId);
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08006288 /*
6289 *DelSta not done FW still in conneced state so dont
6290 *issue IMPS req
6291 */
6292 if (pMac->roam.deauthRspStatus == eSIR_SME_DEAUTH_STATUS)
6293 {
6294 smsLog(pMac, LOGW, FL("FW still in connected state "));
6295 break;
6296 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006297 csrScanStartIdleScan(pMac);
6298 break;
6299 case eCsrForcedIbssLeave:
Abhishek Singhc640dbb2015-06-08 10:54:17 +05306300 csrIbssAgeBss(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07006301 csrRoamCallCallback(pMac, sessionId, NULL,
6302 pCommand->u.roamCmd.roamId,
6303 eCSR_ROAM_IBSS_LEAVE,
6304 eCSR_ROAM_RESULT_IBSS_STOP);
6305 break;
6306 case eCsrForcedDisassocMICFailure:
6307 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
6308
6309 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
6310#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6311 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
6312#endif
6313 csrScanStartIdleScan(pMac);
6314 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006315 case eCsrStopBss:
6316 csrRoamCallCallback(pMac, sessionId, NULL,
6317 pCommand->u.roamCmd.roamId,
6318 eCSR_ROAM_INFRA_IND,
6319 eCSR_ROAM_RESULT_INFRA_STOPPED);
6320 break;
6321 case eCsrForcedDisassocSta:
6322 case eCsrForcedDeauthSta:
6323 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
6324 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
6325 {
6326 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006327
6328 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
6329 {
6330 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05306331 vos_mem_copy(roamInfo.peerMac,
6332 pCommand->u.roamCmd.peerMac,
6333 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07006334 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
6335 roamInfo.statusCode = eSIR_SME_SUCCESS;
6336 status = csrRoamCallCallback(pMac, sessionId,
6337 &roamInfo, pCommand->u.roamCmd.roamId,
6338 eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
6339 }
6340 }
6341 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006342 case eCsrLostLink1:
6343 // if lost link roam1 failed, then issue lost link Scan2 ...
6344 csrScanRequestLostLink2(pMac, sessionId);
6345 break;
6346 case eCsrLostLink2:
6347 // if lost link roam2 failed, then issue lost link scan3 ...
6348 csrScanRequestLostLink3(pMac, sessionId);
6349 break;
6350 case eCsrLostLink3:
6351 default:
6352 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
6353
6354 //We are done with one round of lostlink roaming here
6355 csrScanHandleFailedLostlink3(pMac, sessionId);
6356 break;
6357 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006358 break;
6359 }
6360 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006361 return ( fReleaseCommand );
6362}
6363
Jeff Johnson295189b2012-06-20 16:38:30 -07006364eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
6365{
6366 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006367 return (status);
6368}
6369
Jeff Johnson295189b2012-06-20 16:38:30 -07006370eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
6371{
6372 eHalStatus status = eHAL_STATUS_SUCCESS;
6373 tANI_U32 size = 0;
6374
6375 do
6376 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306377 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006378 if(pSrcProfile->BSSIDs.numOfBSSIDs)
6379 {
6380 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306381 pDstProfile->BSSIDs.bssid = vos_mem_malloc(size);
6382 if ( NULL == pDstProfile->BSSIDs.bssid )
6383 status = eHAL_STATUS_FAILURE;
6384 else
6385 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006386 if(!HAL_STATUS_SUCCESS(status))
6387 {
6388 break;
6389 }
6390 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306391 vos_mem_copy(pDstProfile->BSSIDs.bssid,
6392 pSrcProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07006393 }
6394 if(pSrcProfile->SSIDs.numOfSSIDs)
6395 {
6396 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306397 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(size);
6398 if ( NULL == pDstProfile->SSIDs.SSIDList )
6399 status = eHAL_STATUS_FAILURE;
6400 else
6401 status = eHAL_STATUS_SUCCESS;
6402 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006403 {
6404 break;
6405 }
6406 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306407 vos_mem_copy(pDstProfile->SSIDs.SSIDList,
6408 pSrcProfile->SSIDs.SSIDList, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07006409 }
6410 if(pSrcProfile->nWPAReqIELength)
6411 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306412 pDstProfile->pWPAReqIE = vos_mem_malloc(pSrcProfile->nWPAReqIELength);
6413 if ( NULL == pDstProfile->pWPAReqIE )
6414 status = eHAL_STATUS_FAILURE;
6415 else
6416 status = eHAL_STATUS_SUCCESS;
6417
6418 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006419 {
6420 break;
6421 }
6422 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306423 vos_mem_copy(pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE,
6424 pSrcProfile->nWPAReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006425 }
6426 if(pSrcProfile->nRSNReqIELength)
6427 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306428 pDstProfile->pRSNReqIE = vos_mem_malloc(pSrcProfile->nRSNReqIELength);
6429 if ( NULL == pDstProfile->pRSNReqIE )
6430 status = eHAL_STATUS_FAILURE;
6431 else
6432 status = eHAL_STATUS_SUCCESS;
6433
6434 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006435 {
6436 break;
6437 }
6438 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306439 vos_mem_copy(pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE,
6440 pSrcProfile->nRSNReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006441 }
6442#ifdef FEATURE_WLAN_WAPI
6443 if(pSrcProfile->nWAPIReqIELength)
6444 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306445 pDstProfile->pWAPIReqIE = vos_mem_malloc(pSrcProfile->nWAPIReqIELength);
6446 if ( NULL == pDstProfile->pWAPIReqIE )
6447 status = eHAL_STATUS_FAILURE;
6448 else
6449 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006450 if(!HAL_STATUS_SUCCESS(status))
6451 {
6452 break;
6453 }
6454 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306455 vos_mem_copy(pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE,
6456 pSrcProfile->nWAPIReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006457 }
6458#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07006459 if(pSrcProfile->nAddIEScanLength)
6460 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +05306461 memset(pDstProfile->addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH);
6462 if ( SIR_MAC_MAX_ADD_IE_LENGTH >= pSrcProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -07006463 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05306464 vos_mem_copy(pDstProfile->addIEScan, pSrcProfile->addIEScan,
Kiet Lam64c1b492013-07-12 13:56:44 +05306465 pSrcProfile->nAddIEScanLength);
Agarwal Ashish4f616132013-12-30 23:32:50 +05306466 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
6467 }
6468 else
6469 {
6470 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
6471 FL(" AddIEScanLength is not valid %u"),
6472 pSrcProfile->nAddIEScanLength);
6473 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006474 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006475 if(pSrcProfile->nAddIEAssocLength)
6476 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306477 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6478 if ( NULL == pDstProfile->pAddIEAssoc )
6479 status = eHAL_STATUS_FAILURE;
6480 else
6481 status = eHAL_STATUS_SUCCESS;
6482
Jeff Johnson295189b2012-06-20 16:38:30 -07006483 if(!HAL_STATUS_SUCCESS(status))
6484 {
6485 break;
6486 }
6487 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306488 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6489 pSrcProfile->nAddIEAssocLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006490 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006491 if(pSrcProfile->ChannelInfo.ChannelList)
6492 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306493 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(
6494 pSrcProfile->ChannelInfo.numOfChannels);
6495 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6496 status = eHAL_STATUS_FAILURE;
6497 else
6498 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006499 if(!HAL_STATUS_SUCCESS(status))
6500 {
6501 break;
6502 }
6503 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
Kiet Lam64c1b492013-07-12 13:56:44 +05306504 vos_mem_copy(pDstProfile->ChannelInfo.ChannelList,
6505 pSrcProfile->ChannelInfo.ChannelList,
6506 pSrcProfile->ChannelInfo.numOfChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07006507 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006508 pDstProfile->AuthType = pSrcProfile->AuthType;
6509 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
6510 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
6511 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
6512 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
6513 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
Chet Lanctot186b5732013-03-18 10:26:30 -07006514#ifdef WLAN_FEATURE_11W
6515 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
6516 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
6517 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
6518#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006519 pDstProfile->BSSType = pSrcProfile->BSSType;
6520 pDstProfile->phyMode = pSrcProfile->phyMode;
6521 pDstProfile->csrPersona = pSrcProfile->csrPersona;
6522
6523#ifdef FEATURE_WLAN_WAPI
6524 if(csrIsProfileWapi(pSrcProfile))
6525 {
6526 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
6527 {
6528 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
6529 }
6530 }
6531#endif /* FEATURE_WLAN_WAPI */
6532 pDstProfile->CBMode = pSrcProfile->CBMode;
6533 /*Save the WPS info*/
6534 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006535 pDstProfile->bOSENAssociation = pSrcProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07006536 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006537 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07006538 pDstProfile->privacy = pSrcProfile->privacy;
6539 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
6540 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
6541 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
6542 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
6543 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
6544 pDstProfile->protEnabled = pSrcProfile->protEnabled;
6545 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
6546 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
6547 pDstProfile->wps_state = pSrcProfile->wps_state;
6548 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
Kiet Lam64c1b492013-07-12 13:56:44 +05306549 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6550 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006551#ifdef WLAN_FEATURE_VOWIFI_11R
6552 if (pSrcProfile->MDID.mdiePresent)
6553 {
6554 pDstProfile->MDID.mdiePresent = 1;
6555 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6556 }
6557#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006558 }while(0);
6559
6560 if(!HAL_STATUS_SUCCESS(status))
6561 {
6562 csrReleaseProfile(pMac, pDstProfile);
6563 pDstProfile = NULL;
6564 }
6565
6566 return (status);
6567}
Jeff Johnson295189b2012-06-20 16:38:30 -07006568eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
6569{
6570 eHalStatus status = eHAL_STATUS_SUCCESS;
6571 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
6572 do
6573 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306574 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006575 if(pSrcProfile->bssid)
6576 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306577 pDstProfile->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
6578 if ( NULL == pDstProfile->BSSIDs.bssid )
6579 status = eHAL_STATUS_FAILURE;
6580 else
6581 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006582 if(!HAL_STATUS_SUCCESS(status))
6583 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306584 smsLog( pMac, LOGE,
6585 FL("failed to allocate memory for BSSID"
6586 "%02x:%02x:%02x:%02x:%02x:%02x"),
6587 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6588 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006589 break;
6590 }
6591 pDstProfile->BSSIDs.numOfBSSIDs = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05306592 vos_mem_copy(pDstProfile->BSSIDs.bssid, pSrcProfile->bssid,
6593 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006594 }
6595 if(pSrcProfile->SSID.ssId)
6596 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306597 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
6598 if ( NULL == pDstProfile->SSIDs.SSIDList )
6599 status = eHAL_STATUS_FAILURE;
6600 else
6601 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006602 if(!HAL_STATUS_SUCCESS(status))
6603 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306604 smsLog( pMac, LOGE,
6605 FL("failed to allocate memory for SSIDList"
6606 "%02x:%02x:%02x:%02x:%02x:%02x"),
6607 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6608 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006609 break;
6610 }
6611 pDstProfile->SSIDs.numOfSSIDs = 1;
6612 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
6613 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
Kiet Lam64c1b492013-07-12 13:56:44 +05306614 vos_mem_copy(&pDstProfile->SSIDs.SSIDList[0].SSID,
6615 &pSrcProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006616 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006617 if(pSrcProfile->nAddIEAssocLength)
6618 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306619 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6620 if ( NULL == pDstProfile->pAddIEAssoc)
6621 status = eHAL_STATUS_FAILURE;
6622 else
6623 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006624 if(!HAL_STATUS_SUCCESS(status))
6625 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006626 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs ") );
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006627 break;
6628 }
6629 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306630 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6631 pSrcProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006632 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306633 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(1);
6634 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6635 status = eHAL_STATUS_FAILURE;
6636 else
6637 status = eHAL_STATUS_SUCCESS;
6638
Jeff Johnson295189b2012-06-20 16:38:30 -07006639 if(!HAL_STATUS_SUCCESS(status))
6640 {
6641 break;
6642 }
6643 pDstProfile->ChannelInfo.numOfChannels = 1;
6644 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006645 pDstProfile->AuthType.numEntries = 1;
6646 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
6647 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
6648 pDstProfile->EncryptionType.numEntries = 1;
6649 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
6650 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
6651 pDstProfile->mcEncryptionType.numEntries = 1;
6652 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
6653 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
6654 pDstProfile->BSSType = pSrcProfile->BSSType;
6655 pDstProfile->CBMode = pSrcProfile->CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +05306656 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6657 sizeof(pDstProfile->Keys));
Abhishek Singh2fb3a6e2014-11-20 16:03:01 +05306658#ifdef WLAN_FEATURE_11W
6659 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
6660 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
6661 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
6662#endif
6663
Jeff Johnson295189b2012-06-20 16:38:30 -07006664#ifdef WLAN_FEATURE_VOWIFI_11R
6665 if (pSrcProfile->MDID.mdiePresent)
6666 {
6667 pDstProfile->MDID.mdiePresent = 1;
6668 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6669 }
6670#endif
6671
6672 }while(0);
6673
6674 if(!HAL_STATUS_SUCCESS(status))
6675 {
6676 csrReleaseProfile(pMac, pDstProfile);
6677 pDstProfile = NULL;
6678 }
6679
6680 return (status);
6681}
6682
Jeff Johnson295189b2012-06-20 16:38:30 -07006683eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6684 tScanResultHandle hBSSList,
6685 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
6686 tANI_BOOLEAN fClearScan)
6687{
6688 eHalStatus status = eHAL_STATUS_SUCCESS;
6689 tSmeCmd *pCommand;
6690
6691 pCommand = csrGetCommandBuffer(pMac);
6692 if(NULL == pCommand)
6693 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006694 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006695 status = eHAL_STATUS_RESOURCES;
6696 }
6697 else
6698 {
6699 if( fClearScan )
6700 {
6701 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306702 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006703 }
6704 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6705 if(NULL == pProfile)
6706 {
6707 //We can roam now
6708 //Since pProfile is NULL, we need to build our own profile, set everything to default
6709 //We can only support open and no encryption
6710 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
6711 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
6712 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
6713 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6714 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
6715 }
6716 else
6717 {
6718 //make a copy of the profile
6719 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6720 if(HAL_STATUS_SUCCESS(status))
6721 {
6722 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6723 }
6724 }
6725 pCommand->command = eSmeCommandRoam;
6726 pCommand->sessionId = (tANI_U8)sessionId;
6727 pCommand->u.roamCmd.hBSSList = hBSSList;
6728 pCommand->u.roamCmd.roamId = roamId;
6729 pCommand->u.roamCmd.roamReason = reason;
6730 //We need to free the BssList when the command is done
6731 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
6732 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006733 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6734 FL("CSR PERSONA=%d"),
6735 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07006736 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6737 if( !HAL_STATUS_SUCCESS( status ) )
6738 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006739 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006740 csrReleaseCommandRoam( pMac, pCommand );
6741 }
6742 }
6743
6744 return (status);
6745}
Jeff Johnson295189b2012-06-20 16:38:30 -07006746eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6747 tCsrRoamModifyProfileFields *pMmodProfileFields,
6748 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
6749{
6750 eHalStatus status = eHAL_STATUS_SUCCESS;
6751 tSmeCmd *pCommand;
6752
6753 pCommand = csrGetCommandBuffer(pMac);
6754 if(NULL == pCommand)
6755 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006756 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006757 status = eHAL_STATUS_RESOURCES;
6758 }
6759 else
6760 {
6761 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306762 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006763 if(pProfile)
6764 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006765 //This is likely trying to reassoc to different profile
6766 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6767 //make a copy of the profile
6768 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6769 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006770 }
6771 else
6772 {
6773 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
6774 //how to update WPA/WPA2 info in roamProfile??
6775 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006776 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006777 if(HAL_STATUS_SUCCESS(status))
6778 {
6779 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6780 }
6781 pCommand->command = eSmeCommandRoam;
6782 pCommand->sessionId = (tANI_U8)sessionId;
6783 pCommand->u.roamCmd.roamId = roamId;
6784 pCommand->u.roamCmd.roamReason = reason;
6785 //We need to free the BssList when the command is done
6786 //For reassoc there is no BSS list, so the boolean set to false
6787 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
6788 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
6789 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006790 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6791 if( !HAL_STATUS_SUCCESS( status ) )
6792 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006793 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006794 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6795 csrReleaseCommandRoam( pMac, pCommand );
6796 }
6797 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006798 return (status);
6799}
6800
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006801eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
6802 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306803// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006804{
6805 eHalStatus status = eHAL_STATUS_SUCCESS;
6806 tSmeCmd *pCommand;
6807
6808 pCommand = csrGetCommandBuffer(pMac);
6809 if(NULL == pCommand)
6810 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006811 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006812 status = eHAL_STATUS_RESOURCES;
6813 }
6814 else
6815 {
6816 if(pBssDescription)
6817 {
6818 //copy over the parameters we need later
6819 pCommand->command = eSmeCommandRoam;
6820 pCommand->sessionId = (tANI_U8)sessionId;
6821 pCommand->u.roamCmd.roamReason = reason;
6822 //this is the important parameter
6823 //in this case we are using this field for the "next" BSS
6824 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
6825 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
6826 if( !HAL_STATUS_SUCCESS( status ) )
6827 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006828 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d"), status );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006829 csrReleaseCommandPreauth( pMac, pCommand );
6830 }
6831 }
6832 else
6833 {
6834 //Return failure
6835 status = eHAL_STATUS_RESOURCES;
6836 }
6837 }
6838 return (status);
6839}
6840
6841eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
6842{
6843 tListElem *pEntry;
6844 tSmeCmd *pCommand;
6845 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6846 if ( pEntry )
6847 {
6848 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6849 if ( (eSmeCommandRoam == pCommand->command) &&
6850 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
6851 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006852 smsLog( pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006853 pCommand->command, pCommand->u.roamCmd.roamReason);
6854 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
6855 csrReleaseCommandPreauth( pMac, pCommand );
6856 }
6857 } else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006858 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d "),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006859 pCommand->command, pCommand->u.roamCmd.roamReason);
6860 }
6861 }
6862 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006863 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006864 }
6865 smeProcessPendingQueue( pMac );
6866 return eHAL_STATUS_SUCCESS;
6867}
6868
Jeff Johnson295189b2012-06-20 16:38:30 -07006869eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6870 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6871{
6872 eHalStatus status = eHAL_STATUS_FAILURE;
6873 tScanResultHandle hBSSList;
6874 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006875 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
6876 if(HAL_STATUS_SUCCESS(status))
6877 {
6878 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6879 if(pRoamId)
6880 {
6881 *pRoamId = roamId;
6882 }
6883 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6884 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6885 if(!HAL_STATUS_SUCCESS(status))
6886 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006887 smsLog(pMac, LOGE, FL("failed to start a join process"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006888 csrScanResultPurge(pMac, hBSSList);
6889 }
6890 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006891 return (status);
6892}
6893
Jeff Johnson295189b2012-06-20 16:38:30 -07006894eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6895 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6896{
6897 eHalStatus status = eHAL_STATUS_SUCCESS;
6898 tScanResultHandle hBSSList;
6899 tCsrScanResultFilter *pScanFilter;
6900 tANI_U32 roamId = 0;
6901 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
6902 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006903 if (NULL == pProfile)
6904 {
6905 smsLog(pMac, LOGP, FL("No profile specified"));
6906 return eHAL_STATUS_FAILURE;
6907 }
Abhishek Singh230371c2015-11-23 11:29:57 +05306908 if(!pSession)
6909 {
6910 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6911 return eHAL_STATUS_FAILURE;
6912 }
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05306913 smsLog(pMac, LOG1, FL("called BSSType = %s (%d) authtype = %d "
6914 "encryType = %d"),
6915 lim_BssTypetoString(pProfile->BSSType),
6916 pProfile->BSSType,
6917 pProfile->AuthType.authType[0],
6918 pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006919 if( CSR_IS_WDS( pProfile ) &&
6920 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
6921 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006922 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d"),
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006923 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006924 return status;
6925 }
Abhishek Singh230371c2015-11-23 11:29:57 +05306926 /* Reset abortConnection for the fresh connection */
6927 pSession->abortConnection = FALSE;
Abhishek Singhe0bc0992016-05-20 17:58:18 +05306928 pSession->dhcp_done = false;
Jeff Johnson295189b2012-06-20 16:38:30 -07006929 csrRoamCancelRoaming(pMac, sessionId);
6930 csrScanRemoveFreshScanCommand(pMac, sessionId);
6931 csrScanCancelIdleScan(pMac);
6932 //Only abort the scan if it is not used for other roam/connect purpose
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05306933 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Agarwal Ashish5974ed32014-06-16 16:59:54 +05306934
6935 if (!vos_concurrent_open_sessions_running() &&
6936 (VOS_STA_SAP_MODE == pProfile->csrPersona))
Jeff Johnson295189b2012-06-20 16:38:30 -07006937 {
Agarwal Ashish5974ed32014-06-16 16:59:54 +05306938 /* In case of AP mode we do not want idle mode scan */
Jeff Johnson295189b2012-06-20 16:38:30 -07006939 csrScanDisable(pMac);
6940 }
Agarwal Ashish5974ed32014-06-16 16:59:54 +05306941
Jeff Johnson295189b2012-06-20 16:38:30 -07006942 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6943 //Check whether ssid changes
6944 if(csrIsConnStateConnected(pMac, sessionId))
6945 {
6946 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6947 {
6948 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6949 }
6950 }
6951#ifdef FEATURE_WLAN_BTAMP_UT_RF
6952 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
6953#endif
Abhishek Singh7b52ed52016-02-11 17:45:54 +05306954 /*
6955 * If roamSession.connectState is disconnecting that mean
6956 * disconnect/stop adapter was received with scan for ssid
6957 * in progress and dropped. This state will ensure that
6958 * connect will not be issued from scan for ssid completion.
6959 * Thus if this fresh connect also issue scan for ssid the connect
6960 * command will be dropped assuming disconnect is in progress.
6961 * Thus reset connectState here
6962 */
6963 if (eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTING ==
6964 pMac->roam.roamSession[sessionId].connectState)
6965 pMac->roam.roamSession[sessionId].connectState =
6966 eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
Jeff Johnson295189b2012-06-20 16:38:30 -07006967 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
6968 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006969 smsLog(pMac, LOG1, FL("is called with BSSList"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006970 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
6971 if(pRoamId)
6972 {
6973 roamId = *pRoamId;
6974 }
6975 if(!HAL_STATUS_SUCCESS(status))
6976 {
6977 fCallCallback = eANI_BOOLEAN_TRUE;
6978 }
6979 }
6980 else
6981 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306982 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
6983 if ( NULL == pScanFilter )
6984 status = eHAL_STATUS_FAILURE;
6985 else
6986 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006987 if(HAL_STATUS_SUCCESS(status))
6988 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306989 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006990 //Try to connect to any BSS
6991 if(NULL == pProfile)
6992 {
6993 //No encryption
6994 pScanFilter->EncryptionType.numEntries = 1;
6995 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6996 }//we don't have a profile
6997 else
6998 {
6999 //Here is the profile we need to connect to
7000 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
7001 }//We have a profile
7002 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
7003 if(pRoamId)
7004 {
7005 *pRoamId = roamId;
7006 }
7007
7008 if(HAL_STATUS_SUCCESS(status))
7009 {
7010 /*Save the WPS info*/
7011 if(NULL != pProfile)
7012 {
7013 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07007014 pScanFilter->bOSENAssociation = pProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07007015 }
7016 else
7017 {
7018 pScanFilter->bWPSAssociation = 0;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07007019 pScanFilter->bOSENAssociation = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07007020 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007021 do
7022 {
7023 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07007024 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
Jeff Johnson295189b2012-06-20 16:38:30 -07007025 )
7026 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007027 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07007028 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
7029 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
7030 if(!HAL_STATUS_SUCCESS(status))
7031 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007032 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007033 fCallCallback = eANI_BOOLEAN_TRUE;
7034 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007035 else
7036 {
7037 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
7038 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007039 break;
7040 }
7041 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007042 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007043 if(HAL_STATUS_SUCCESS(status))
7044 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007045 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
7046 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
7047 if(!HAL_STATUS_SUCCESS(status))
7048 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007049 smsLog(pMac, LOGE, FL(" CSR failed to issue connect command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007050 csrScanResultPurge(pMac, hBSSList);
7051 fCallCallback = eANI_BOOLEAN_TRUE;
7052 }
7053 }//Have scan result
7054 else if(NULL != pProfile)
7055 {
7056 //Check whether it is for start ibss
7057 if(CSR_IS_START_IBSS(pProfile))
7058 {
7059 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
7060 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
7061 if(!HAL_STATUS_SUCCESS(status))
7062 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007063 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007064 fCallCallback = eANI_BOOLEAN_TRUE;
7065 }
7066 }
7067 else
7068 {
7069 //scan for this SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07007070 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007071 if(!HAL_STATUS_SUCCESS(status))
7072 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007073 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07007074 fCallCallback = eANI_BOOLEAN_TRUE;
7075 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007076 else
7077 {
7078 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
7079 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007080 }
7081 }
7082 else
7083 {
7084 fCallCallback = eANI_BOOLEAN_TRUE;
7085 }
7086 } while (0);
7087 if(NULL != pProfile)
7088 {
7089 //we need to free memory for filter if profile exists
7090 csrFreeScanFilter(pMac, pScanFilter);
7091 }
7092 }//Got the scan filter from profile
7093
Kiet Lam64c1b492013-07-12 13:56:44 +05307094 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007095 }//allocated memory for pScanFilter
7096 }//No Bsslist coming in
7097 //tell the caller if we fail to trigger a join request
7098 if( fCallCallback )
7099 {
7100 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
7101 }
7102
7103 return (status);
7104}
Jeff Johnson295189b2012-06-20 16:38:30 -07007105eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
7106 tCsrRoamModifyProfileFields modProfileFields,
7107 tANI_U32 *pRoamId)
7108{
7109 eHalStatus status = eHAL_STATUS_SUCCESS;
7110 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
7111 tANI_U32 roamId = 0;
7112 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007113 if (NULL == pProfile)
7114 {
7115 smsLog(pMac, LOGP, FL("No profile specified"));
7116 return eHAL_STATUS_FAILURE;
7117 }
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05307118 smsLog(pMac, LOG1, FL("called BSSType = %s (%d) authtype = %d "
7119 "encryType = %d"),
7120 lim_BssTypetoString(pProfile->BSSType),
7121 pProfile->BSSType,
7122 pProfile->AuthType.authType[0],
7123 pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007124 csrRoamCancelRoaming(pMac, sessionId);
7125 csrScanRemoveFreshScanCommand(pMac, sessionId);
7126 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05307127 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007128 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07007129 if(csrIsConnStateConnected(pMac, sessionId))
7130 {
7131 if(pProfile)
7132 {
7133 if(pProfile->SSIDs.numOfSSIDs &&
7134 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
7135 {
7136 fCallCallback = eANI_BOOLEAN_FALSE;
7137 }
7138 else
7139 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007140 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007141 }
7142 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307143 else if (!vos_mem_compare(&modProfileFields,
7144 &pSession->connectedProfile.modifyProfileFields,
7145 sizeof(tCsrRoamModifyProfileFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -07007146 {
7147 fCallCallback = eANI_BOOLEAN_FALSE;
7148 }
7149 else
7150 {
7151 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007152 "in tCsrRoamModifyProfileFields got modified"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007153 }
7154 }
7155 else
7156 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007157 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007158 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007159 if(!fCallCallback)
7160 {
7161 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
7162 if(pRoamId)
7163 {
7164 *pRoamId = roamId;
7165 }
7166
Jeff Johnson295189b2012-06-20 16:38:30 -07007167 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
7168 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007169 }
7170 else
7171 {
7172 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
7173 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
7174 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007175 return status;
7176}
Jeff Johnson295189b2012-06-20 16:38:30 -07007177eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
7178{
7179 eHalStatus status = eHAL_STATUS_FAILURE;
7180 tScanResultHandle hBSSList = NULL;
7181 tCsrScanResultFilter *pScanFilter = NULL;
7182 tANI_U32 roamId;
7183 tCsrRoamProfile *pProfile = NULL;
7184 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007185
7186 if(!pSession)
7187 {
7188 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7189 return eHAL_STATUS_FAILURE;
7190 }
7191
Jeff Johnson295189b2012-06-20 16:38:30 -07007192 do
7193 {
7194 if(pSession->pCurRoamProfile)
7195 {
7196 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05307197 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007198 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
Kiet Lam64c1b492013-07-12 13:56:44 +05307199 pProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
7200 if ( NULL == pProfile )
7201 status = eHAL_STATUS_FAILURE;
7202 else
7203 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07007204 if(!HAL_STATUS_SUCCESS(status))
7205 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05307206 vos_mem_set(pProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007207 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05307208 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07007209 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05307210 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
7211 if ( NULL == pScanFilter )
7212 status = eHAL_STATUS_FAILURE;
7213 else
7214 status = eHAL_STATUS_SUCCESS;
7215
Jeff Johnson295189b2012-06-20 16:38:30 -07007216 if(!HAL_STATUS_SUCCESS(status))
7217 {
7218 break;
7219 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307220 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007221 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
7222 if(!HAL_STATUS_SUCCESS(status))
7223 {
7224 break;
7225 }
7226 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
7227 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
7228 if(HAL_STATUS_SUCCESS(status))
7229 {
7230 //we want to put the last connected BSS to the very beginning, if possible
7231 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
7232 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
7233 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
7234 if(!HAL_STATUS_SUCCESS(status))
7235 {
7236 csrScanResultPurge(pMac, hBSSList);
7237 break;
7238 }
7239 }
7240 else
7241 {
7242 //Do a scan on this profile
7243 //scan for this SSID only in case the AP suppresses SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07007244 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007245 if(!HAL_STATUS_SUCCESS(status))
7246 {
7247 break;
7248 }
7249 }
7250 }//We have a profile
7251 else
7252 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007253 smsLog(pMac, LOGW, FL("cannot find a roaming profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007254 break;
7255 }
7256 }while(0);
7257 if(pScanFilter)
7258 {
7259 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05307260 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07007261 }
7262 if(NULL != pProfile)
7263 {
7264 csrReleaseProfile(pMac, pProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05307265 vos_mem_free(pProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07007266 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007267 return (status);
7268}
Jeff Johnson295189b2012-06-20 16:38:30 -07007269eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
7270{
7271 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007272 if(csrIsConnStateConnected(pMac, sessionId))
7273 {
7274 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
7275 if(HAL_STATUS_SUCCESS(status))
7276 {
7277 status = csrRoamJoinLastProfile(pMac, sessionId);
7278 }
7279 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007280 return (status);
7281}
7282
Jeff Johnson295189b2012-06-20 16:38:30 -07007283eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
7284{
7285 eHalStatus status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007286 smsLog(pMac, LOGW, FL("is called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007287 csrRoamCancelRoaming(pMac, sessionId);
7288 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
7289 if(csrIsConnStateDisconnected(pMac, sessionId))
7290 {
7291 status = csrRoamJoinLastProfile(pMac, sessionId);
7292 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007293 return (status);
7294}
7295
Jeff Johnson295189b2012-06-20 16:38:30 -07007296eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
7297{
7298 eHalStatus status = eHAL_STATUS_SUCCESS;
7299 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
7300 eCsrRoamSubState NewSubstate;
7301 tANI_U32 sessionId = pCommand->sessionId;
Abhishek Singhf4669da2014-05-26 15:07:49 +05307302
7303 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7304 {
7305 smsLog(pMac, LOG1, FL(" Stop Wait for key timer and change substate to"
7306 " eCSR_ROAM_SUBSTATE_NONE"));
7307 csrRoamStopWaitForKeyTimer( pMac );
7308 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7309 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007310 // change state to 'Roaming'...
7311 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
7312
7313 if ( csrIsConnStateIbss( pMac, sessionId ) )
7314 {
7315 // If we are in an IBSS, then stop the IBSS...
7316 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
7317 fComplete = (!HAL_STATUS_SUCCESS(status));
7318 }
7319 else if ( csrIsConnStateInfra( pMac, sessionId ) )
7320 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007321 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 -07007322 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
7323 //Restore AC weight in case we change it
7324 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
7325 // in Infrasturcture, we need to disassociate from the Infrastructure network...
7326 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
7327 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
7328 {
7329 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
7330 }
Abhishek Singhcf4590b2014-04-16 18:58:08 +05307331 else
7332 {
7333 // If we are in neighbor preauth done state then on receiving
7334 // disassoc or deauth we dont roam instead we just disassoc
7335 // from current ap and then go to disconnected state
7336 // This happens for ESE and 11r FT connections ONLY.
7337#ifdef WLAN_FEATURE_VOWIFI_11R
7338 if (csrRoamIs11rAssoc(pMac) &&
7339 (csrNeighborRoamStatePreauthDone(pMac)))
7340 {
7341 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7342 }
7343#endif
7344#ifdef FEATURE_WLAN_ESE
7345 if (csrRoamIsESEAssoc(pMac) &&
7346 (csrNeighborRoamStatePreauthDone(pMac)))
7347 {
7348 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7349 }
7350#endif
7351#ifdef FEATURE_WLAN_LFR
7352 if (csrRoamIsFastRoamEnabled(pMac, sessionId) &&
7353 (csrNeighborRoamStatePreauthDone(pMac)))
7354 {
7355 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7356 }
7357#endif
7358 }
7359
Jeff Johnson295189b2012-06-20 16:38:30 -07007360 if( fDisassoc )
7361 {
7362 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
Girish Gowli1c2fc802015-01-19 16:18:07 +05307363 if (pMac->roam.configParam.roamDelayStatsEnabled)
7364 {
7365 vos_record_roam_event(e_SME_DISASSOC_ISSUE, NULL, 0);
7366 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007367 }
7368 else
7369 {
7370 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
7371 }
7372 fComplete = (!HAL_STATUS_SUCCESS(status));
7373 }
7374 else if ( csrIsConnStateWds( pMac, sessionId ) )
7375 {
7376 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
7377 {
7378 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
7379 fComplete = (!HAL_STATUS_SUCCESS(status));
7380 }
7381 //This has to be WDS station
7382 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
7383 {
7384
7385 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7386 if( fDisassoc )
7387 {
7388 status = csrRoamIssueDisassociate( pMac, sessionId,
7389 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
7390 fComplete = (!HAL_STATUS_SUCCESS(status));
7391 }
7392 }
7393 } else {
7394 // we got a dis-assoc request while not connected to any peer
7395 // just complete the command
7396 fComplete = eANI_BOOLEAN_TRUE;
7397 status = eHAL_STATUS_FAILURE;
7398 }
7399 if(fComplete)
7400 {
7401 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7402 }
7403
7404 if(HAL_STATUS_SUCCESS(status))
7405 {
7406 if ( csrIsConnStateInfra( pMac, sessionId ) )
7407 {
7408 //Set the state to disconnect here
7409 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
Mukul Sharmac353a5b2015-01-16 20:49:12 +05307410#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
7411 //we don't need to run this timer any more
7412 if (VOS_TIMER_STATE_RUNNING ==
7413 pMac->roam.neighborRoamInfo.forcedInitialRoamTo5GHTimer.state)
7414 {
7415 status = vos_timer_stop(&pMac->roam.neighborRoamInfo.forcedInitialRoamTo5GHTimer);
7416 if (status != eHAL_STATUS_SUCCESS)
7417 smsLog(pMac, LOGE, FL("Failed to Stop Forced 5G timer"));
7418 }
7419#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007420 }
7421 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007422 else
7423 {
7424 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
7425 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007426 return (status);
7427}
7428
Jeff Johnson295189b2012-06-20 16:38:30 -07007429/* This is been removed from latest code base */
7430/*
7431static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
7432{
7433 eHalStatus status;
7434 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007435 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
7436 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007437 return ( status );
7438}
7439*/
7440
Jeff Johnson295189b2012-06-20 16:38:30 -07007441eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
7442{
7443 eHalStatus status = eHAL_STATUS_SUCCESS;
7444 tSmeCmd *pCommand;
Abhishek Singhb08e1962015-10-27 13:51:21 +05307445
Jeff Johnson295189b2012-06-20 16:38:30 -07007446 do
7447 {
Jeff Johnson295189b2012-06-20 16:38:30 -07007448 pCommand = csrGetCommandBuffer( pMac );
7449 if ( !pCommand )
7450 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007451 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007452 status = eHAL_STATUS_RESOURCES;
7453 break;
7454 }
7455 //Change the substate in case it is wait-for-key
7456 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7457 {
7458 csrRoamStopWaitForKeyTimer( pMac );
7459 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7460 }
7461 pCommand->command = eSmeCommandRoam;
7462 pCommand->sessionId = (tANI_U8)sessionId;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05307463 smsLog( pMac, LOG1, FL("Disassociate reason: %d, sessionId: %d"),
7464 reason,sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007465 switch ( reason )
7466 {
7467 case eCSR_DISCONNECT_REASON_MIC_ERROR:
7468 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
7469 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007470 case eCSR_DISCONNECT_REASON_DEAUTH:
7471 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
7472 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007473 case eCSR_DISCONNECT_REASON_HANDOFF:
Jeff Johnson295189b2012-06-20 16:38:30 -07007474 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
7475 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007476 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
7477 case eCSR_DISCONNECT_REASON_DISASSOC:
7478 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
7479 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007480 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
7481 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
7482 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007483 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
7484 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
7485 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007486 default:
7487 break;
7488 }
Abhishek Singhb08e1962015-10-27 13:51:21 +05307489 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007490 if( !HAL_STATUS_SUCCESS( status ) )
7491 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007492 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007493 csrReleaseCommandRoam( pMac, pCommand );
7494 }
7495 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07007496 return( status );
7497}
7498
Jeff Johnson295189b2012-06-20 16:38:30 -07007499eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
7500{
7501 eHalStatus status = eHAL_STATUS_SUCCESS;
7502 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007503 pCommand = csrGetCommandBuffer( pMac );
7504 if ( NULL != pCommand )
7505 {
7506 //Change the substate in case it is wait-for-key
7507 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
7508 {
7509 csrRoamStopWaitForKeyTimer( pMac );
7510 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7511 }
7512 pCommand->command = eSmeCommandRoam;
7513 pCommand->sessionId = (tANI_U8)sessionId;
7514 pCommand->u.roamCmd.roamReason = eCsrStopBss;
7515 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7516 if( !HAL_STATUS_SUCCESS( status ) )
7517 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007518 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007519 csrReleaseCommandRoam( pMac, pCommand );
7520 }
7521 }
7522 else
7523 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007524 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007525 status = eHAL_STATUS_RESOURCES;
7526 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007527 return ( status );
7528}
7529
Jeff Johnson295189b2012-06-20 16:38:30 -07007530eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7531{
7532 eHalStatus status = eHAL_STATUS_SUCCESS;
7533 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007534
7535 if(!pSession)
7536 {
7537 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7538 return eHAL_STATUS_FAILURE;
7539 }
7540
Jeff Johnson295189b2012-06-20 16:38:30 -07007541#ifdef FEATURE_WLAN_BTAMP_UT_RF
7542 //Stop te retry
7543 pSession->maxRetryCount = 0;
7544 csrRoamStopJoinRetryTimer(pMac, sessionId);
7545#endif
7546 //Not to call cancel roaming here
7547 //Only issue disconnect when necessary
7548 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
7549 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
7550 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
7551
7552 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007553 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007554 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
7555 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307556 else
7557 {
Abhishek Singh7b52ed52016-02-11 17:45:54 +05307558 pMac->roam.roamSession[sessionId].connectState =
7559 eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTING;
Abhishek Singhdc2bfd42014-06-19 17:59:05 +05307560 csrScanAbortScanForSSID(pMac, sessionId);
7561 status = eHAL_STATUS_CMD_NOT_QUEUED;
Abhishek Singh7f775f82015-12-17 15:23:52 +05307562 smsLog(pMac, LOGE,
7563 FL("Disconnect not queued, Abort Scan for SSID"));
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307564 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007565 return (status);
7566}
7567
Jeff Johnson295189b2012-06-20 16:38:30 -07007568eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7569{
7570 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007571
7572 if(!pSession)
7573 {
7574 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7575 return eHAL_STATUS_FAILURE;
7576 }
7577
Jeff Johnson295189b2012-06-20 16:38:30 -07007578 csrRoamCancelRoaming(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007579 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
7580
7581 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
7582}
7583
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307584void csr_abortConnection(tpAniSirGlobal pMac, tANI_U32 sessionId)
7585{
7586 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7587 if(!pSession)
7588 {
7589 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7590 return;
7591 }
7592 pSession->abortConnection = TRUE;
7593 return;
7594}
7595
Jeff Johnson295189b2012-06-20 16:38:30 -07007596eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
7597 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
7598{
7599 eHalStatus status = eHAL_STATUS_SUCCESS;
7600 tDot11fBeaconIEs *pIesTemp = pIes;
7601 tANI_U8 index;
7602 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7603 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007604
7605 if(!pSession)
7606 {
7607 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7608 return eHAL_STATUS_FAILURE;
7609 }
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007610 if(pConnectProfile->pAddIEAssoc)
7611 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307612 vos_mem_free(pConnectProfile->pAddIEAssoc);
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007613 pConnectProfile->pAddIEAssoc = NULL;
7614 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307615 vos_mem_set(&pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007616 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
7617 pConnectProfile->AuthInfo = pProfile->AuthType;
7618 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
7619 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
7620 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
7621 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
7622 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
7623 pConnectProfile->BSSType = pProfile->BSSType;
7624 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
7625 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07007626 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
AnjaneeDevi Kapparapu4b043912014-02-18 13:22:35 +05307627 if (!pConnectProfile->beaconInterval)
7628 {
7629 smsLog(pMac, LOGW, FL("ERROR: Beacon interval is ZERO"));
7630 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307631 vos_mem_copy(&pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007632 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
7633 if(pProfile->nAddIEAssocLength)
7634 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307635 pConnectProfile->pAddIEAssoc = vos_mem_malloc(pProfile->nAddIEAssocLength);
7636 if ( NULL == pConnectProfile->pAddIEAssoc )
7637 status = eHAL_STATUS_FAILURE;
7638 else
7639 status = eHAL_STATUS_SUCCESS;
7640 if (!HAL_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007641 {
7642 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
7643 return eHAL_STATUS_FAILURE;
7644 }
7645 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05307646 vos_mem_copy(pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
7647 pProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007648 }
Abhishek Singh2fb3a6e2014-11-20 16:03:01 +05307649
7650#ifdef WLAN_FEATURE_11W
7651 pConnectProfile->MFPEnabled = pProfile->MFPEnabled;
7652 pConnectProfile->MFPRequired = pProfile->MFPRequired;
7653 pConnectProfile->MFPCapable = pProfile->MFPCapable;
7654#endif
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007655
Jeff Johnson295189b2012-06-20 16:38:30 -07007656 //Save bssid
7657 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
7658#ifdef WLAN_FEATURE_VOWIFI_11R
7659 if (pSirBssDesc->mdiePresent)
7660 {
7661 pConnectProfile->MDID.mdiePresent = 1;
7662 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
7663 }
7664#endif
Leela Venkata Kiran Kumar Reddy Chiralad48e3272013-04-12 14:21:07 -07007665 if( NULL == pIesTemp )
7666 {
7667 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
7668 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007669#ifdef FEATURE_WLAN_ESE
7670 if ((csrIsProfileESE(pProfile) ||
7671 ((pIesTemp->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +05307672 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
7673 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
7674 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
7675 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
7676#ifdef WLAN_FEATURE_11W
7677 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
Abhishek Singh83080e02014-11-07 12:04:16 +05307678 || (pProfile->negotiatedAuthType ==
7679 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
Sachin Ahuja23ff1192014-10-06 22:02:45 +05307680#endif
7681 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007682 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07007683 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007684 pConnectProfile->isESEAssoc = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007685 }
7686#endif
7687 //save ssid
Jeff Johnson295189b2012-06-20 16:38:30 -07007688 if(HAL_STATUS_SUCCESS(status))
7689 {
7690 if(pIesTemp->SSID.present)
7691 {
7692 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +05307693 vos_mem_copy(pConnectProfile->SSID.ssId, pIesTemp->SSID.ssid,
7694 pIesTemp->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07007695 }
7696
7697 //Save the bss desc
7698 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307699
7700 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07007701 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307702 //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 -07007703 pConnectProfile->qap = TRUE;
7704 }
7705 else
7706 {
7707 pConnectProfile->qap = FALSE;
7708 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007709 if ( NULL == pIes )
7710 {
7711 //Free memory if it allocated locally
Kiet Lam64c1b492013-07-12 13:56:44 +05307712 vos_mem_free(pIesTemp);
Jeff Johnson295189b2012-06-20 16:38:30 -07007713 }
7714 }
7715 //Save Qos connection
7716 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
7717
7718 if(!HAL_STATUS_SUCCESS(status))
7719 {
7720 csrFreeConnectBssDesc(pMac, sessionId);
7721 }
7722 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
7723 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307724 if ((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
7725 vos_mem_compare(pProfile->SSIDs.SSIDList[index].SSID.ssId,
7726 pConnectProfile->SSID.ssId,
7727 pConnectProfile->SSID.length))
Jeff Johnson295189b2012-06-20 16:38:30 -07007728 {
7729 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
7730 break;
7731 }
7732 pConnectProfile->handoffPermitted = FALSE;
7733 }
7734
7735 return (status);
7736}
7737
Jeff Johnson295189b2012-06-20 16:38:30 -07007738static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
7739{
7740 tListElem *pEntry = NULL;
7741 tSmeCmd *pCommand = NULL;
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307742 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007743 //The head of the active list is the request we sent
7744 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7745 if(pEntry)
7746 {
7747 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7748 }
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307749 pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007750 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7751 {
7752 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
7753 {
7754#ifndef WLAN_MDM_CODE_REDUCTION_OPT
7755 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7756#endif
7757 }
7758 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307759 if(!pSession)
7760 {
7761 smsLog(pMac, LOGE, FL(" session %d not found "),
7762 pSmeJoinRsp->sessionId);
7763 return;
7764 }
7765 pSession->abortConnection = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007766 }
7767 else
7768 {
7769 tANI_U32 roamId = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007770 if(!pSession)
7771 {
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307772 smsLog(pMac, LOGE, FL(" session %d not found "),
7773 pSmeJoinRsp->sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07007774 return;
7775 }
Sushant Kaushikb4834d22015-07-15 15:29:05 +05307776 if (pSession->abortConnection)
7777 {
7778 smsLog(pMac, LOG1, FL("Disconnection in progess"
7779 "abort Join request"));
7780 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7781 pSession->abortConnection = FALSE;
7782 return;
7783 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007784 //The head of the active list is the request we sent
7785 //Try to get back the same profile and roam again
7786 if(pCommand)
7787 {
7788 roamId = pCommand->u.roamCmd.roamId;
7789 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007790 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
7791 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007792 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007793#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7794 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
7795 if (csrRoamIsHandoffInProgress(pMac))
7796 {
7797 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
7798 /* Should indicate neighbor roam algorithm about the connect failure here */
7799 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
7800 }
7801#endif
7802 if (pCommand)
7803 {
7804 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
7805 {
7806 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7807 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
7808 csrRoamReissueRoamCommand(pMac);
7809 }
7810 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
7811 {
7812 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7813 }
7814 else
7815 {
7816 csrRoam(pMac, pCommand);
7817 }
7818 }
7819 else
7820 {
7821 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7822 }
7823 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
7824}
7825
Jeff Johnson295189b2012-06-20 16:38:30 -07007826eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7827 tDot11fBeaconIEs *pIes,
7828 tCsrRoamProfile *pProfile, tANI_U32 roamId )
7829{
7830 eHalStatus status;
Arif Hussain24bafea2013-11-15 15:10:03 -08007831 smsLog( pMac, LOG1, "Attempting to Join Bssid= "MAC_ADDRESS_STR,
7832 MAC_ADDR_ARRAY(pSirBssDesc->bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07007833
7834 // Set the roaming substate to 'join attempt'...
7835 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007836 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007837 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007838 return (status);
7839}
7840
Jeff Johnson295189b2012-06-20 16:38:30 -07007841static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7842 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
7843{
7844 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007845 // Set the roaming substate to 'join attempt'...
7846 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
7847
Kaushik, Sushant8489f472014-01-27 11:41:22 +05307848 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7849 FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)"));
Girish Gowli1c2fc802015-01-19 16:18:07 +05307850 if (pMac->roam.configParam.roamDelayStatsEnabled)
7851 {
7852 vos_record_roam_event(e_SME_ISSUE_REASSOC_REQ, NULL, pProfile->negotiatedAuthType);
7853 vos_record_roam_event(e_CACHE_ROAM_PEER_MAC, (void *)pSirBssDesc->bssId, 6);
7854 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007855 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007856 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07007857}
7858
Jeff Johnson295189b2012-06-20 16:38:30 -07007859void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
7860{
7861 tListElem *pEntry;
7862 tSmeCmd *pCommand;
7863 tCsrRoamInfo roamInfo;
7864 tANI_U32 sessionId;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05307865 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007866
7867 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7868 if(pEntry)
7869 {
7870 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7871 if ( eSmeCommandRoam == pCommand->command )
7872 {
7873 sessionId = pCommand->sessionId;
7874 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007875
7876 if(!pSession)
7877 {
7878 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7879 return;
7880 }
Abhishek Singhaf15f152013-11-30 16:08:55 +05307881 /* While switching between two AP, csr will reissue roam command again
7882 to the nextbss if it was interrupted by the dissconnect req for the
7883 previous bss.During this csr is incrementing bRefAssocStartCnt twice.
7884 so reset the bRefAssocStartCnt.
7885 */
7886 if(pSession->bRefAssocStartCnt > 0)
7887 {
7888 pSession->bRefAssocStartCnt--;
7889 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007890 if( pCommand->u.roamCmd.fStopWds )
7891 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307892 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007893 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
7894 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
7895 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007896 if (CSR_IS_WDS(&pSession->connectedProfile)){
Jeff Johnson295189b2012-06-20 16:38:30 -07007897 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
7898 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7899 eCSR_ROAM_WDS_IND,
7900 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
Jeff Johnson295189b2012-06-20 16:38:30 -07007901 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
7902 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
7903 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7904 eCSR_ROAM_INFRA_IND,
7905 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
7906 }
7907
Jeff Johnson295189b2012-06-20 16:38:30 -07007908
Jeff Johnson295189b2012-06-20 16:38:30 -07007909 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
7910 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007911 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007912 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7913 }
7914 }
7915 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
7916 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007917 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007918 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7919 }
7920 }
7921 else
7922 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007923 smsLog(pMac, LOGW, " Command is not roaming after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007924 }
7925 }
7926 else
7927 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007928 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available");
Jeff Johnson295189b2012-06-20 16:38:30 -07007929 }
7930}
7931
Jeff Johnson295189b2012-06-20 16:38:30 -07007932tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
7933{
7934 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7935 tListElem *pEntry;
7936 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007937 //alwasy lock active list before locking pending list
7938 csrLLLock( &pMac->sme.smeCmdActiveList );
7939 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7940 if(pEntry)
7941 {
7942 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7943 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7944 {
7945 fRet = eANI_BOOLEAN_TRUE;
7946 }
7947 }
7948 if(eANI_BOOLEAN_FALSE == fRet)
7949 {
7950 csrLLLock(&pMac->sme.smeCmdPendingList);
7951 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
7952 while(pEntry)
7953 {
7954 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7955 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7956 {
7957 fRet = eANI_BOOLEAN_TRUE;
7958 break;
7959 }
7960 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7961 }
7962 csrLLUnlock(&pMac->sme.smeCmdPendingList);
7963 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307964 if (eANI_BOOLEAN_FALSE == fRet)
7965 {
7966 csrLLLock(&pMac->roam.roamCmdPendingList);
7967 pEntry = csrLLPeekHead(&pMac->roam.roamCmdPendingList, LL_ACCESS_NOLOCK);
7968 while (pEntry)
7969 {
7970 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7971 if (( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7972 {
7973 fRet = eANI_BOOLEAN_TRUE;
7974 break;
7975 }
7976 pEntry = csrLLNext(&pMac->roam.roamCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7977 }
7978 csrLLUnlock(&pMac->roam.roamCmdPendingList);
7979 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007980 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007981 return (fRet);
7982}
7983
Jeff Johnson295189b2012-06-20 16:38:30 -07007984tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
7985{
7986 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7987 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07007988 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
7989 {
7990 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
7991 {
7992 break;
7993 }
7994 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007995 return ( fRet );
7996}
7997
Jeff Johnson295189b2012-06-20 16:38:30 -07007998tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
7999{
8000 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008001 //alwasy lock active list before locking pending list
8002 csrLLLock( &pMac->sme.smeCmdActiveList );
8003 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
8004 if(eANI_BOOLEAN_FALSE == fRet)
8005 {
8006 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
8007 }
8008 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07008009 return (fRet);
8010}
8011
Jeff Johnson295189b2012-06-20 16:38:30 -07008012tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
8013{
8014 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
8015 tListElem *pEntry;
8016 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008017 //alwasy lock active list before locking pending list
8018 csrLLLock( &pMac->sme.smeCmdActiveList );
8019 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
8020 if( pEntry )
8021 {
8022 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
8023 if( ( eCsrRoamCommandScan == pCommand->command ) &&
8024 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
8025 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
8026 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
8027 {
8028 fRet = eANI_BOOLEAN_TRUE;
8029 }
8030 }
8031 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07008032 return (fRet);
8033}
Jeff Johnson295189b2012-06-20 16:38:30 -07008034eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
8035{
8036 eHalStatus status = eHAL_STATUS_SUCCESS;
8037 tSmeCmd *pCommand = NULL;
8038 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
8039 tANI_BOOLEAN fRemoveCmd = FALSE;
8040 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07008041 // Delete the old assoc command. All is setup for reassoc to be serialized
8042 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
8043 if ( pEntry )
8044 {
8045 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
8046 if ( !pCommand )
8047 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008048 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008049 return eHAL_STATUS_RESOURCES;
8050 }
8051 if ( eSmeCommandRoam == pCommand->command )
8052 {
8053 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
8054 {
8055 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
8056 }
8057 else
8058 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008059 smsLog( pMac, LOGE, FL(" Unexpected active roam command present ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008060 }
8061 if (fRemoveCmd == FALSE)
8062 {
8063 // Implies we did not get the serialized assoc command we
8064 // were expecting
8065 pCommand = NULL;
8066 }
8067 }
8068 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008069 if(NULL == pCommand)
8070 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008071 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008072 return eHAL_STATUS_RESOURCES;
8073 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008074 do
8075 {
8076 //Change the substate in case it is wait-for-key
8077 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8078 {
8079 csrRoamStopWaitForKeyTimer( pMac );
8080 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
8081 }
8082 pCommand->command = eSmeCommandRoam;
8083 pCommand->sessionId = (tANI_U8)sessionId;
8084 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07008085 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
8086 if( !HAL_STATUS_SUCCESS( status ) )
8087 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008088 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008089 csrReleaseCommandRoam( pMac, pCommand );
8090 }
8091 } while( 0 );
8092
Jeff Johnson295189b2012-06-20 16:38:30 -07008093 return( status );
8094}
8095static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
8096{
8097 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
8098 tCsrScanResult *pScanResult = NULL;
8099 tSirBssDescription *pBssDesc = NULL;
8100 tSmeCmd *pCommand = NULL;
8101 tANI_U32 sessionId;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05308102 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008103 if(NULL == pEntry)
8104 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05308105 smsLog(pMac, LOGE, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07008106 return;
8107 }
8108 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
8109 sessionId = pCommand->sessionId;
8110 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008111
8112 if(!pSession)
8113 {
8114 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8115 return;
8116 }
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308117 smsLog(pMac, LOG1, FL("CFG return value is %d "
8118 " current state is : %d substate is : %d "),
8119 result, pMac->roam.curState[sessionId],
8120 pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008121 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
8122 {
8123 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008124 smsLog(pMac, LOGW, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008125 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
8126 }
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07008127 /* If the roaming has stopped, not to continue the roaming command*/
8128 else if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
8129 {
8130 //No need to complete roaming here as it already completes
8131 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed\n"),
8132 pCommand->u.roamCmd.roamReason);
8133 csrSetAbortRoamingCommand( pMac, pCommand );
8134 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
8135 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008136 else
8137 {
8138 if ( CCM_IS_RESULT_SUCCESS(result) )
8139 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308140 smsLog(pMac, LOG1, "Cfg sequence complete");
Jeff Johnson295189b2012-06-20 16:38:30 -07008141 // Successfully set the configuration parameters for the new Bss. Attempt to
8142 // join the roaming Bss.
8143 if(pCommand->u.roamCmd.pRoamBssEntry)
8144 {
8145 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
8146 pBssDesc = &pScanResult->Result.BssDescriptor;
8147 }
8148 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
8149 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07008150 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07008151 )
8152 {
8153 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
8154 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
8155 pBssDesc, pCommand->u.roamCmd.roamId )))
8156 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05308157 smsLog(pMac, LOGE, " CSR start BSS failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07008158 //We need to complete the command
8159 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
8160 }
8161 }
8162 else
8163 {
8164 if (!pCommand->u.roamCmd.pRoamBssEntry)
8165 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05308166 smsLog(pMac, LOGE, " pRoamBssEntry is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07008167 //We need to complete the command
8168 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
8169 return;
8170 }
8171 // If we are roaming TO an Infrastructure BSS...
8172 VOS_ASSERT(pScanResult != NULL);
8173 if ( csrIsInfraBssDesc( pBssDesc ) )
8174 {
8175 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308176 smsLog(pMac, LOG1, " Roaming in a Infra BSS");
Jeff Johnson295189b2012-06-20 16:38:30 -07008177 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
8178 {
8179 // ..and currently in an Infrastructure connection....
8180 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
8181 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308182 smsLog(pMac, LOG1, " Connected to infra BSS");
Jeff Johnson295189b2012-06-20 16:38:30 -07008183 // ...and the SSIDs are equal, then we Reassoc.
8184 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
8185 pIesLocal ) )
8186 // ..and currently in an infrastructure connection
8187 {
8188 // then issue a Reassoc.
8189 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
8190 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
8191 &pCommand->u.roamCmd.roamProfile );
8192 }
8193 else
8194 {
8195
8196 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
8197 // previously associated AP.
8198 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
8199 pIesLocal,
8200 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
8201 {
8202 //try something else
8203 csrRoam( pMac, pCommand );
8204 }
8205 }
8206 }
8207 else
8208 {
8209 eHalStatus status = eHAL_STATUS_SUCCESS;
8210
8211 /* We need to come with other way to figure out that this is because of HO in BMP
8212 The below API will be only available for Android as it uses a different HO algorithm */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008213 /* Reassoc request will be used only for ESE and 11r handoff whereas other legacy roaming should
Jeff Johnson295189b2012-06-20 16:38:30 -07008214 * use join request */
8215#ifdef WLAN_FEATURE_VOWIFI_11R
8216 if (csrRoamIsHandoffInProgress(pMac) &&
8217 csrRoamIs11rAssoc(pMac))
8218 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308219 smsLog(pMac, LOG1, " HandoffInProgress with 11r enabled");
Jeff Johnson295189b2012-06-20 16:38:30 -07008220 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
8221 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
8222 }
8223 else
8224#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008225#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008226 if (csrRoamIsHandoffInProgress(pMac) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008227 csrRoamIsESEAssoc(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07008228 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308229 smsLog(pMac, LOG1, " HandoffInProgress with ESE enabled");
Jeff Johnson295189b2012-06-20 16:38:30 -07008230 // Now serialize the reassoc command.
8231 status = csrRoamIssueReassociateCmd(pMac, sessionId);
8232 }
8233 else
8234#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008235#ifdef FEATURE_WLAN_LFR
8236 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05308237 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008238 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308239 smsLog(pMac, LOG1, " HandoffInProgress with LFR enabled");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07008240 // Now serialize the reassoc command.
8241 status = csrRoamIssueReassociateCmd(pMac, sessionId);
8242 }
8243 else
8244#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008245 // else we are not connected and attempting to Join. Issue the
8246 // Join request.
8247 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05308248 smsLog(pMac, LOG1, " Not connected, Attempting to Join");
Jeff Johnson295189b2012-06-20 16:38:30 -07008249 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
8250 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
8251 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
8252 }
8253 if(!HAL_STATUS_SUCCESS(status))
8254 {
8255 //try something else
8256 csrRoam( pMac, pCommand );
8257 }
8258 }
8259 if( !pScanResult->Result.pvIes )
8260 {
8261 //Locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05308262 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07008263 }
8264 }
8265 }//if ( csrIsInfraBssDesc( pBssDesc ) )
8266 else
8267 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008268 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008269 }
8270 }//else
8271 }//if ( WNI_CFG_SUCCESS == result )
8272 else
8273 {
8274 // In the event the configuration failed, for infra let the roam processor
8275 //attempt to join something else...
8276 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
8277 {
8278 csrRoam(pMac, pCommand);
8279 }
8280 else
8281 {
8282 //We need to complete the command
8283 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
8284 {
8285 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
8286 }
8287 else
8288 {
8289 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8290 }
8291 }
8292 }
8293 }//we have active entry
8294}
8295
Jeff Johnson295189b2012-06-20 16:38:30 -07008296static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
8297{
Jeff Johnson295189b2012-06-20 16:38:30 -07008298 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
8299 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008300 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008301 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
8302 // join the new one...
8303 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07008304 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
8305 }
8306 else {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008307 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08X [%d]", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008308 /***profHandleLostLinkAfterReset(pAdapter);
8309 // In the event the authenticate fails, let the roam processor attempt to join something else...
8310 roamRoam( pAdapter );***/
8311 }
8312}
8313
Jeff Johnson295189b2012-06-20 16:38:30 -07008314static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
8315{
8316 eCsrRoamCompleteResult result;
8317 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
8318 tCsrRoamInfo roamInfo;
8319 tANI_U32 roamId = 0;
Kapil Gupta04ab1992016-06-26 13:36:51 +05308320 tANI_U32 current_timestamp, max_time = -1;
8321 tANI_U32 candidateApCnt, oldestIndex;
8322 tANI_U8 nilMac[6] = {0};
8323
8324 if (eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode)
Jeff Johnson295189b2012-06-20 16:38:30 -07008325 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008326 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008327 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07008328 /* Defeaturize this part later if needed */
8329#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
8330 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
8331 * we need the response contents while processing the result in csrRoamProcessResults() */
8332 if (csrRoamIsHandoffInProgress(pMac))
8333 {
8334 /* Need to dig more on indicating events to SME QoS module */
8335 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
8336 csrRoamComplete( pMac, result, pSmeJoinRsp);
Kapil Gupta04ab1992016-06-26 13:36:51 +05308337#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
8338 /* Add previous BSSID to blacklist ; this will be in blacklised for
8339 * some period and score of this AP will be reduced if black listed
8340 * to avoid ping pong */
8341 if (pMac->PERroamCandidatesCnt)
8342 {
8343 current_timestamp = jiffies_to_msecs(jiffies);
8344 for (candidateApCnt = 0; candidateApCnt <
8345 SIR_PER_ROAM_MAX_CANDIDATE_CNT; candidateApCnt++)
8346 {
8347 /* Find one blank entry */
8348 if (sirCompareMacAddr(nilMac,
8349 pMac->previousRoamApInfo[candidateApCnt].bssAddr))
8350 {
8351 vos_mem_copy(pMac->previousRoamApInfo[candidateApCnt].
8352 bssAddr,
8353 pNeighborRoamInfo->prevConnProfile.bssid,
8354 sizeof(tSirMacAddr));
8355 pMac->previousRoamApInfo[candidateApCnt].timeStamp =
8356 current_timestamp;
8357 smsLog(pMac, LOG1, FL("added bssid=" MAC_ADDRESS_STR " at index %d"),
8358 MAC_ADDR_ARRAY(
8359 pNeighborRoamInfo->prevConnProfile.bssid),
8360 candidateApCnt);
8361 break;
8362 }
8363 /* if already in the list */
8364 if (sirCompareMacAddr(pMac->previousRoamApInfo
8365 [candidateApCnt].bssAddr,
8366 pNeighborRoamInfo->prevConnProfile.bssid) &&
8367 ((current_timestamp -
8368 pMac->previousRoamApInfo[candidateApCnt].timeStamp) >
8369 pMac->PERroamTimeout))
8370 {
8371 vos_mem_copy(pMac->previousRoamApInfo[candidateApCnt].
8372 bssAddr,
8373 pNeighborRoamInfo->prevConnProfile.bssid,
8374 sizeof(tSirMacAddr));
8375 pMac->previousRoamApInfo[candidateApCnt].timeStamp =
8376 current_timestamp;
8377 break;
8378 } else
8379 {
8380 /* find oldest BSSID entry in the blacklist */
8381 if (max_time <
8382 pMac->previousRoamApInfo[candidateApCnt].timeStamp)
8383 {
8384 max_time =
8385 pMac->previousRoamApInfo[candidateApCnt].timeStamp;
8386 oldestIndex = candidateApCnt;
8387 }
8388 }
8389 }
8390 if (candidateApCnt == SIR_PER_ROAM_MAX_CANDIDATE_CNT)
8391 {
8392 smsLog(pMac, LOGW,
8393 "%s: Clearing out oldest roam results bssid="
8394 MAC_ADDRESS_STR,
8395 __func__,
8396 MAC_ADDR_ARRAY(pMac->previousRoamApInfo[oldestIndex].bssAddr));
8397 pMac->previousRoamApInfo[oldestIndex].timeStamp = current_timestamp;
8398 vos_mem_copy(pMac->previousRoamApInfo[oldestIndex].bssAddr,
8399 pNeighborRoamInfo->prevConnProfile.bssid,
8400 sizeof(tSirMacAddr));
8401 }
8402 }
8403#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008404 }
8405 else
8406#endif
8407 {
8408 csrRoamComplete( pMac, result, NULL );
8409 }
8410 }
8411 /* Should we handle this similar to handling the join failure? Is it ok
8412 * to call csrRoamComplete() with state as CsrJoinFailure */
8413 else
8414 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008415 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008416 result = eCsrReassocFailure;
Abhishek Singh837adf22015-10-01 17:37:37 +05308417 vos_fatal_event_logs_req(WLAN_LOG_TYPE_FATAL,
8418 WLAN_LOG_INDICATOR_HOST_DRIVER,
8419 WLAN_LOG_REASON_ROAM_FAIL,
8420 FALSE, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008421#ifdef WLAN_FEATURE_VOWIFI_11R
8422 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
Mukul Sharmaa052e3d2014-09-08 23:47:06 +05308423 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode) ||
8424 (eSIR_SME_JOIN_DEAUTH_FROM_AP_DURING_ADD_STA == pSmeJoinRsp->statusCode))
Jeff Johnson295189b2012-06-20 16:38:30 -07008425 {
8426 // Inform HDD to turn off FT flag in HDD
8427 if (pNeighborRoamInfo)
8428 {
8429 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
8430 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
8431 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07008432 /*
8433 * Since the above callback sends a disconnect
8434 * to HDD, we should clean-up our state
8435 * machine as well to be in sync with the upper
8436 * layers. There is no need to send a disassoc
8437 * since: 1) we will never reassoc to the current
8438 * AP in LFR, and 2) there is no need to issue a
8439 * disassoc to the AP with which we were trying
8440 * to reassoc.
8441 */
8442 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8443 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07008444 }
8445 }
8446#endif
8447 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
8448 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
8449 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
8450 //The disassoc rsp message will remove the command from active list
8451 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
8452 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
8453 {
8454 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8455 }
8456 }
8457}
8458
Jeff Johnson295189b2012-06-20 16:38:30 -07008459static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
8460{
Jeff Johnson295189b2012-06-20 16:38:30 -07008461#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8462 {
8463 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07008464 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
8465 if(pIbssLog)
8466 {
8467 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
8468 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
8469 {
8470 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
8471 }
8472 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
8473 }
8474 }
8475#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008476 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8477 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
8478 {
8479 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8480 }
8481 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
8482 {
8483 csrRoamReissueRoamCommand(pMac);
8484 }
8485}
8486
Jeff Johnson295189b2012-06-20 16:38:30 -07008487void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
8488{
8489 tSirResultCodes statusCode;
8490#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
8491 tScanResultHandle hBSSList;
8492 tANI_BOOLEAN fCallCallback, fRemoveCmd;
8493 eHalStatus status;
8494 tCsrRoamInfo roamInfo;
8495 tCsrScanResultFilter *pScanFilter = NULL;
8496 tANI_U32 roamId = 0;
8497 tCsrRoamProfile *pCurRoamProfile = NULL;
8498 tListElem *pEntry = NULL;
8499 tSmeCmd *pCommand = NULL;
8500#endif
8501 tANI_U32 sessionId;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05308502 tCsrRoamSession *pSession = NULL;
Jeff Johnsone7245742012-09-05 17:12:55 -07008503
Jeff Johnson295189b2012-06-20 16:38:30 -07008504 tSirSmeDisassocRsp SmeDisassocRsp;
8505
8506 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
8507 sessionId = SmeDisassocRsp.sessionId;
8508 statusCode = SmeDisassocRsp.statusCode;
8509
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008510 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008511
8512 if ( csrIsConnStateInfra( pMac, sessionId ) )
8513 {
8514 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8515 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008516 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008517
8518 if(!pSession)
8519 {
8520 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8521 return;
8522 }
8523
Jeff Johnson295189b2012-06-20 16:38:30 -07008524 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
8525 {
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05308526 smsLog( pMac, LOG2, "***eCsrNothingToJoin***");
Jeff Johnson295189b2012-06-20 16:38:30 -07008527 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8528 }
8529 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
8530 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
8531 {
8532 if ( eSIR_SME_SUCCESS == statusCode )
8533 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008534 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008535 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
8536 }
8537 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8538 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008539 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
8540 {
Kaushik, Sushant8489f472014-01-27 11:41:22 +05308541 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH,
8542 "CSR SmeDisassocReq due to HO on session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07008543#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008544 /*
8545 * First ensure if the roam profile is in the scan cache.
8546 * If not, post a reassoc failure and disconnect.
8547 */
Kiet Lam64c1b492013-07-12 13:56:44 +05308548 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
8549 if ( NULL == pScanFilter )
8550 status = eHAL_STATUS_FAILURE;
8551 else
8552 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008553 if(HAL_STATUS_SUCCESS(status))
8554 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308555 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008556 status = csrRoamPrepareFilterFromProfile(pMac,
8557 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
8558 if(!HAL_STATUS_SUCCESS(status))
8559 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008560 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008561 __func__, status);
8562 goto POST_ROAM_FAILURE;
8563 }
8564 else
8565 {
8566 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
8567 if (!HAL_STATUS_SUCCESS(status))
8568 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008569 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008570 __func__, status);
8571 goto POST_ROAM_FAILURE;
8572 }
8573 }
8574 }
8575 else
8576 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008577 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008578 __func__, status);
8579 goto POST_ROAM_FAILURE;
8580 }
8581
8582 /*
8583 * After ensuring that the roam profile is in the scan result list,
8584 * dequeue the command from the active list.
8585 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008586 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
8587 if ( pEntry )
8588 {
8589 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008590 /* If the head of the queue is Active and it is a ROAM command, remove
8591 * and put this on the Free queue.
8592 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008593 if ( eSmeCommandRoam == pCommand->command )
8594 {
Jeff Johnsone7245742012-09-05 17:12:55 -07008595
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008596 /*
8597 * we need to process the result first before removing it from active list
8598 * because state changes still happening insides roamQProcessRoamResults so
8599 * no other roam command should be issued.
8600 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008601 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
8602 if(pCommand->u.roamCmd.fReleaseProfile)
8603 {
8604 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
8605 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
8606 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008607 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07008608 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07008609 else
8610 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008611 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008612 __func__, pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07008613 }
8614 }
8615 else
8616 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008617 smsLog( pMac, LOGE, "%s: roam command not active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008618 }
8619 }
8620 else
8621 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008622 smsLog( pMac, LOGE, "%s: NO commands are active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008623 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008624
8625 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07008626 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
8627
Kiet Lam64c1b492013-07-12 13:56:44 +05308628 vos_mem_copy(roamInfo.bssid,
8629 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
8630 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008631
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008632 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
8633 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008634
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008635 /* Copy the connected profile to apply the same for this connection as well */
Kiet Lam64c1b492013-07-12 13:56:44 +05308636 pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
8637 if ( pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07008638 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308639 vos_mem_set(pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008640 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
8641 //make sure to put it at the head of the cmd queue
8642 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
8643 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
8644 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
8645
Jeff Johnson295189b2012-06-20 16:38:30 -07008646 if(!HAL_STATUS_SUCCESS(status))
8647 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008648 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008649 __func__, status);
8650 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008651 }
8652
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008653 /* Notify sub-modules like QoS etc. that handoff happening */
8654 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
Padma, Santhosh Kumar110608e2015-04-22 18:12:17 +05308655 pmcStopTrafficTimer(pMac);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08008656 csrReleaseProfile(pMac, pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05308657 vos_mem_free(pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07008658 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308659 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008660 return;
8661 }
8662
8663POST_ROAM_FAILURE:
8664 if (pScanFilter)
8665 {
8666 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308667 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008668 }
8669 if (pCurRoamProfile)
Kiet Lam64c1b492013-07-12 13:56:44 +05308670 vos_mem_free(pCurRoamProfile);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008671
8672 /* Inform the upper layers that the reassoc failed */
8673 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
8674 csrRoamCallCallback(pMac, sessionId,
8675 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
8676
8677 /*
8678 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
8679 * Upon success, we would re-enter this routine after receiving the disassoc
8680 * response and will fall into the reassoc fail sub-state. And, eventually
8681 * call csrRoamComplete which would remove the roam command from SME active
8682 * queue.
8683 */
8684 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
8685 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
8686 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008687 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008688 __func__, status);
8689 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07008690 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008691#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008692
Jeff Johnson295189b2012-06-20 16:38:30 -07008693 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
8694 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
8695 {
8696 // Disassoc due to Reassoc failure falls into this codepath....
8697 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8698 }
8699 else
8700 {
8701 if ( eSIR_SME_SUCCESS == statusCode )
8702 {
8703 // Successfully disassociated from the 'old' Bss...
8704 //
8705 // We get Disassociate response in three conditions.
8706 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
8707 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
8708 // Infrastructure network.
8709 // - Third is where we are doing an Infra to Infra roam between networks with different
8710 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
8711
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008712 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008713 }
8714 else
8715 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008716 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008717 }
8718 //We are not done yet. Get the data and continue roaming
8719 csrRoamReissueRoamCommand(pMac);
8720 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008721}
8722
Jeff Johnson295189b2012-06-20 16:38:30 -07008723static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
8724{
8725 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008726 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08008727 pMac->roam.deauthRspStatus = statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008728 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
8729 {
8730 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8731 }
8732 else
8733 {
8734 if ( eSIR_SME_SUCCESS == statusCode )
8735 {
8736 // Successfully deauth from the 'old' Bss...
8737 //
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008738 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008739 }
8740 else
8741 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008742 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008743 }
8744 //We are not done yet. Get the data and continue roaming
8745 csrRoamReissueRoamCommand(pMac);
8746 }
8747}
8748
Jeff Johnson295189b2012-06-20 16:38:30 -07008749static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
8750{
8751 eCsrRoamCompleteResult result;
8752
8753 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
8754 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008755 smsLog( pMac, LOGW, "SmeStartBssReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008756 result = eCsrStartBssSuccess;
8757 }
8758 else
8759 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008760 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08X", pSmeStartBssRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008761 //Let csrRoamComplete decide what to do
8762 result = eCsrStartBssFailure;
8763 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008764 csrRoamComplete( pMac, result, pSmeStartBssRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -07008765}
8766
Jeff Johnson295189b2012-06-20 16:38:30 -07008767/*
8768 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
8769 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
8770 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
8771 For the messages where sender allocates memory for specific structures, then it can be
8772 cast accordingly.
8773*/
8774void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8775{
8776 tSirSmeRsp *pSmeRsp;
8777 tSmeIbssPeerInd *pIbssPeerInd;
8778 tCsrRoamInfo roamInfo;
8779 // TODO Session Id need to be acquired in this function
8780 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008781 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308782 smsLog(pMac, LOG2, FL("Message %d[0x%04X] received in substate %s"),
8783 pSmeRsp->messageType, pSmeRsp->messageType,
8784 macTraceGetcsrRoamSubState(
8785 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008786 pSmeRsp->messageType = (pSmeRsp->messageType);
8787 pSmeRsp->length = (pSmeRsp->length);
8788 pSmeRsp->statusCode = (pSmeRsp->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008789 switch (pSmeRsp->messageType)
8790 {
8791
8792 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
8793 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
8794 {
8795 //We sent a JOIN_REQ
8796 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
8797 }
8798 break;
8799
8800 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
8801 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
8802 {
8803 //We sent a AUTH_REQ
8804 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
8805 }
8806 break;
8807
8808 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
8809 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
8810 {
8811 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
8812 }
8813 break;
8814
8815 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
8816 {
8817 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
8818 }
8819 break;
8820
8821 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
8822 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
8823 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
8824 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
8825 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
8826 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
8827//HO
8828 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
8829 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308830 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %s"),
8831 macTraceGetcsrRoamSubState(
8832 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008833 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
Girish Gowli1c2fc802015-01-19 16:18:07 +05308834 if (pMac->roam.configParam.roamDelayStatsEnabled)
8835 {
8836 vos_record_roam_event(e_SME_DISASSOC_COMPLETE, NULL, 0);
8837 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008838 }
8839 break;
8840
8841 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
8842 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
8843 {
8844 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
8845 }
8846 break;
8847
8848 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
8849 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
8850 {
8851 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
8852 }
8853 break;
8854
8855 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
8856 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
8857 {
8858 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
8859 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008860 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008861 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
8862 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
8863 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008864 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state");
Kiet Lam64c1b492013-07-12 13:56:44 +05308865 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
8866 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008867 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
8868 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05308869 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
8870 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008871 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
8872 eCSR_ROAM_CONNECT_STATUS_UPDATE,
8873 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
8874 break;
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05308875 case eWNI_SME_LOST_LINK_PARAMS_IND:
8876 {
8877 tpSirSmeLostLinkParamsInd pLostLinkParamsInd = (tpSirSmeLostLinkParamsInd)pSmeRsp;
8878 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
8879 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
8880 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
8881 roamInfo.u.pLostLinkParams = &pLostLinkParamsInd->info;
8882 pRoamInfo = &roamInfo;
8883 csrRoamCallCallback(pMac, pLostLinkParamsInd->sessionId,
8884 pRoamInfo, 0, eCSR_ROAM_LOST_LINK_PARAMS_IND, result);
8885 break;
8886 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008887 default:
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308888 smsLog(pMac, LOG1,
8889 FL("Unexpected message type = %d[0x%X] received in substate %s"),
8890 pSmeRsp->messageType, pSmeRsp->messageType,
8891 macTraceGetcsrRoamSubState(
8892 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008893
8894 //If we are connected, check the link status change
8895 if(!csrIsConnStateDisconnected(pMac, sessionId))
8896 {
8897 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
8898 }
8899 break;
8900 }
8901}
8902
Jeff Johnson295189b2012-06-20 16:38:30 -07008903void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8904{
8905 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07008906 switch (pSirMsg->messageType)
8907 {
8908 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008909 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008910 csrRoamStatsRspProcessor( pMac, pSirMsg );
8911 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008912 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
8913 {
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05308914 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07008915 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
8916 tCsrRoamInfo roamInfo;
8917 tCsrRoamInfo *pRoamInfo = NULL;
8918 tANI_U32 sessionId;
8919 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008920 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer "));
Kiet Lam64c1b492013-07-12 13:56:44 +05308921 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008922 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07008923 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
8924 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
8925 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008926
8927 if(!pSession)
8928 {
8929 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8930 return;
8931 }
8932
Jeff Johnson295189b2012-06-20 16:38:30 -07008933 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
8934 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07008935 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
8936 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
8937 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07008938 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
8939 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05308940 vos_mem_copy(pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr,
8941 sizeof(tSirMacAddr));
8942 vos_mem_copy(&pRoamInfo->bssid, pUpperLayerAssocCnf->bssId,
8943 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008944 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Hardik Kantilal Patel1ba630f2014-11-21 04:32:05 +05308945#ifdef WLAN_FEATURE_AP_HT40_24G
8946 pRoamInfo->HT40MHzIntoEnabledSta =
8947 pUpperLayerAssocCnf->HT40MHzIntoEnabledSta;
8948 smsLog( pMac, LOGW, FL("HT40MHzIntoEnabledSta: %d \n"),
8949 pRoamInfo->HT40MHzIntoEnabledSta);
8950#endif
Deepthi Gowriae6a1662015-10-12 12:59:37 +05308951 pRoamInfo->maxRateFlags = pUpperLayerAssocCnf->rate_flags;
Jeff Johnson295189b2012-06-20 16:38:30 -07008952 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
8953 {
8954 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
8955 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
8956 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
8957 }
8958 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8959 {
8960 vos_sleep( 100 );
8961 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
8962 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
8963 }
8964
Jeff Johnson295189b2012-06-20 16:38:30 -07008965 }
8966 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008967 default:
8968 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
8969 break;
8970 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008971}
8972
Jeff Johnson295189b2012-06-20 16:38:30 -07008973eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
8974 tSirBssDescription *pBssDescription,
8975 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
8976 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
8977 tANI_U8 keyId, tANI_U16 keyLength,
8978 tANI_U8 *pKey, tANI_U8 paeRole )
8979{
8980 eHalStatus status = eHAL_STATUS_SUCCESS;
8981 tAniEdType edType;
8982
8983 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
8984 {
8985 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
8986 }
8987
8988 edType = csrTranslateEncryptTypeToEdType( EncryptType );
8989
8990 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
8991 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
8992 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
8993 addKey )
8994 {
8995 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07008996 setKey.encType = EncryptType;
8997 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308998 vos_mem_copy(&setKey.peerMac, bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008999 setKey.paeRole = paeRole; //0 for supplicant
9000 setKey.keyId = keyId; // Kye index
9001 setKey.keyLength = keyLength;
9002 if( keyLength )
9003 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309004 vos_mem_copy(setKey.Key, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07009005 }
9006 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
9007 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009008 return (status);
9009}
9010
Jeff Johnson295189b2012-06-20 16:38:30 -07009011static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
9012 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
9013{
9014 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
9015 tSmeCmd *pCommand = NULL;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009016#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07009017 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009018#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07009019
9020 do
9021 {
9022 pCommand = csrGetCommandBuffer(pMac);
9023 if(NULL == pCommand)
9024 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009025 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009026 status = eHAL_STATUS_RESOURCES;
9027 break;
9028 }
Sushant Kaushike7de85f2014-06-16 17:13:30 +05309029 vos_mem_zero(pCommand, sizeof(tSmeCmd));
Jeff Johnson295189b2012-06-20 16:38:30 -07009030 pCommand->command = eSmeCommandSetKey;
9031 pCommand->sessionId = (tANI_U8)sessionId;
9032 // validate the key length, Adjust if too long...
9033 // for static WEP the keys are not set thru' SetContextReq
9034 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
9035 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
9036 {
9037 //KeyLength maybe 0 for static WEP
9038 if( pSetKey->keyLength )
9039 {
9040 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
9041 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009042 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009043 break;
9044 }
9045
9046 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309047 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
9048 CSR_WEP40_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009049 }
9050 }
9051 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
9052 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
9053 {
9054 //KeyLength maybe 0 for static WEP
9055 if( pSetKey->keyLength )
9056 {
9057 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
9058 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009059 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009060 break;
9061 }
9062
9063 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309064 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
9065 CSR_WEP104_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009066 }
9067 }
9068 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
9069 {
9070 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
9071 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009072 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009073 break;
9074 }
9075 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309076 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
9077 CSR_TKIP_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009078 }
9079 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
9080 {
9081 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
9082 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009083 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009084 break;
9085 }
9086 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309087 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
9088 CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009089 }
9090#ifdef FEATURE_WLAN_WAPI
9091 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
9092 {
9093 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
9094 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009095 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009096 break;
9097 }
9098 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309099 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
9100 CSR_WAPI_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009101 }
9102#endif /* FEATURE_WLAN_WAPI */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009103#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07009104 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
9105 {
9106 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
9107 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009108 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07009109 break;
9110 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009111 vos_mem_copy(pSession->eseCckmInfo.krk, pSetKey->Key,
Kiet Lam64c1b492013-07-12 13:56:44 +05309112 CSR_KRK_KEY_LEN);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009113 pSession->eseCckmInfo.reassoc_req_num=1;
9114 pSession->eseCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009115 status = eHAL_STATUS_SUCCESS;
9116 break;
9117 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009118#endif /* FEATURE_WLAN_ESE */
Jeff Johnsone7245742012-09-05 17:12:55 -07009119
Jeff Johnson295189b2012-06-20 16:38:30 -07009120#ifdef WLAN_FEATURE_11W
9121 //Check for 11w BIP
Chet Lanctot186b5732013-03-18 10:26:30 -07009122 else if (eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009123 {
Chet Lanctot186b5732013-03-18 10:26:30 -07009124 if (pSetKey->keyLength < CSR_AES_KEY_LEN)
Jeff Johnson295189b2012-06-20 16:38:30 -07009125 {
Chet Lanctot186b5732013-03-18 10:26:30 -07009126 smsLog(pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07009127 break;
9128 }
9129 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309130 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009131 }
9132#endif
9133 status = eHAL_STATUS_SUCCESS;
9134 pCommand->u.setKeyCmd.roamId = roamId;
9135 pCommand->u.setKeyCmd.encType = pSetKey->encType;
9136 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05309137 vos_mem_copy(&pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac,
9138 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009139 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
9140 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
Kiet Lam64c1b492013-07-12 13:56:44 +05309141 vos_mem_copy(pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009142 //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
9143
9144 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
9145 if( !HAL_STATUS_SUCCESS( status ) )
9146 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009147 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07009148 }
9149 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009150 // Free the command if there has been a failure, or it is a
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009151 // "local" operation like the set ESE CCKM KRK key.
Jeff Johnson74b3ec52013-04-03 13:45:51 -07009152 if ( ( NULL != pCommand ) &&
9153 ( (!HAL_STATUS_SUCCESS( status ) )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009154#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07009155 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009156#endif /* FEATURE_WLAN_ESE */
Jeff Johnson74b3ec52013-04-03 13:45:51 -07009157 ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009158 {
9159 csrReleaseCommandSetKey( pMac, pCommand );
9160 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009161 return( status );
9162}
9163
Jeff Johnson295189b2012-06-20 16:38:30 -07009164eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
9165 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
9166{
9167 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
9168 tSmeCmd *pCommand = NULL;
9169 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009170 do
9171 {
9172 if( !csrIsSetKeyAllowed(pMac, sessionId) )
9173 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009174 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009175 status = eHAL_STATUS_CSR_WRONG_STATE;
9176 break;
9177 }
9178 pCommand = csrGetCommandBuffer(pMac);
9179 if(NULL == pCommand)
9180 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009181 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009182 status = eHAL_STATUS_RESOURCES;
9183 break;
9184 }
9185 pCommand->command = eSmeCommandRemoveKey;
9186 pCommand->sessionId = (tANI_U8)sessionId;
9187 pCommand->u.removeKeyCmd.roamId = roamId;
9188 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
Kiet Lam64c1b492013-07-12 13:56:44 +05309189 vos_mem_copy(&pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac,
9190 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009191 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
9192 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
9193 {
9194 //in this case, put it to the end of the Q incase there is a set key pending.
9195 fImediate = eANI_BOOLEAN_FALSE;
9196 }
Arif Hussain24bafea2013-11-15 15:10:03 -08009197 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac="MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07009198 pRemoveKey->encType, pRemoveKey->keyId,
Arif Hussain24bafea2013-11-15 15:10:03 -08009199 MAC_ADDR_ARRAY(pCommand->u.removeKeyCmd.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07009200 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
9201 if( !HAL_STATUS_SUCCESS( status ) )
9202 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009203 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07009204 break;
9205 }
9206 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009207 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
9208 {
9209 csrReleaseCommandRemoveKey( pMac, pCommand );
9210 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009211 return (status );
9212}
9213
Jeff Johnson295189b2012-06-20 16:38:30 -07009214eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
9215{
9216 eHalStatus status;
9217 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
9218 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
9219 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
9220 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009221#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9222 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
9223 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Girish Gowli2857eb22014-07-31 19:49:46 +05309224 if(!pSession)
9225 {
9226 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9227 return eHAL_STATUS_FAILURE;
9228 }
lukez3c809222013-05-03 10:23:02 -07009229 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009230 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309231 vos_mem_set(&setKeyEvent,
9232 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009233 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
9234 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05309235 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_BCAST_REQ;
Jeff Johnson295189b2012-06-20 16:38:30 -07009236 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
9237 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9238 }
9239 else
9240 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05309241 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_UNICAST_REQ;
Jeff Johnson295189b2012-06-20 16:38:30 -07009242 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
9243 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9244 }
Kiet Lam64c1b492013-07-12 13:56:44 +05309245 vos_mem_copy(setKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
lukez3c809222013-05-03 10:23:02 -07009246 if(CSR_IS_ENC_TYPE_STATIC(pCommand->u.setKeyCmd.encType))
Jeff Johnson295189b2012-06-20 16:38:30 -07009247 {
9248 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009249 //It has to be static WEP here
9250 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
9251 {
9252 setKeyEvent.keyId = (v_U8_t)defKeyId;
9253 }
9254 }
9255 else
9256 {
9257 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
9258 }
9259 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
9260 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9261 }
9262#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009263 if( csrIsSetKeyAllowed(pMac, sessionId) )
9264 {
9265 status = csrSendMBSetContextReqMsg( pMac, sessionId,
9266 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
9267 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
9268 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
9269 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
9270 pCommand->u.setKeyCmd.keyRsc);
9271 }
9272 else
9273 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009274 smsLog( pMac, LOGW, FL(" cannot process not connected") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009275 //Set this status so the error handling take care of the case.
9276 status = eHAL_STATUS_CSR_WRONG_STATE;
9277 }
9278 if( !HAL_STATUS_SUCCESS(status) )
9279 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009280 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07009281 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07009282#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
lukez3c809222013-05-03 10:23:02 -07009283 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07009284 {
9285 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
9286 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05309287 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_BCAST_RSP;
Jeff Johnson295189b2012-06-20 16:38:30 -07009288 }
9289 else
9290 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +05309291 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_UNICAST_RSP;
Jeff Johnson295189b2012-06-20 16:38:30 -07009292 }
9293 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9294 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9295 }
9296#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009297 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009298 return ( status );
9299}
9300
Jeff Johnson295189b2012-06-20 16:38:30 -07009301eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
9302{
9303 eHalStatus status;
9304 tpSirSmeRemoveKeyReq pMsg = NULL;
9305 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
9306 tANI_U8 *p;
9307 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009308#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9309 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
9310 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Girish Gowli2857eb22014-07-31 19:49:46 +05309311 if(!pSession)
9312 {
9313 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9314 return eHAL_STATUS_FAILURE;
9315 }
Kiet Lam64c1b492013-07-12 13:56:44 +05309316 vos_mem_set(&removeKeyEvent,
9317 sizeof(vos_event_wlan_security_payload_type),0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009318 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
9319 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9320 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309321 vos_mem_copy(removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009322 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
9323 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
9324 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
9325#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009326 if( csrIsSetKeyAllowed(pMac, sessionId) )
9327 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309328 pMsg = vos_mem_malloc(wMsgLen);
9329 if ( NULL == pMsg )
9330 status = eHAL_STATUS_FAILURE;
9331 else
9332 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009333 }
9334 else
9335 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009336 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009337 //Set the error status so error handling kicks in below
9338 status = eHAL_STATUS_CSR_WRONG_STATE;
9339 }
9340 if( HAL_STATUS_SUCCESS( status ) )
9341 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309342 vos_mem_set(pMsg, wMsgLen ,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009343 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
9344 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07009345 pMsg->sessionId = (tANI_U8)sessionId;
9346 pMsg->transactionId = 0;
9347 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
9348 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
9349 // bssId - copy from session Info
Kiet Lam64c1b492013-07-12 13:56:44 +05309350 vos_mem_copy(p,
9351 &pMac->roam.roamSession[sessionId].connectedProfile.bssid,
9352 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009353 p += sizeof(tSirMacAddr);
9354 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +05309355 vos_mem_copy(p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009356 p += sizeof(tSirMacAddr);
9357 // edType
9358 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
9359 p++;
9360 // weptype
9361 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
9362 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
9363 {
9364 *p = (tANI_U8)eSIR_WEP_STATIC;
9365 }
9366 else
9367 {
9368 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
9369 }
9370 p++;
9371 //keyid
9372 *p = pCommand->u.removeKeyCmd.keyId;
9373 p++;
9374 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07009375 status = palSendMBMessage(pMac->hHdd, pMsg);
9376 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009377 if( !HAL_STATUS_SUCCESS( status ) )
9378 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07009379 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07009380#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9381 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07009382 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07009383 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
9384#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009385 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
9386 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009387 return ( status );
9388}
9389
Jeff Johnson295189b2012-06-20 16:38:30 -07009390eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
9391{
9392 eHalStatus status;
9393
9394 if( !csrIsSetKeyAllowed(pMac, sessionId) )
9395 {
9396 status = eHAL_STATUS_CSR_WRONG_STATE;
9397 }
9398 else
9399 {
9400 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
9401 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009402 return ( status );
9403}
9404
Jeff Johnson295189b2012-06-20 16:38:30 -07009405/*
9406 Prepare a filter base on a profile for parsing the scan results.
9407 Upon successful return, caller MUST call csrFreeScanFilter on
9408 pScanFilter when it is done with the filter.
9409*/
9410eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
9411 tCsrScanResultFilter *pScanFilter)
9412{
9413 eHalStatus status = eHAL_STATUS_SUCCESS;
9414 tANI_U32 size = 0;
9415 tANI_U8 index = 0;
9416
9417 do
9418 {
9419 if(pProfile->BSSIDs.numOfBSSIDs)
9420 {
9421 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05309422 pScanFilter->BSSIDs.bssid = vos_mem_malloc(size);
9423 if ( NULL == pScanFilter->BSSIDs.bssid )
9424 status = eHAL_STATUS_FAILURE;
9425 else
9426 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009427 if(!HAL_STATUS_SUCCESS(status))
9428 {
9429 break;
9430 }
9431 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05309432 vos_mem_copy(pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07009433 }
9434 if(pProfile->SSIDs.numOfSSIDs)
9435 {
9436 if( !CSR_IS_WDS_STA( pProfile ) )
9437 {
9438 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
9439 }
9440 else
9441 {
9442 //For WDS station
9443 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
9444 pScanFilter->SSIDs.numOfSSIDs = 1;
9445 }
9446 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05309447 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(size);
9448 if ( NULL == pScanFilter->SSIDs.SSIDList )
9449 status = eHAL_STATUS_FAILURE;
9450 else
9451 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009452 if(!HAL_STATUS_SUCCESS(status))
9453 {
9454 break;
9455 }
Kiet Lam64c1b492013-07-12 13:56:44 +05309456 vos_mem_copy(pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList,
9457 size);
Jeff Johnson295189b2012-06-20 16:38:30 -07009458 }
9459 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
9460 {
9461 pScanFilter->ChannelInfo.numOfChannels = 0;
9462 pScanFilter->ChannelInfo.ChannelList = NULL;
9463 }
9464 else if(pProfile->ChannelInfo.numOfChannels)
9465 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309466 pScanFilter->ChannelInfo.ChannelList = vos_mem_malloc(
9467 sizeof(*pScanFilter->ChannelInfo.ChannelList) *
9468 pProfile->ChannelInfo.numOfChannels);
9469 if ( NULL == pScanFilter->ChannelInfo.ChannelList )
9470 status = eHAL_STATUS_FAILURE;
9471 else
9472 status = eHAL_STATUS_SUCCESS;
9473
Jeff Johnson295189b2012-06-20 16:38:30 -07009474 pScanFilter->ChannelInfo.numOfChannels = 0;
9475 if(HAL_STATUS_SUCCESS(status))
9476 {
9477 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
9478 {
9479 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
9480 {
9481 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
9482 = pProfile->ChannelInfo.ChannelList[index];
9483 pScanFilter->ChannelInfo.numOfChannels++;
9484 }
9485 else
9486 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009487 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid"), pProfile->ChannelInfo.ChannelList[index]);
Jeff Johnson295189b2012-06-20 16:38:30 -07009488 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009489 }
9490 }
9491 else
9492 {
9493 break;
9494 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009495 }
9496 else
9497 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05309498 smsLog(pMac, LOGE, FL("Channel list empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009499 status = eHAL_STATUS_FAILURE;
9500 break;
9501 }
9502 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
9503 pScanFilter->authType = pProfile->AuthType;
9504 pScanFilter->EncryptionType = pProfile->EncryptionType;
9505 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
9506 pScanFilter->BSSType = pProfile->BSSType;
9507 pScanFilter->phyMode = pProfile->phyMode;
9508#ifdef FEATURE_WLAN_WAPI
9509 //check if user asked for WAPI with 11n or auto mode, in that case modify
9510 //the phymode to 11g
9511 if(csrIsProfileWapi(pProfile))
9512 {
9513 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
9514 {
9515 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
9516 }
9517 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
9518 {
9519 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
9520 }
9521 if(!pScanFilter->phyMode)
9522 {
9523 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
9524 }
9525 }
9526#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07009527 /*Save the WPS info*/
9528 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -07009529 pScanFilter->bOSENAssociation = pProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07009530 if( pProfile->countryCode[0] )
9531 {
9532 //This causes the matching function to use countryCode as one of the criteria.
Kiet Lam64c1b492013-07-12 13:56:44 +05309533 vos_mem_copy(pScanFilter->countryCode, pProfile->countryCode,
9534 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009535 }
9536#ifdef WLAN_FEATURE_VOWIFI_11R
9537 if (pProfile->MDID.mdiePresent)
9538 {
9539 pScanFilter->MDID.mdiePresent = 1;
9540 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
9541 }
9542#endif
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05309543
9544#ifdef WLAN_FEATURE_11W
9545 // Management Frame Protection
9546 pScanFilter->MFPEnabled = pProfile->MFPEnabled;
9547 pScanFilter->MFPRequired = pProfile->MFPRequired;
9548 pScanFilter->MFPCapable = pProfile->MFPCapable;
9549#endif
9550
Jeff Johnson295189b2012-06-20 16:38:30 -07009551 }while(0);
9552
9553 if(!HAL_STATUS_SUCCESS(status))
9554 {
9555 csrFreeScanFilter(pMac, pScanFilter);
9556 }
9557
9558 return(status);
9559}
9560
Jeff Johnson295189b2012-06-20 16:38:30 -07009561tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
9562 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
9563{
9564 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
9565 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07009566 do
9567 {
9568 // Validate the type is ok...
9569 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
9570 pCommand = csrGetCommandBuffer( pMac );
9571 if ( !pCommand )
9572 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009573 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009574 break;
9575 }
9576 //Change the substate in case it is waiting for key
9577 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
9578 {
9579 csrRoamStopWaitForKeyTimer( pMac );
9580 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
9581 }
9582 pCommand->command = eSmeCommandWmStatusChange;
9583 pCommand->sessionId = (tANI_U8)sessionId;
9584 pCommand->u.wmStatusChangeCmd.Type = Type;
9585 if ( eCsrDisassociated == Type )
9586 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309587 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg,
9588 pSmeRsp,
9589 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07009590 }
9591 else
9592 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309593 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg,
9594 pSmeRsp,
9595 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07009596 }
9597 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
9598 {
9599 fCommandQueued = eANI_BOOLEAN_TRUE;
9600 }
9601 else
9602 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009603 smsLog( pMac, LOGE, FL(" fail to send message ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009604 csrReleaseCommandWmStatusChange( pMac, pCommand );
9605 }
9606
Jeff Johnson295189b2012-06-20 16:38:30 -07009607 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
9608 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07009609 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07009610 return( fCommandQueued );
9611}
9612
Jeff Johnson295189b2012-06-20 16:38:30 -07009613static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
9614{
9615 v_S7_t rssi = 0;
9616 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
9617 if(pGetRssiReq)
9618 {
9619 if(NULL != pGetRssiReq->pVosContext)
9620 {
9621 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
9622 }
9623 else
9624 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009625 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009626 return;
9627 }
9628
9629 if(NULL != pGetRssiReq->rssiCallback)
9630 {
9631 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
9632 }
9633 else
9634 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009635 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009636 return;
9637 }
9638 }
9639 else
9640 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009641 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009642 }
9643 return;
9644}
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309645
9646static void csrUpdateSnr(tpAniSirGlobal pMac, void* pMsg)
9647{
9648 tANI_S8 snr = 0;
9649 tAniGetSnrReq *pGetSnrReq = (tAniGetSnrReq*)pMsg;
9650
9651 if (pGetSnrReq)
9652 {
9653 if (VOS_STATUS_SUCCESS !=
9654 WDA_GetSnr(pGetSnrReq->staId, &snr))
9655 {
9656 smsLog(pMac, LOGE, FL("Error in WLANTL_GetSnr"));
9657 return;
9658 }
9659
9660 if (pGetSnrReq->snrCallback)
9661 {
9662 ((tCsrSnrCallback)(pGetSnrReq->snrCallback))(snr, pGetSnrReq->staId,
9663 pGetSnrReq->pDevContext);
9664 }
9665 else
9666 {
9667 smsLog(pMac, LOGE, FL("pGetSnrReq->snrCallback is NULL"));
9668 return;
9669 }
9670 }
9671 else
9672 {
9673 smsLog(pMac, LOGE, FL("pGetSnrReq is NULL"));
9674 }
9675 return;
9676}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009677#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009678void csrRoamRssiRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9679{
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009680 tAniGetRoamRssiRsp* pRoamRssiRsp = (tAniGetRoamRssiRsp*)pMsg;
9681
Jeff Johnson36d483b2013-04-08 11:08:53 -07009682 if (NULL != pRoamRssiRsp)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009683 {
Jeff Johnson36d483b2013-04-08 11:08:53 -07009684 /* Get roam Rssi request is backed up and passed back to the response,
9685 Extract the request message to fetch callback */
9686 tpAniGetRssiReq reqBkp = (tAniGetRssiReq*)pRoamRssiRsp->rssiReq;
9687 v_S7_t rssi = pRoamRssiRsp->rssi;
9688
9689 if ((NULL != reqBkp) && (NULL != reqBkp->rssiCallback))
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009690 {
9691 ((tCsrRssiCallback)(reqBkp->rssiCallback))(rssi, pRoamRssiRsp->staId, reqBkp->pDevContext);
9692 reqBkp->rssiCallback = NULL;
9693 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009694 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009695 }
9696 else
9697 {
9698 smsLog( pMac, LOGE, FL("reqBkp->rssiCallback is NULL"));
9699 if (NULL != reqBkp)
9700 {
9701 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009702 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009703 }
9704 }
9705 }
9706 else
9707 {
9708 smsLog( pMac, LOGE, FL("pRoamRssiRsp is NULL"));
9709 }
9710 return;
9711}
9712#endif
9713
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009714
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009715#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009716void csrTsmStatsRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9717{
9718 tAniGetTsmStatsRsp* pTsmStatsRsp = (tAniGetTsmStatsRsp*)pMsg;
9719
9720 if (NULL != pTsmStatsRsp)
9721 {
9722 /* Get roam Rssi request is backed up and passed back to the response,
9723 Extract the request message to fetch callback */
9724 tpAniGetTsmStatsReq reqBkp = (tAniGetTsmStatsReq*)pTsmStatsRsp->tsmStatsReq;
9725
9726 if (NULL != reqBkp)
9727 {
9728 if (NULL != reqBkp->tsmStatsCallback)
9729 {
9730 ((tCsrTsmStatsCallback)(reqBkp->tsmStatsCallback))(pTsmStatsRsp->tsmMetrics,
9731 pTsmStatsRsp->staId, reqBkp->pDevContext);
9732 reqBkp->tsmStatsCallback = NULL;
9733 }
9734 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009735 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009736 }
9737 else
9738 {
9739 smsLog( pMac, LOGE, FL("reqBkp is NULL"));
9740 if (NULL != reqBkp)
9741 {
9742 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009743 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009744 }
9745 }
9746 }
9747 else
9748 {
9749 smsLog( pMac, LOGE, FL("pTsmStatsRsp is NULL"));
9750 }
9751 return;
9752}
9753
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009754void csrSendEseAdjacentApRepInd(tpAniSirGlobal pMac, tCsrRoamSession *pSession)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009755{
9756 tANI_U32 roamTS2 = 0;
9757 tCsrRoamInfo roamInfo;
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009758 tpPESession pSessionEntry = NULL;
9759 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009760
9761 if (NULL == pSession)
9762 {
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009763 smsLog(pMac, LOGE, FL("pSession is NULL"));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009764 return;
9765 }
9766
9767 roamTS2 = vos_timer_get_system_time();
9768 roamInfo.tsmRoamDelay = roamTS2 - pSession->roamTS1;
Arif Hussaina7c8e412013-11-20 11:06:42 -08009769 smsLog(pMac, LOG1, "Bssid("MAC_ADDRESS_STR") Roaming Delay(%u ms)",
9770 MAC_ADDR_ARRAY(pSession->connectedProfile.bssid),
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009771 roamInfo.tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009772
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009773 pSessionEntry = peFindSessionByBssid(pMac, pSession->connectedProfile.bssid, &sessionId);
9774 if (NULL == pSessionEntry)
9775 {
9776 smsLog(pMac, LOGE, FL("session %d not found"), sessionId);
9777 return;
9778 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009779 pSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly = roamInfo.tsmRoamDelay;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009780 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009781 0, eCSR_ROAM_ESE_ADJ_AP_REPORT_IND, 0);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009782}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009783#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009784
Jeff Johnsone7245742012-09-05 17:12:55 -07009785static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
9786{
9787 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
9788 if(pTlRssiInd)
9789 {
9790 if(NULL != pTlRssiInd->tlCallback)
9791 {
9792 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -08009793 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07009794 }
9795 else
9796 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009797 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009798 }
9799 }
9800 else
9801 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009802 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009803 }
9804 return;
9805}
Jeff Johnson295189b2012-06-20 16:38:30 -07009806
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309807eHalStatus csrSendResetApCapsChanged(tpAniSirGlobal pMac, tSirMacAddr *bssId)
9808{
9809 tpSirResetAPCapsChange pMsg;
9810 tANI_U16 len;
9811 eHalStatus status = eHAL_STATUS_SUCCESS;
9812
9813 /* Create the message and send to lim */
9814 len = sizeof(tSirResetAPCapsChange);
Kiet Lam64c1b492013-07-12 13:56:44 +05309815 pMsg = vos_mem_malloc(len);
9816 if ( NULL == pMsg )
9817 status = eHAL_STATUS_FAILURE;
9818 else
9819 status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309820 if (HAL_STATUS_SUCCESS(status))
9821 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309822 vos_mem_set(pMsg, sizeof(tSirResetAPCapsChange), 0);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309823 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
9824 pMsg->length = len;
Kiet Lam64c1b492013-07-12 13:56:44 +05309825 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08009826 smsLog( pMac, LOG1, FL("CSR reset caps change for Bssid= "MAC_ADDRESS_STR),
9827 MAC_ADDR_ARRAY(pMsg->bssId));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309828 status = palSendMBMessage(pMac->hHdd, pMsg);
9829 }
9830 else
9831 {
9832 smsLog( pMac, LOGE, FL("Memory allocation failed\n"));
9833 }
9834 return status;
9835}
9836
Jeff Johnson295189b2012-06-20 16:38:30 -07009837void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
9838{
9839 tSirSmeAssocInd *pAssocInd;
9840 tSirSmeDisassocInd *pDisassocInd;
9841 tSirSmeDeauthInd *pDeauthInd;
Hanumantha Reddy Pothula1b6eb2f2015-11-30 20:50:23 +05309842 tSirSmeDisConDoneInd *pDisConDoneInd;
Jeff Johnson295189b2012-06-20 16:38:30 -07009843 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
9844 tSirSmeNewBssInfo *pNewBss;
9845 tSmeIbssPeerInd *pIbssPeerInd;
9846 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
9847 tSirSmeApNewCaps *pApNewCaps;
9848 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
9849 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
9850 tCsrRoamInfo *pRoamInfo = NULL;
9851 tCsrRoamInfo roamInfo;
9852 eHalStatus status;
9853 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
9854 tCsrRoamSession *pSession = NULL;
9855 tpSirSmeSwitchChannelInd pSwitchChnInd;
9856 tSmeMaxAssocInd *pSmeMaxAssocInd;
Kiet Lam64c1b492013-07-12 13:56:44 +05309857 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
krunal soni587bf012014-02-04 12:35:11 -08009858
9859
9860 if (NULL == pSirMsg)
9861 { smsLog(pMac, LOGE, FL("pSirMsg is NULL"));
9862 return;
9863 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009864 switch( pSirMsg->messageType )
9865 {
9866 case eWNI_SME_ASSOC_IND:
9867 {
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +05309868 tCsrRoamSession *pSession = NULL;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +05309869 smsLog( pMac, LOG1, FL("Receive WNI_SME_ASSOC_IND from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009870 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
9871 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
9872 if( HAL_STATUS_SUCCESS( status ) )
9873 {
9874 pSession = CSR_GET_SESSION(pMac, sessionId);
9875
Jeff Johnson32d95a32012-09-10 13:15:23 -07009876 if(!pSession)
9877 {
9878 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9879 return;
9880 }
9881
Jeff Johnson295189b2012-06-20 16:38:30 -07009882 pRoamInfo = &roamInfo;
9883
9884 // Required for indicating the frames to upper layer
9885 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
9886 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
9887
9888 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
9889 pRoamInfo->beaconLength = pAssocInd->beaconLength;
9890 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
9891 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9892
9893 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
9894 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
9895 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
9896
9897 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
9898 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05309899 vos_mem_copy(pRoamInfo->peerMac, pAssocInd->peerMacAddr,
9900 sizeof(tSirMacAddr));
9901 vos_mem_copy(&pRoamInfo->bssid, pAssocInd->bssId,
9902 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009903 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
Deepthi Gowriae6a1662015-10-12 12:59:37 +05309904 pRoamInfo->maxRateFlags = pAssocInd->rate_flags;
Hardik Kantilal Patel1ba630f2014-11-21 04:32:05 +05309905#ifdef WLAN_FEATURE_AP_HT40_24G
9906 pRoamInfo->HT40MHzIntoEnabledSta =
9907 pAssocInd->HT40MHzIntoEnabledSta;
9908 smsLog(pMac, LOGW, FL("HT40MHzIntoEnabledSta: %d \n"),
9909 pRoamInfo->HT40MHzIntoEnabledSta);
9910#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009911 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07009912 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -07009913 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
9914 {
9915 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
9916 {
9917 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
9918 pSession->pConnectBssDesc,
9919 &(pRoamInfo->peerMac),
9920 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9921 pRoamInfo->fAuthRequired = FALSE;
9922 }
9923 else
9924 {
9925 pRoamInfo->fAuthRequired = TRUE;
9926 }
9927 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
9928 if (!HAL_STATUS_SUCCESS(status))
9929 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
9930 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009931 /* Send Association completion message to PE */
9932 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
9933
9934 /* send a message to CSR itself just to avoid the EAPOL frames going
9935 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -07009936 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
9937 {
9938 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9939 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009940 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
9941 {
9942 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
9943 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
9944 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9945 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009946 }
9947 }
9948 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009949 case eWNI_SME_DISASSOC_IND:
Jeff Johnson295189b2012-06-20 16:38:30 -07009950 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309951 // Check if AP dis-associated us because of MIC failure. If so,
9952 // then we need to take action immediately and not wait till the
9953 // the WmStatusChange requests is pushed and processed
9954 tSmeCmd *pCommand;
9955
9956 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
9957 status = csrRoamGetSessionIdFromBSSID( pMac,
9958 (tCsrBssid *)pDisassocInd->bssId, &sessionId );
9959 if( HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009960 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309961 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC"
9962 " for session %d "), sessionId);
9963 smsLog( pMac, LOGE, FL("DISASSOCIATION from peer ="
9964 MAC_ADDRESS_STR " "
9965 " reason = %d status = %d "),
9966 MAC_ADDR_ARRAY(pDisassocInd->peerMacAddr),
9967 pDisassocInd->reasonCode,
9968 pDisassocInd->statusCode);
9969 // If we are in neighbor preauth done state then on receiving
9970 // disassoc or deauth we dont roam instead we just disassoc
9971 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009972 // This happens for ESE and 11r FT connections ONLY.
Agarwal Ashish4f616132013-12-30 23:32:50 +05309973#ifdef WLAN_FEATURE_VOWIFI_11R
9974 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9975 {
9976 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9977 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009978#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009979#ifdef FEATURE_WLAN_ESE
9980 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Agarwal Ashish4f616132013-12-30 23:32:50 +05309981 {
9982 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9983 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009984#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009985#ifdef FEATURE_WLAN_LFR
Agarwal Ashish4f616132013-12-30 23:32:50 +05309986 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
9987 {
9988 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9989 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009990#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +05309991 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009992
Agarwal Ashish4f616132013-12-30 23:32:50 +05309993 if (!pSession)
9994 {
9995 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9996 return;
9997 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07009998
Agarwal Ashish4f616132013-12-30 23:32:50 +05309999 if ( csrIsConnStateInfra( pMac, sessionId ) )
10000 {
10001 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
10002 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010003#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Agarwal Ashish4f616132013-12-30 23:32:50 +053010004 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -070010005#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +053010006 csrRoamLinkDown(pMac, sessionId);
10007 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
10008 if (CSR_IS_INFRA_AP(&pSession->connectedProfile))
10009 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053010010 /*
10011 * STA/P2P client got disassociated so remove any pending deauth
10012 * commands in sme pending list
10013 */
Kaushik, Sushant488df382014-03-05 11:43:47 +053010014 pCommand = csrGetCommandBuffer(pMac);
10015 if (NULL == pCommand)
10016 {
10017 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
10018 status = eHAL_STATUS_RESOURCES;
10019 return;
10020 }
Agarwal Ashish4f616132013-12-30 23:32:50 +053010021 pCommand->command = eSmeCommandRoam;
10022 pCommand->sessionId = (tANI_U8)sessionId;
10023 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
10024 vos_mem_copy(pCommand->u.roamCmd.peerMac,
10025 pDisassocInd->peerMacAddr,
10026 sizeof(tSirMacAddr));
10027 csrRoamRemoveDuplicateCommand(pMac, sessionId, pCommand, eCsrForcedDeauthSta);
10028 csrReleaseCommand( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -070010029
Agarwal Ashish4f616132013-12-30 23:32:50 +053010030 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010031 }
Agarwal Ashish4f616132013-12-30 23:32:50 +053010032 else
10033 {
10034 smsLog(pMac, LOGE, FL(" Session Id not found for BSSID " MAC_ADDRESS_STR),
10035 MAC_ADDR_ARRAY(pDisassocInd->bssId));
10036 }
Kiet Lam82004c62013-11-11 13:24:28 +053010037 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010038 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010039 case eWNI_SME_DEAUTH_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010040 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010041 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
10042 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
10043 if( HAL_STATUS_SUCCESS( status ) )
10044 {
10045 // If we are in neighbor preauth done state then on receiving
10046 // disassoc or deauth we dont roam instead we just disassoc
10047 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010048 // This happens for ESE and 11r FT connections ONLY.
Jeff Johnson295189b2012-06-20 16:38:30 -070010049#ifdef WLAN_FEATURE_VOWIFI_11R
10050 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
10051 {
10052 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
10053 }
10054#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010055#ifdef FEATURE_WLAN_ESE
10056 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson295189b2012-06-20 16:38:30 -070010057 {
10058 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
10059 }
10060#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010061#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053010062 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070010063 {
10064 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
10065 }
10066#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010067 pSession = CSR_GET_SESSION( pMac, sessionId );
10068
Jeff Johnson32d95a32012-09-10 13:15:23 -070010069 if(!pSession)
10070 {
10071 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10072 return;
10073 }
10074
Jeff Johnson295189b2012-06-20 16:38:30 -070010075 if ( csrIsConnStateInfra( pMac, sessionId ) )
10076 {
10077 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
10078 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010079#ifndef WLAN_MDM_CODE_REDUCTION_OPT
10080 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
10081#endif
10082 csrRoamLinkDown(pMac, sessionId);
10083 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070010084 }
10085 break;
Hanumantha Reddy Pothula1b6eb2f2015-11-30 20:50:23 +053010086
10087 case eWNI_SME_DISCONNECT_DONE_IND:
10088 pDisConDoneInd = (tSirSmeDisConDoneInd *)(pSirMsg);
10089 smsLog( pMac, LOG1,
10090 FL("eWNI_SME_DISCONNECT_DONE_IND RC:%d"),
10091 pDisConDoneInd->reasonCode);
10092 if( CSR_IS_SESSION_VALID(pMac, pDisConDoneInd->sessionId))
10093 {
10094 roamInfo.reasonCode = pDisConDoneInd->reasonCode;
10095 roamInfo.statusCode = eSIR_SME_STA_DISASSOCIATED;
10096 vos_mem_copy(roamInfo.peerMac, pDisConDoneInd->peerMacAddr,
10097 sizeof(tSirMacAddr));
10098 status = csrRoamCallCallback(pMac,
10099 pDisConDoneInd->sessionId,
10100 &roamInfo, 0,
10101 eCSR_ROAM_LOSTLINK,
10102 eCSR_ROAM_RESULT_DISASSOC_IND);
Abhishek Singh7f345c42016-08-24 11:15:23 +053010103 pSession = CSR_GET_SESSION(pMac,
10104 pDisConDoneInd->sessionId);
10105 if (pSession &&
10106 !CSR_IS_INFRA_AP(&pSession->connectedProfile))
10107 csrRoamStateChange(pMac,
10108 eCSR_ROAMING_STATE_IDLE,
10109 pDisConDoneInd->sessionId);
Hanumantha Reddy Pothula1b6eb2f2015-11-30 20:50:23 +053010110 }
10111 else
10112 {
10113 smsLog(pMac, LOGE, FL("Inactive session %d"),
10114 pDisConDoneInd->sessionId);
10115 }
10116 break;
10117
Jeff Johnson295189b2012-06-20 16:38:30 -070010118 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 -080010119 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010120 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
10121 //Update with the new channel id.
10122 //The channel id is hidden in the statusCode.
10123 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
10124 if( HAL_STATUS_SUCCESS( status ) )
10125 {
10126 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010127 if(!pSession)
10128 {
10129 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10130 return;
10131 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010132 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
10133 if(pSession->pConnectBssDesc)
10134 {
10135 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
10136 }
10137 }
10138 break;
10139
10140 case eWNI_SME_DEAUTH_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010141 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010142 {
10143 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
10144 sessionId = pDeauthRsp->sessionId;
10145 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
10146 {
10147 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010148 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
10149 {
10150 pRoamInfo = &roamInfo;
10151 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +053010152 vos_mem_copy(pRoamInfo->peerMac, pDeauthRsp->peerMacAddr,
10153 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070010154 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
10155 pRoamInfo->statusCode = pDeauthRsp->statusCode;
10156 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
10157 }
10158 }
10159 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010160 break;
10161
10162 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010163 /* session id is invalid here so cant use it to access the array curSubstate as index */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010164 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -070010165 {
10166 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
10167 sessionId = pDisassocRsp->sessionId;
10168 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
10169 {
10170 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010171 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
10172 {
10173 pRoamInfo = &roamInfo;
10174 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +053010175 vos_mem_copy(pRoamInfo->peerMac, pDisassocRsp->peerMacAddr,
10176 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070010177 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
10178 pRoamInfo->statusCode = pDisassocRsp->statusCode;
10179 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
10180 }
10181 }
10182 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010183 break;
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +053010184 case eWNI_SME_LOST_LINK_PARAMS_IND:
10185 {
10186 tpSirSmeLostLinkParamsInd pLostLinkParamsInd = (tpSirSmeLostLinkParamsInd)pSirMsg;
10187 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
10188 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
10189 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
10190 roamInfo.u.pLostLinkParams = &pLostLinkParamsInd->info;
10191 pRoamInfo = &roamInfo;
10192 csrRoamCallCallback(pMac, pLostLinkParamsInd->sessionId,
10193 pRoamInfo, 0, eCSR_ROAM_LOST_LINK_PARAMS_IND, result);
10194 break;
10195 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010196 case eWNI_SME_MIC_FAILURE_IND:
10197 {
10198 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
10199 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
10200 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Leo Chang9b01ad92013-09-12 17:26:56 -070010201
10202 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
10203 if( HAL_STATUS_SUCCESS( status ) )
10204 {
Kiet Lamf2f201e2013-11-16 21:24:16 +053010205 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Leo Chang9b01ad92013-09-12 17:26:56 -070010206 roamInfo.u.pMICFailureInfo = &pMicInd->info;
10207 pRoamInfo = &roamInfo;
10208 if(pMicInd->info.multicast)
10209 {
10210 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
10211 }
10212 else
10213 {
10214 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
10215 }
10216 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
10217 }
10218
Jeff Johnson295189b2012-06-20 16:38:30 -070010219#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10220 {
lukez3c809222013-05-03 10:23:02 -070010221 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010222 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010223 if(!pSession)
10224 {
10225 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10226 return;
10227 }
lukez3c809222013-05-03 10:23:02 -070010228
Kiet Lam64c1b492013-07-12 13:56:44 +053010229 vos_mem_set(&secEvent, sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010230 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
10231 secEvent.encryptionModeMulticast =
10232 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10233 secEvent.encryptionModeUnicast =
10234 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
10235 secEvent.authMode =
10236 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010237 vos_mem_copy(secEvent.bssid,
10238 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010239 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
10240 }
10241#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010242 }
10243 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010244 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
10245 {
10246 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
10247 tCsrRoamInfo roamInfo;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010248 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010249
10250 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
10251 if( HAL_STATUS_SUCCESS( status ) )
10252 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010253 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010254 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
10255 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
10256 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
10257 }
10258 }
10259 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010260
Jeff Johnson295189b2012-06-20 16:38:30 -070010261 case eWNI_SME_WM_STATUS_CHANGE_NTF:
10262 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
10263 switch( pStatusChangeMsg->statusChangeCode )
10264 {
10265 case eSIR_SME_IBSS_ACTIVE:
10266 sessionId = csrFindIbssSession( pMac );
10267 if( CSR_SESSION_ID_INVALID != sessionId )
10268 {
10269 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010270 if(!pSession)
10271 {
10272 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10273 return;
10274 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010275 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
10276 if(pSession->pConnectBssDesc)
10277 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010278 vos_mem_copy(&roamInfo.bssid,
10279 pSession->pConnectBssDesc->bssId,
10280 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010281 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
10282 pRoamInfo = &roamInfo;
10283 }
10284 else
10285 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010286 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -070010287 }
10288 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
10289 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
10290 }
10291 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010292 case eSIR_SME_IBSS_INACTIVE:
10293 sessionId = csrFindIbssSession( pMac );
10294 if( CSR_SESSION_ID_INVALID != sessionId )
10295 {
10296 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010297 if(!pSession)
10298 {
10299 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10300 return;
10301 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010302 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
10303 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
10304 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
10305 }
10306 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010307 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
10308 sessionId = csrFindIbssSession( pMac );
10309 if( CSR_SESSION_ID_INVALID != sessionId )
10310 {
10311 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010312 if(!pSession)
10313 {
10314 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10315 return;
10316 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010317 // update the connection state information
10318 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010319#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10320 {
10321 vos_log_ibss_pkt_type *pIbssLog;
10322 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -070010323 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10324 if(pIbssLog)
10325 {
10326 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
10327 if(pNewBss)
10328 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010329 vos_mem_copy(pIbssLog->bssid, pNewBss->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010330 if(pNewBss->ssId.length)
10331 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010332 vos_mem_copy(pIbssLog->ssid, pNewBss->ssId.ssId,
10333 pNewBss->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070010334 }
10335 pIbssLog->operatingChannel = pNewBss->channelNumber;
10336 }
10337 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
10338 {
10339 //***U8 is not enough for beacon interval
10340 pIbssLog->beaconInterval = (v_U8_t)bi;
10341 }
10342 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10343 }
10344 }
10345#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010346 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
Shailender Karmuchi642e9812013-05-30 14:34:49 -070010347
10348 if ((eCSR_ENCRYPT_TYPE_NONE ==
10349 pSession->connectedProfile.EncryptionType ))
10350 {
10351 csrRoamIssueSetContextReq( pMac, sessionId,
10352 pSession->connectedProfile.EncryptionType,
10353 pSession->pConnectBssDesc,
10354 &Broadcastaddr,
10355 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
10356 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010357 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
10358 roamStatus = eCSR_ROAM_IBSS_IND;
Kiet Lam64c1b492013-07-12 13:56:44 +053010359 vos_mem_copy(&roamInfo.bssid, &pNewBss->bssId,
10360 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010361 pRoamInfo = &roamInfo;
10362 //This BSSID is th ereal BSSID, let's save it
10363 if(pSession->pConnectBssDesc)
10364 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010365 vos_mem_copy(pSession->pConnectBssDesc->bssId,
10366 &pNewBss->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010367 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010368 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010369 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070010370 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010371 // detection by LIM that the capabilities of the associated AP have changed.
10372 case eSIR_SME_AP_CAPS_CHANGED:
10373 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010374 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED");
Jeff Johnson295189b2012-06-20 16:38:30 -070010375 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
10376 if( HAL_STATUS_SUCCESS( status ) )
10377 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -080010378 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
10379 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010380 (eCSR_ROAM_SUBSTATE_NONE == pMac->roam.curSubState[sessionId]) ||
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -080010381 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
10382 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
10383 )
10384 {
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010385 smsLog(pMac, LOGW, "Calling csrRoamDisconnectInternal");
10386 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -080010387 }
10388 else
10389 {
10390 smsLog(pMac, LOGW,
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010391 FL("Skipping csrScanForCapabilityChange as "
10392 "CSR is in state %s and sub-state %s"),
10393 macTraceGetcsrRoamState(
10394 pMac->roam.curState[sessionId]),
10395 macTraceGetcsrRoamSubState(
10396 pMac->roam.curSubState[sessionId]));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010397 /* We ignore the caps change event if CSR is not in full connected state.
10398 * Send one event to PE to reset limSentCapsChangeNtf
10399 * Once limSentCapsChangeNtf set 0, lim can send sub sequent CAPS change event
10400 * otherwise lim cannot send any CAPS change events to SME */
10401 csrSendResetApCapsChanged(pMac, &pApNewCaps->bssId);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -080010402 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010403 }
10404 break;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +053010405
Jeff Johnson295189b2012-06-20 16:38:30 -070010406 default:
10407 roamStatus = eCSR_ROAM_FAILED;
10408 result = eCSR_ROAM_RESULT_NONE;
10409 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010410 } // end switch on statusChangeCode
10411 if(eCSR_ROAM_RESULT_NONE != result)
10412 {
10413 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
10414 }
10415 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010416 case eWNI_SME_IBSS_NEW_PEER_IND:
10417 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070010418#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10419 {
10420 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010421 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10422 if(pIbssLog)
10423 {
10424 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
Kiet Lam64c1b492013-07-12 13:56:44 +053010425 vos_mem_copy(pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010426 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10427 }
10428 }
10429#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010430 sessionId = csrFindIbssSession( pMac );
10431 if( CSR_SESSION_ID_INVALID != sessionId )
10432 {
10433 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010434
10435 if(!pSession)
10436 {
10437 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10438 return;
10439 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010440 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
10441 if(pSession->pConnectBssDesc)
10442 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010443 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
10444 sizeof(tCsrBssid));
10445 vos_mem_copy(&roamInfo.bssid, pSession->pConnectBssDesc->bssId,
10446 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010447 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
10448 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010449 roamInfo.pbFrames = vos_mem_malloc((pIbssPeerInd->mesgLen
10450 - sizeof(tSmeIbssPeerInd)));
10451 if ( NULL == roamInfo.pbFrames )
10452 status = eHAL_STATUS_FAILURE;
10453 else
10454 status = eHAL_STATUS_SUCCESS;
10455 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070010456 {
10457 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
Kiet Lam64c1b492013-07-12 13:56:44 +053010458 vos_mem_copy(roamInfo.pbFrames,
10459 ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
10460 roamInfo.nBeaconLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070010461 }
10462 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
10463 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
10464 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +053010465 roamInfo.pBssDesc = vos_mem_malloc(pSession->pConnectBssDesc->length);
10466 if ( NULL == roamInfo.pBssDesc )
10467 status = eHAL_STATUS_FAILURE;
10468 else
10469 status = eHAL_STATUS_SUCCESS;
10470 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070010471 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010472 vos_mem_copy(roamInfo.pBssDesc,
10473 pSession->pConnectBssDesc,
10474 pSession->pConnectBssDesc->length);
Jeff Johnson295189b2012-06-20 16:38:30 -070010475 }
10476 if(HAL_STATUS_SUCCESS(status))
10477 {
10478 pRoamInfo = &roamInfo;
10479 }
10480 else
10481 {
10482 if(roamInfo.pbFrames)
10483 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010484 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -070010485 }
10486 if(roamInfo.pBssDesc)
10487 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010488 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070010489 }
10490 }
10491 }
10492 else
10493 {
10494 pRoamInfo = &roamInfo;
10495 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070010496 if ((eCSR_ENCRYPT_TYPE_NONE ==
10497 pSession->connectedProfile.EncryptionType ))
10498 {
10499 csrRoamIssueSetContextReq( pMac, sessionId,
10500 pSession->connectedProfile.EncryptionType,
10501 pSession->pConnectBssDesc,
10502 &(pIbssPeerInd->peerAddr),
10503 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
10504 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010505 }
10506 else
10507 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010508 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -070010509 }
10510 //send up the sec type for the new peer
10511 if (pRoamInfo)
10512 {
10513 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
10514 }
10515 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
10516 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
10517 if(pRoamInfo)
10518 {
10519 if(roamInfo.pbFrames)
10520 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010521 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -070010522 }
10523 if(roamInfo.pBssDesc)
10524 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010525 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070010526 }
10527 }
10528 }
10529 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010530 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
10531 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
10532 sessionId = csrFindIbssSession( pMac );
10533 if( CSR_SESSION_ID_INVALID != sessionId )
10534 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010535#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10536 {
10537 vos_log_ibss_pkt_type *pIbssLog;
10538
10539 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10540 if(pIbssLog)
10541 {
10542 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
10543 if(pIbssPeerInd)
10544 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010545 vos_mem_copy(pIbssLog->peerMacAddr,
10546 &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010547 }
10548 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10549 }
10550 }
10551#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010552 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM");
Jeff Johnson295189b2012-06-20 16:38:30 -070010553 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
10554 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
10555 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +053010556 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
10557 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010558 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
10559 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
10560 }
10561 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010562 case eWNI_SME_SETCONTEXT_RSP:
10563 {
10564 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
10565 tListElem *pEntry;
10566 tSmeCmd *pCommand;
10567
10568 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10569 if ( pEntry )
10570 {
10571 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10572 if ( eSmeCommandSetKey == pCommand->command )
10573 {
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010574 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010575 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010576
10577 if(!pSession)
10578 {
10579 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10580 return;
10581 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010582
10583#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10584 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
10585 {
10586 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053010587 vos_mem_set(&setKeyEvent,
10588 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010589 if( pRsp->peerMacAddr[0] & 0x01 )
10590 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +053010591 setKeyEvent.eventId =
10592 WLAN_SECURITY_EVENT_SET_BCAST_RSP;
Jeff Johnson295189b2012-06-20 16:38:30 -070010593 }
10594 else
10595 {
Abhishek Singh9ecac4a2016-01-06 13:47:33 +053010596 setKeyEvent.eventId =
10597 WLAN_SECURITY_EVENT_SET_UNICAST_RSP;
Jeff Johnson295189b2012-06-20 16:38:30 -070010598 }
Padma, Santhosh Kumar110608e2015-04-22 18:12:17 +053010599 if( pRsp->peerMacAddr[0] & 0x01 )
10600 {
10601 pMac->pmc.remainInPowerActiveTillDHCP = FALSE;
10602 smsLog(pMac, LOG1, FL("Reset"
10603 "remainInPowerActiveTillDHCP to allow BMPS"));
10604 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010605 setKeyEvent.encryptionModeMulticast =
10606 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10607 setKeyEvent.encryptionModeUnicast =
10608 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010609 vos_mem_copy(setKeyEvent.bssid,
10610 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010611 setKeyEvent.authMode =
10612 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -070010613 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010614 {
10615 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10616 }
10617 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
10618 }
10619#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
10620 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
10621 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010622 csrRoamStopWaitForKeyTimer( pMac );
10623
Jeff Johnson295189b2012-06-20 16:38:30 -070010624 //We are done with authentication, whethere succeed or not
10625 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010626 //We do it here because this linkup function is not called after association
10627 //when a key needs to be set.
10628 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
10629 {
10630 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10631 }
10632 }
Jeff Johnson43971f52012-07-17 12:26:56 -070010633 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010634 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010635 vos_mem_copy(&roamInfo.peerMac,
10636 &pRsp->peerMacAddr, sizeof(tCsrBssid));
Jeff Johnsone7245742012-09-05 17:12:55 -070010637 //Make sure we install the GTK before indicating to HDD as authenticated
10638 //This is to prevent broadcast packets go out after PTK and before GTK.
Kiet Lam64c1b492013-07-12 13:56:44 +053010639 if ( vos_mem_compare( &Broadcastaddr, pRsp->peerMacAddr,
10640 sizeof(tSirMacAddr) ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070010641 {
Yathish9f22e662012-12-10 14:21:35 -080010642#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
10643 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
10644 {
10645 tpSirSetActiveModeSetBncFilterReq pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053010646 pMsg = vos_mem_malloc(sizeof(tSirSetActiveModeSetBncFilterReq));
Yathish9f22e662012-12-10 14:21:35 -080010647 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
Sreelakshmi Konamkidb3f75a2016-05-26 15:41:04 +053010648 pMsg->length = pal_cpu_to_be16(sizeof(
10649 tSirSetActiveModeSetBncFilterReq));
Yathish9f22e662012-12-10 14:21:35 -080010650 pMsg->seesionId = sessionId;
Sreelakshmi Konamkidb3f75a2016-05-26 15:41:04 +053010651 vos_mem_copy(pMsg->bssid,
10652 pSession->connectedProfile.bssid,
10653 sizeof(tSirMacAddr));
Yathish9f22e662012-12-10 14:21:35 -080010654 status = palSendMBMessage(pMac->hHdd, pMsg );
10655 }
10656#endif
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010657 /* OBSS SCAN Indication will be sent to Firmware to start OBSS Scan */
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010658 if( CSR_IS_CHANNEL_24GHZ(pSession->connectedProfile.operationChannel)
Hardik Kantilal Pateldb19a092014-11-21 17:01:42 +053010659 && IS_HT40_OBSS_SCAN_FEATURE_ENABLE
Padma, Santhosh Kumardf905172015-03-10 11:42:35 +053010660 && (pSession->connectState ==
10661 eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED)
10662 && pSession->pCurRoamProfile
Hardik Kantilal Pateldb19a092014-11-21 17:01:42 +053010663 && (VOS_P2P_GO_MODE !=
10664 pSession->pCurRoamProfile->csrPersona
10665 && VOS_STA_SAP_MODE !=
10666 pSession->pCurRoamProfile->csrPersona))
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010667 {
10668 tpSirSmeHT40OBSSScanInd pMsg;
10669 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSScanInd));
10670 pMsg->messageType =
10671 pal_cpu_to_be16((tANI_U16)eWNI_SME_HT40_OBSS_SCAN_IND);
10672 pMsg->length =
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010673 pal_cpu_to_be16(sizeof( tSirSmeHT40OBSSScanInd));
10674 vos_mem_copy(pMsg->peerMacAddr,
10675 pSession->connectedProfile.bssid,
10676 sizeof(tSirMacAddr));
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010677 status = palSendMBMessage(pMac->hHdd,
10678 pMsg );
10679 }
Padma, Santhosh Kumardf905172015-03-10 11:42:35 +053010680 else
10681 {
10682 smsLog( pMac, LOG1,FL("OBSS SCAN"
10683 "Indication not sent to FW"
10684 "channel %d OBSS_SCAN: %d"),
10685 pSession->connectedProfile.
10686 operationChannel,
10687 IS_HT40_OBSS_SCAN_FEATURE_ENABLE);
10688 smsLog( pMac, LOG1,FL("connectState %d"
10689 "pCurRoamProfile %p"),
10690 pSession->connectState,
10691 pSession->pCurRoamProfile);
10692 }
10693
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010694 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -070010695 }
10696 else
10697 {
10698 result = eCSR_ROAM_RESULT_NONE;
10699 }
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010700 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010701 }
10702 else
10703 {
10704 result = eCSR_ROAM_RESULT_FAILURE;
Arif Hussaina7c8e412013-11-20 11:06:42 -080010705 smsLog(pMac, LOGE, "CSR: Roam Completion setkey "
10706 "command failed(%d) PeerMac "MAC_ADDRESS_STR,
10707 pRsp->statusCode, MAC_ADDR_ARRAY(pRsp->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070010708 }
Padma, Santhosh Kumarc3eca802016-02-17 19:58:28 +053010709 roamInfo.is11rAssoc = csrRoamIs11rAssoc(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010710 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10711 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -070010712 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
10713 // can go ahead and initiate the TSPEC if any are pending
10714 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010715#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070010716 //Send Adjacent AP repot to new AP.
10717 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
10718 pSession->isPrevApInfoValid &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010719 pSession->connectedProfile.isESEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070010720 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010721#ifdef FEATURE_WLAN_ESE_UPLOAD
10722 csrSendEseAdjacentApRepInd(pMac, pSession);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010723#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010724 csrEseSendAdjacentApRepMsg(pMac, pSession);
Jeff Johnson295189b2012-06-20 16:38:30 -070010725#endif
10726 pSession->isPrevApInfoValid = FALSE;
10727 }
10728#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010729 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10730 {
10731 csrReleaseCommandSetKey( pMac, pCommand );
10732 }
10733 }
10734 else
10735 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010736 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010737 }
10738 }
10739 else
10740 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010741 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010742 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010743 smeProcessPendingQueue( pMac );
10744 }
10745 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010746 case eWNI_SME_REMOVEKEY_RSP:
10747 {
10748 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
10749 tListElem *pEntry;
10750 tSmeCmd *pCommand;
10751
10752 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10753 if ( pEntry )
10754 {
10755 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10756 if ( eSmeCommandRemoveKey == pCommand->command )
10757 {
10758 sessionId = pCommand->sessionId;
10759 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010760
10761 if(!pSession)
10762 {
10763 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10764 return;
10765 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010766#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10767 {
10768 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053010769 vos_mem_set(&removeKeyEvent,
10770 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010771 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
10772 removeKeyEvent.encryptionModeMulticast =
10773 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10774 removeKeyEvent.encryptionModeUnicast =
10775 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010776 vos_mem_copy( removeKeyEvent.bssid,
10777 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010778 removeKeyEvent.authMode =
10779 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -070010780 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010781 {
10782 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10783 }
10784 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
10785 }
10786#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -070010787 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010788 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010789 vos_mem_copy(&roamInfo.peerMac, &pRsp->peerMacAddr,
10790 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010791 result = eCSR_ROAM_RESULT_NONE;
10792 pRoamInfo = &roamInfo;
10793 }
10794 else
10795 {
10796 result = eCSR_ROAM_RESULT_FAILURE;
10797 }
10798 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10799 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
10800 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10801 {
10802 csrReleaseCommandRemoveKey( pMac, pCommand );
10803 }
10804 }
10805 else
10806 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010807 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010808 }
10809 }
10810 else
10811 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010812 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010813 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010814 smeProcessPendingQueue( pMac );
10815 }
10816 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010817 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010818 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010819 csrRoamStatsRspProcessor( pMac, pSirMsg );
10820 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010821#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080010822 case eWNI_SME_GET_ROAM_RSSI_RSP:
10823 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
10824 csrRoamRssiRspProcessor( pMac, pSirMsg );
10825 break;
10826#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010827#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010828 case eWNI_SME_GET_TSM_STATS_RSP:
10829 smsLog( pMac, LOG2, FL("TSM Stats rsp from PE"));
10830 csrTsmStatsRspProcessor( pMac, pSirMsg );
10831 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010832#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -070010833 case eWNI_SME_GET_RSSI_REQ:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010834 smsLog( pMac, LOG2, FL("GetRssiReq from self"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010835 csrUpdateRssi( pMac, pSirMsg );
10836 break;
10837
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053010838 case eWNI_SME_GET_SNR_REQ:
10839 smsLog( pMac, LOG2, FL("GetSnrReq from self"));
10840 csrUpdateSnr(pMac, pSirMsg);
10841 break;
10842
Jeff Johnson295189b2012-06-20 16:38:30 -070010843#ifdef WLAN_FEATURE_VOWIFI_11R
10844 case eWNI_SME_FT_PRE_AUTH_RSP:
10845 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
10846 break;
10847#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010848 case eWNI_SME_MAX_ASSOC_EXCEEDED:
10849 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010850 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 -070010851 sessionId = pSmeMaxAssocInd->sessionId;
10852 roamInfo.sessionId = sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053010853 vos_mem_copy(&roamInfo.peerMac, pSmeMaxAssocInd->peerMac,
10854 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010855 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
10856 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
10857 break;
10858
10859 case eWNI_SME_BTAMP_LOG_LINK_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010860 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010861 btampEstablishLogLinkHdlr( pSirMsg );
10862 break;
Jeff Johnsone7245742012-09-05 17:12:55 -070010863 case eWNI_SME_RSSI_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010864 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread"));
Jeff Johnsone7245742012-09-05 17:12:55 -070010865 csrRoamRssiIndHdlr( pMac, pSirMsg );
10866 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010867#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
10868 case eWNI_SME_CANDIDATE_FOUND_IND:
10869 smsLog( pMac, LOG2, FL("Candidate found indication from PE"));
10870 csrNeighborRoamCandidateFoundIndHdlr( pMac, pSirMsg );
10871 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070010872 case eWNI_SME_HANDOFF_REQ:
10873 smsLog( pMac, LOG2, FL("Handoff Req from self"));
10874 csrNeighborRoamHandoffReqHdlr( pMac, pSirMsg );
10875 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010876#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010877
10878 default:
10879 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010880 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -070010881}
10882
Jeff Johnson295189b2012-06-20 16:38:30 -070010883void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
10884 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
10885{
10886 if(pSession)
10887 {
10888 if(pSession->bRefAssocStartCnt)
10889 {
10890 pSession->bRefAssocStartCnt--;
10891 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
10892 //Need to call association_completion because there is an assoc_start pending.
10893 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
10894 eCSR_ROAM_ASSOCIATION_COMPLETION,
10895 eCSR_ROAM_RESULT_FAILURE);
10896 }
10897 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
10898 }
10899 else
10900 {
10901 smsLog(pMac, LOGW, FL(" pSession is NULL"));
10902 }
10903}
10904
10905
10906eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
10907{
10908 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010909 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
10910 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
10911 {
10912 status = csrScanRequestLostLink1( pMac, sessionId );
10913 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010914 return(status);
10915}
10916
Jeff Johnson295189b2012-06-20 16:38:30 -070010917//return a boolean to indicate whether roaming completed or continue.
10918tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
10919 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
10920{
10921 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
10922 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
10923 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10924 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010925 if(!pSession)
10926 {
10927 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10928 return eANI_BOOLEAN_FALSE;
10929 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010930 //Check whether time is up
10931 if(pSession->fCancelRoaming || fForce ||
10932 ((curTime - pSession->roamingStartTime) > roamTime) ||
10933 eCsrReassocRoaming == pSession->roamingReason ||
10934 eCsrDynamicRoaming == pSession->roamingReason)
10935 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010936 smsLog(pMac, LOGW, FL(" indicates roaming completion"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010937 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
10938 {
10939 //roaming is cancelled, tell HDD to indicate disconnect
10940 //Because LIM overload deauth_ind for both deauth frame and missed beacon
10941 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
10942 //to be eSIR_BEACON_MISSED
10943 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
10944 {
10945 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10946 }
10947 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
10948 {
10949 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
10950 }
10951 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
10952 {
10953 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
10954 }
10955 else
10956 {
10957 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10958 }
10959 }
10960 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10961 pSession->roamingReason = eCsrNotRoaming;
10962 }
10963 else
10964 {
10965 pSession->roamResult = roamResult;
10966 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
10967 {
10968 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10969 pSession->roamingReason = eCsrNotRoaming;
10970 }
10971 else
10972 {
10973 fCompleted = eANI_BOOLEAN_FALSE;
10974 }
10975 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010976 return(fCompleted);
10977}
10978
Jeff Johnson295189b2012-06-20 16:38:30 -070010979void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
10980{
10981 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010982
10983 if(!pSession)
10984 {
10985 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10986 return;
10987 }
10988
Jeff Johnson295189b2012-06-20 16:38:30 -070010989 if(CSR_IS_ROAMING(pSession))
10990 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010991 smsLog(pMac, LOGW, " Cancelling roaming");
Jeff Johnson295189b2012-06-20 16:38:30 -070010992 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
10993 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
10994 {
10995 //No need to do anything in here because the handler takes care of it
10996 }
10997 else
10998 {
10999 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
11000 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
11001 //Roaming is stopped after here
11002 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
11003 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053011004 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Jeff Johnson295189b2012-06-20 16:38:30 -070011005 csrRoamStopRoamingTimer(pMac, sessionId);
11006 }
11007 }
11008}
11009
Jeff Johnson295189b2012-06-20 16:38:30 -070011010void csrRoamRoamingTimerHandler(void *pv)
11011{
11012 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
11013 tpAniSirGlobal pMac = pInfo->pMac;
11014 tANI_U32 sessionId = pInfo->sessionId;
11015 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011016
11017 if(!pSession)
11018 {
11019 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11020 return;
11021 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011022
11023 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
11024 {
11025 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
11026 {
11027 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
11028 pSession->roamingReason = eCsrNotRoaming;
11029 }
11030 }
11031}
11032
Jeff Johnson295189b2012-06-20 16:38:30 -070011033eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
11034{
11035 eHalStatus status;
11036 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011037
11038 if(!pSession)
11039 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011040 smsLog(pMac, LOGE, FL(" session %d not found"), sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -070011041 return eHAL_STATUS_FAILURE;
11042 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011043
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011044 smsLog(pMac, LOG1, " csrScanStartRoamingTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070011045 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053011046 status = vos_timer_start(&pSession->hTimerRoaming, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070011047
11048 return (status);
11049}
11050
Jeff Johnson295189b2012-06-20 16:38:30 -070011051eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
11052{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053011053 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerRoaming));
Jeff Johnson295189b2012-06-20 16:38:30 -070011054}
11055
Jeff Johnson295189b2012-06-20 16:38:30 -070011056void csrRoamWaitForKeyTimeOutHandler(void *pv)
11057{
11058 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
11059 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011060 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080011061 eHalStatus status = eHAL_STATUS_FAILURE;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011062
Agrawal Ashishf9cf2be2016-02-25 11:25:42 +053011063 smsLog(pMac, LOGE, FL("WaitForKey timer expired in state=%s sub-state=%s"),
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053011064 macTraceGetNeighbourRoamState(
11065 pMac->roam.neighborRoamInfo.neighborRoamState),
11066 macTraceGetcsrRoamSubState(
11067 pMac->roam.curSubState[pInfo->sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011068
Jeff Johnson295189b2012-06-20 16:38:30 -070011069 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
11070 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011071#ifdef FEATURE_WLAN_LFR
11072 if (csrNeighborRoamIsHandoffInProgress(pMac))
11073 {
11074 /*
11075 * Enable heartbeat timer when hand-off is in progress
11076 * and Key Wait timer expired.
11077 */
11078 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011079 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011080 pMac->roam.configParam.HeartbeatThresh24);
11081 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
11082 pMac->roam.configParam.HeartbeatThresh24,
11083 NULL, eANI_BOOLEAN_FALSE);
11084 }
11085#endif
Agrawal Ashishf9cf2be2016-02-25 11:25:42 +053011086 smsLog(pMac, LOGE, " SME pre-auth state timeout. ");
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070011087
Jeff Johnson295189b2012-06-20 16:38:30 -070011088 //Change the substate so command queue is unblocked.
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070011089 if (CSR_ROAM_SESSION_MAX > pInfo->sessionId)
11090 {
11091 csrRoamSubstateChange(pMac, eCSR_ROAM_SUBSTATE_NONE,
11092 pInfo->sessionId);
11093 }
11094
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011095 if (pSession)
11096 {
11097 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
11098 {
11099 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
11100 smeProcessPendingQueue(pMac);
Agrawal Ashishf9cf2be2016-02-25 11:25:42 +053011101 status = sme_AcquireGlobalLock(&pMac->sme);
11102 if (HAL_STATUS_SUCCESS(status))
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080011103 {
Agrawal Ashishf9cf2be2016-02-25 11:25:42 +053011104 csrRoamDisconnect(pMac, pInfo->sessionId,
11105 eCSR_DISCONNECT_REASON_UNSPECIFIED);
11106 sme_ReleaseGlobalLock(&pMac->sme);
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080011107 }
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011108 }
11109 else
11110 {
Agrawal Ashishf9cf2be2016-02-25 11:25:42 +053011111 smsLog(pMac, LOGE, FL("Session id %d is disconnected"),
11112 pInfo->sessionId);
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011113 }
11114 }
11115 else
11116 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011117 smsLog(pMac, LOGW, "%s: session not found", __func__);
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011118 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011119 }
11120
11121}
11122
Jeff Johnson295189b2012-06-20 16:38:30 -070011123eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
11124{
11125 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011126#ifdef FEATURE_WLAN_LFR
11127 if (csrNeighborRoamIsHandoffInProgress(pMac))
11128 {
11129 /* Disable heartbeat timer when hand-off is in progress */
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053011130 smsLog(pMac, LOG2, FL("disabling HB timer in state=%s sub-state=%s"),
11131 macTraceGetNeighbourRoamState(
11132 pMac->roam.neighborRoamInfo.neighborRoamState),
11133 macTraceGetcsrRoamSubState(
11134 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]
11135 ));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011136 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
11137 }
11138#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011139 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053011140 status = vos_timer_start(&pMac->roam.hTimerWaitForKey, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070011141
11142 return (status);
11143}
11144
Jeff Johnson295189b2012-06-20 16:38:30 -070011145eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
11146{
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053011147 smsLog(pMac, LOG2, FL("WaitForKey timer stopped in state=%s sub-state=%s"),
11148 macTraceGetNeighbourRoamState(
11149 pMac->roam.neighborRoamInfo.neighborRoamState),
11150 macTraceGetcsrRoamSubState(
11151 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011152#ifdef FEATURE_WLAN_LFR
11153 if (csrNeighborRoamIsHandoffInProgress(pMac))
11154 {
11155 /*
11156 * Enable heartbeat timer when hand-off is in progress
11157 * and Key Wait timer got stopped for some reason
11158 */
11159 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011160 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080011161 pMac->roam.configParam.HeartbeatThresh24);
11162 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
11163 pMac->roam.configParam.HeartbeatThresh24,
11164 NULL, eANI_BOOLEAN_FALSE);
11165 }
11166#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053011167 return (vos_timer_stop(&pMac->roam.hTimerWaitForKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070011168}
11169
Jeff Johnson295189b2012-06-20 16:38:30 -070011170void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
11171 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
11172{
11173 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
11174 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070011175 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11176 /* To silence the KW tool Null chaeck is added */
11177 if(!pSession)
11178 {
11179 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11180 return;
11181 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011182
11183 if(pCommand)
11184 {
11185 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -070011186 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011187 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011188 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
11189 {
11190 //if success, force roaming completion
11191 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
11192 }
11193 else
11194 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070011195 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011196 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d"), roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -070011197 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
11198 }
11199}
11200
Jeff Johnson295189b2012-06-20 16:38:30 -070011201eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
11202{
11203 eHalStatus status = eHAL_STATUS_SUCCESS;
11204 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
11205 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
11206 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
11207 tCsrRoamInfo *pRoamInfo = NULL;
11208 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070011209 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -070011210 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070011211 /* To silence the KW tool Null chaeck is added */
11212 if(!pSession)
11213 {
11214 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11215 return eHAL_STATUS_FAILURE;
11216 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011217 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070011218 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -070011219 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
11220 if ( eWNI_SME_DISASSOC_IND == type )
11221 {
11222 result = eCSR_ROAM_RESULT_DISASSOC_IND;
11223 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
11224 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070011225 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070011226 }
11227 else if ( eWNI_SME_DEAUTH_IND == type )
11228 {
11229 result = eCSR_ROAM_RESULT_DEAUTH_IND;
11230 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
11231 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Selvaraj, Sridhara9545d92016-06-08 17:38:20 +053011232 pSession->joinFailStatusCode.reasonCode = pDeauthIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070011233 }
11234 else
11235 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011236 smsLog(pMac, LOGW, FL("gets an unknown type (%d)"), type);
Jeff Johnson295189b2012-06-20 16:38:30 -070011237 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070011238 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070011239 }
11240
11241 // call profile lost link routine here
Jeff Johnson295189b2012-06-20 16:38:30 -070011242 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -070011243 {
11244 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_LOSTLINK_DETECTED, result);
11245 }
11246
11247 if ( eWNI_SME_DISASSOC_IND == type )
11248 {
11249 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
11250 }
11251 else if ( eWNI_SME_DEAUTH_IND == type )
11252 {
11253 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
11254 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011255 if(!HAL_STATUS_SUCCESS(status))
11256 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080011257 //If fail to send confirmation to PE, not to trigger roaming
11258 fToRoam = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011259 }
11260
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080011261 //prepare to tell HDD to disconnect
Kiet Lam64c1b492013-07-12 13:56:44 +053011262 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011263 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
11264 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070011265 if( eWNI_SME_DISASSOC_IND == type)
11266 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080011267 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053011268 vos_mem_copy(roamInfo.peerMac, pDisassocIndMsg->peerMacAddr,
11269 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080011270 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
11271 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011272 else if( eWNI_SME_DEAUTH_IND == type )
11273 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080011274 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053011275 vos_mem_copy(roamInfo.peerMac, pDeauthIndMsg->peerMacAddr,
11276 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080011277 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
11278 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011279 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)"), roamInfo.staId);
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080011280
11281 /* See if we can possibly roam. If so, start the roaming process and notify HDD
11282 that we are roaming. But if we cannot possibly roam, or if we are unable to
11283 currently roam, then notify HDD of the lost link */
Jeff Johnson295189b2012-06-20 16:38:30 -070011284 if(fToRoam)
11285 {
11286 //Only remove the connected BSS in infrastructure mode
11287 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
11288 //Not to do anying for lostlink with WDS
11289 if( pMac->roam.configParam.nRoamingTime )
11290 {
11291 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
11292 ( eWNI_SME_DEAUTH_IND == type ) ?
11293 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
11294 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011295 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011296 //For IBSS, we need to give some more info to HDD
11297 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
11298 {
11299 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
11300 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
11301 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
11302 }
11303 else
11304 {
11305 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
11306 }
Jeff Johnsone7245742012-09-05 17:12:55 -070011307 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070011308 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
11309 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
11310 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
11311 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
11312 }
11313 else
11314 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070011315 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -070011316 fToRoam = eANI_BOOLEAN_FALSE;
11317 }
11318 }
11319 else
11320 {
11321 //We are told not to roam, indicate lostlink
11322 fToRoam = eANI_BOOLEAN_FALSE;
11323 }
11324 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011325 if(!fToRoam)
11326 {
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080011327 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -070011328 Still enable idle scan for polling in case concurrent sessions are running */
11329 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
11330 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080011331 csrScanStartIdleScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070011332 }
11333 }
11334
11335 return (status);
11336}
11337
Jeff Johnson295189b2012-06-20 16:38:30 -070011338eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
11339{
11340 eHalStatus status = eHAL_STATUS_SUCCESS;
11341 tListElem *pEntry = NULL;
11342 tSmeCmd *pCommand = NULL;
11343 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011344
11345 if(!pSession)
11346 {
11347 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11348 return eHAL_STATUS_FAILURE;
11349 }
11350
Jeff Johnson295189b2012-06-20 16:38:30 -070011351 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011352 //Only remove the connected BSS in infrastructure mode
11353 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
11354 if(pMac->roam.configParam.nRoamingTime)
11355 {
11356 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
11357 {
11358 //before starting the lost link logic release the roam command for handoff
11359 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
11360 if(pEntry)
11361 {
11362 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
11363 }
11364 if(pCommand)
11365 {
11366 if (( eSmeCommandRoam == pCommand->command ) &&
11367 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
11368 {
11369 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
11370 {
11371 csrReleaseCommandRoam( pMac, pCommand );
11372 }
11373 }
11374 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011375 smsLog( pMac, LOGW, "Lost link roaming started ...");
Jeff Johnson295189b2012-06-20 16:38:30 -070011376 }
11377 }
11378 else
11379 {
11380 //We are told not to roam, indicate lostlink
11381 status = eHAL_STATUS_FAILURE;
11382 }
11383
11384 return (status);
11385}
Jeff Johnson295189b2012-06-20 16:38:30 -070011386void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
11387{
11388 tListElem *pEntry;
11389 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070011390 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
11391 if ( pEntry )
11392 {
11393 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
11394 if ( eSmeCommandWmStatusChange == pCommand->command )
11395 {
11396 // Nothing to process in a Lost Link completion.... It just kicks off a
11397 // roaming sequence.
11398 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
11399 {
11400 csrReleaseCommandWmStatusChange( pMac, pCommand );
11401 }
11402 else
11403 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011404 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command");
Jeff Johnson295189b2012-06-20 16:38:30 -070011405 }
11406
11407 }
11408 else
11409 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011410 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070011411 }
11412 }
11413 else
11414 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011415 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070011416 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011417 smeProcessPendingQueue( pMac );
11418}
11419
Jeff Johnson295189b2012-06-20 16:38:30 -070011420void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
11421{
11422 eHalStatus status = eHAL_STATUS_FAILURE;
11423 tSirSmeRsp *pSirSmeMsg;
11424 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011425
11426 if(!pSession)
11427 {
11428 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
11429 return;
11430 }
Sachin Ahuja2fea3d12014-12-18 17:31:31 +053011431 smsLog(pMac, LOG1, FL("session:%d, CmdType : %d"),
11432 pCommand->sessionId,
11433 pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070011434 switch ( pCommand->u.wmStatusChangeCmd.Type )
11435 {
11436 case eCsrDisassociated:
11437 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
11438 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
11439 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011440 case eCsrDeauthenticated:
11441 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
11442 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
11443 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011444 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011445 smsLog(pMac, LOGW, FL("gets an unknown command %d"), pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070011446 break;
11447 }
11448 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
11449 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
11450 {
11451 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
11452 {
11453 //This is not good
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011454 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011455 }
11456 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011457 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
11458 // command here since there is nothing else to do.
11459 csrRoamWmStatusChangeComplete( pMac );
11460}
11461
Jeff Johnson295189b2012-06-20 16:38:30 -070011462//This function returns band and mode information.
11463//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
11464//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -070011465static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
11466 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -070011467{
Jeff Johnson295189b2012-06-20 16:38:30 -070011468 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
11469 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
11470 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070011471 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -070011472
Jeff Johnson295189b2012-06-20 16:38:30 -070011473 //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 -070011474 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
11475 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
11476 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
11477 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011478 {
11479 switch( pMac->roam.configParam.uCfgDot11Mode )
11480 {
11481 case eCSR_CFG_DOT11_MODE_11A:
11482 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11483 eBand = eCSR_BAND_5G;
11484 break;
11485 case eCSR_CFG_DOT11_MODE_11B:
11486 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11487 eBand = eCSR_BAND_24;
11488 break;
11489 case eCSR_CFG_DOT11_MODE_11G:
11490 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
11491 eBand = eCSR_BAND_24;
11492 break;
11493 case eCSR_CFG_DOT11_MODE_11N:
11494 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011495 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11496 break;
11497#ifdef WLAN_FEATURE_11AC
11498 case eCSR_CFG_DOT11_MODE_11AC:
11499 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11500 {
Ravi Joshiacc81822013-10-10 15:30:41 -070011501 /* If the operating channel is in 2.4 GHz band, check for
11502 * INI item to disable VHT operation in 2.4 GHz band
11503 */
11504 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11505 !pMac->roam.configParam.enableVhtFor24GHz)
11506 {
11507 /* Disable 11AC operation */
11508 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11509 }
11510 else
11511 {
11512 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
11513 }
11514 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011515 }
11516 else
11517 {
11518 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11519 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11520 }
11521 break;
11522 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
11523 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11524 {
Ravi Joshiacc81822013-10-10 15:30:41 -070011525 /* If the operating channel is in 2.4 GHz band, check for
11526 * INI item to disable VHT operation in 2.4 GHz band
11527 */
11528 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11529 !pMac->roam.configParam.enableVhtFor24GHz)
11530 {
11531 /* Disable 11AC operation */
11532 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11533 }
11534 else
11535 {
11536 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
11537 }
11538 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011539 }
11540 else
11541 {
11542 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11543 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11544 }
11545 break;
11546#endif
11547 case eCSR_CFG_DOT11_MODE_AUTO:
Ravi Joshia96ceb42013-05-20 18:52:39 -070011548#ifdef WLAN_FEATURE_11AC
Abhishek Singh03c39422014-09-24 10:52:30 +053011549 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11550 {
11551 /* If the operating channel is in 2.4 GHz band, check for
11552 * INI item to disable VHT operation in 2.4 GHz band
11553 */
11554 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11555 !pMac->roam.configParam.enableVhtFor24GHz)
Ravi Joshia96ceb42013-05-20 18:52:39 -070011556 {
Abhishek Singh03c39422014-09-24 10:52:30 +053011557 /* Disable 11AC operation */
11558 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011559 }
11560 else
11561 {
Abhishek Singh03c39422014-09-24 10:52:30 +053011562 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
11563 }
11564 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11565 }
11566 else
11567 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070011568 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11569 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011570 }
Abhishek Singh03c39422014-09-24 10:52:30 +053011571#else
11572 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11573 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11574#endif
Ravi Joshia96ceb42013-05-20 18:52:39 -070011575 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011576 default:
11577 // Global dot11 Mode setting is 11a/b/g.
11578 // use the channel number to determine the Mode setting.
11579 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
11580 {
11581 eBand = pMac->roam.configParam.eBand;
11582 if(eCSR_BAND_24 == eBand)
11583 {
11584 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
11585 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11586 }
11587 else
11588 {
11589 //prefer 5GHz
11590 eBand = eCSR_BAND_5G;
11591 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11592 }
11593 }
11594 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11595 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070011596 // WiFi tests require IBSS networks to start in 11b mode
11597 // without any change to the default parameter settings
11598 // on the adapter. We use ACU to start an IBSS through
11599 // creation of a startIBSS profile. This startIBSS profile
11600 // has Auto MACProtocol and the adapter property setting
11601 // for dot11Mode is also AUTO. So in this case, let's
11602 // start the IBSS network in 11b mode instead of 11g mode.
11603 // So this is for Auto=profile->MacProtocol && Auto=Global.
11604 // dot11Mode && profile->channel is < 14, then start the IBSS
11605 // in b mode.
Jeff Johnson295189b2012-06-20 16:38:30 -070011606 //
Ravi Joshia96ceb42013-05-20 18:52:39 -070011607 // Note: we used to have this start as an 11g IBSS for best
11608 // performance... now to specify that the user will have to
11609 // set the do11Mode in the property page to 11g to force it.
Jeff Johnson295189b2012-06-20 16:38:30 -070011610 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11611 eBand = eCSR_BAND_24;
11612 }
11613 else
11614 {
11615 // else, it's a 5.0GHz channel. Set mode to 11a.
11616 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11617 eBand = eCSR_BAND_5G;
11618 }
11619 break;
11620 }//switch
11621 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
11622 else
11623 {
11624 //dot11 mode is set, lets pick the band
11625 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
11626 {
11627 // channel is Auto also.
11628 eBand = pMac->roam.configParam.eBand;
11629 if(eCSR_BAND_ALL == eBand)
11630 {
11631 //prefer 5GHz
11632 eBand = eCSR_BAND_5G;
11633 }
11634 }
11635 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11636 {
11637 eBand = eCSR_BAND_24;
11638 }
11639 else
11640 {
11641 eBand = eCSR_BAND_5G;
11642 }
Ravi Joshia96ceb42013-05-20 18:52:39 -070011643 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011644 if(pBand)
11645 {
11646 *pBand = eBand;
11647 }
11648
11649 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011650 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -070011651 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11652 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011653
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080011654 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
11655 if( (!CSR_IS_11n_ALLOWED(pProfile->EncryptionType.encryptionType[0] ) || ((pProfile->privacy == 1) && (pProfile->EncryptionType.encryptionType[0] == eCSR_ENCRYPT_TYPE_NONE)) ) &&
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011656 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011657#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011658 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011659#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011660 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
11661 {
11662 //We cannot do 11n here
11663 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11664 {
11665 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
11666 }
11667 else
11668 {
11669 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11670 }
11671 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011672 return( cfgDot11Mode );
11673}
11674
Jeff Johnson295189b2012-06-20 16:38:30 -070011675eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
11676{
11677 eHalStatus status;
11678 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011679
11680 if(!pSession)
11681 {
11682 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11683 return eHAL_STATUS_FAILURE;
11684 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011685
11686#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11687 {
11688 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011689 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11690 if(pIbssLog)
11691 {
11692 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
11693 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11694 }
11695 }
11696#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011697 // Set the roaming substate to 'stop Bss request'...
11698 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
11699
11700 // attempt to stop the Bss (reason code is ignored...)
11701 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080011702 if(!HAL_STATUS_SUCCESS(status))
11703 {
11704 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
11705 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011706 return (status);
11707}
11708
Jeff Johnson295189b2012-06-20 16:38:30 -070011709//pNumChan is a caller allocated space with the sizeof pChannels
11710eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
11711{
11712
11713 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
11714 (tANI_U8 *)pChannels,
11715 pNumChan));
11716}
11717
Kiran4a17ebe2013-01-31 10:43:43 -080011718tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
11719{
11720 tANI_U32 cfgLength = 0;
11721 tANI_U16 cfgId = 0;
11722 tPowerdBm maxTxPwr = 0;
11723 tANI_U8 *pCountryInfo = NULL;
11724 eHalStatus status;
11725 tANI_U8 count = 0;
11726 tANI_U8 firstChannel;
11727 tANI_U8 maxChannels;
11728
11729 if (CSR_IS_CHANNEL_5GHZ(channel))
11730 {
11731 cfgId = WNI_CFG_MAX_TX_POWER_5;
11732 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
11733 }
11734 else if (CSR_IS_CHANNEL_24GHZ(channel))
11735 {
11736 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
11737 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
11738 }
11739 else
11740 return maxTxPwr;
11741
Kiet Lam64c1b492013-07-12 13:56:44 +053011742 pCountryInfo = vos_mem_malloc(cfgLength);
11743 if ( NULL == pCountryInfo )
11744 status = eHAL_STATUS_FAILURE;
11745 else
11746 status = eHAL_STATUS_SUCCESS;
Kiran4a17ebe2013-01-31 10:43:43 -080011747 if (status != eHAL_STATUS_SUCCESS)
11748 {
11749 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiet Lam64c1b492013-07-12 13:56:44 +053011750 FL("%s: failed to allocate memory, status = %d"),
Kiran4a17ebe2013-01-31 10:43:43 -080011751 __FUNCTION__, status);
11752 goto error;
11753 }
11754 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
11755 if (status != eHAL_STATUS_SUCCESS)
11756 {
11757 goto error;
11758 }
11759 /* Identify the channel and maxtxpower */
11760 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
11761 {
11762 firstChannel = pCountryInfo[count++];
11763 maxChannels = pCountryInfo[count++];
11764 maxTxPwr = pCountryInfo[count++];
11765
11766 if ((channel >= firstChannel) &&
11767 (channel < (firstChannel + maxChannels)))
11768 {
11769 break;
11770 }
11771 }
11772
11773error:
11774 if (NULL != pCountryInfo)
Kiet Lam64c1b492013-07-12 13:56:44 +053011775 vos_mem_free(pCountryInfo);
Kiran4a17ebe2013-01-31 10:43:43 -080011776
11777 return maxTxPwr;
11778}
11779
11780
Jeff Johnson295189b2012-06-20 16:38:30 -070011781tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
11782{
11783 tANI_BOOLEAN fValid = FALSE;
11784 tANI_U32 idxValidChannels;
11785 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11786
11787 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
11788 {
11789 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
11790 {
11791 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
11792 {
11793 fValid = TRUE;
11794 break;
11795 }
11796 }
11797 }
11798 pMac->roam.numValidChannels = len;
11799 return fValid;
11800}
11801
Jeff Johnson295189b2012-06-20 16:38:30 -070011802tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
11803{
11804 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
11805 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011806 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
11807 {
11808 if(channel == pMac->scan.base40MHzChannels.channelList[i])
11809 {
11810 fValid = eANI_BOOLEAN_TRUE;
11811 break;
11812 }
11813 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011814 return (fValid);
11815}
11816
Jeff Johnson295189b2012-06-20 16:38:30 -070011817//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070011818 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011819{
Jeff Johnsone7245742012-09-05 17:12:55 -070011820 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011821 tANI_U8 centerChn;
11822 tANI_U32 ChannelBondingMode;
Sandeep Puligilla60342762014-01-30 21:05:37 +053011823
Jeff Johnson295189b2012-06-20 16:38:30 -070011824 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
11825 {
11826 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
11827 }
11828 else
11829 {
11830 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
11831 }
11832 //Figure what the other side's CB mode
11833 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
11834 {
11835 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
11836 {
Agrawal Ashishf187d512014-04-03 17:01:52 +053011837 // In Case WPA2 and TKIP is the only one cipher suite in Pairwise.
11838 if ((pIes->RSN.present && (pIes->RSN.pwise_cipher_suite_count == 1) &&
11839 !memcmp(&(pIes->RSN.pwise_cipher_suites[0][0]),
11840 "\x00\x0f\xac\x02",4))
Abhishek Singhfd8afeb2014-10-15 11:55:45 +053011841 //In Case only WPA1 is supported and TKIP is the only one cipher suite in Unicast.
11842 ||( !pIes->RSN.present && (pIes->WPA.present && (pIes->WPA.unicast_cipher_count == 1) &&
Agrawal Ashishf187d512014-04-03 17:01:52 +053011843 !memcmp(&(pIes->WPA.unicast_ciphers[0][0]),
Abhishek Singhfd8afeb2014-10-15 11:55:45 +053011844 "\x00\x50\xf2\x02",4))))
Agrawal Ashishf187d512014-04-03 17:01:52 +053011845
Leela Venkata Kiran Kumar Reddy Chirala10c5a2e2013-12-18 14:41:28 -080011846 {
11847 smsLog(pMac, LOGW, " No channel bonding in TKIP mode ");
11848 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11849 }
11850
11851 else if(pIes->HTInfo.present)
Jeff Johnson295189b2012-06-20 16:38:30 -070011852 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011853 /* This is called during INFRA STA/CLIENT and should use the merged value of
11854 * supported channel width and recommended tx width as per standard
11855 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011856 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070011857 pIes->HTCaps.supportedChannelWidthSet,
11858 pIes->HTInfo.recommendedTxWidthSet,
11859 pIes->HTInfo.secondaryChannelOffset);
11860
11861 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
11862 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070011863 else
Jeff Johnsone7245742012-09-05 17:12:55 -070011864 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11865 switch (eRet) {
11866 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
11867 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
11868 break;
11869 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
11870 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
11871 break;
11872 case PHY_SINGLE_CHANNEL_CENTERED:
11873 default:
11874 centerChn = primaryChn;
11875 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011876 }
Jeff Johnsone7245742012-09-05 17:12:55 -070011877 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070011878 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011879 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Abhishek Singh25144bb2014-05-01 16:03:21 +053011880 eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011881 }
Sushant Kaushikc1123872015-01-07 13:59:20 +053011882 if ((CSR_IS_CHANNEL_24GHZ(primaryChn))&& !IS_HT40_OBSS_SCAN_FEATURE_ENABLE)
11883 {
11884 smsLog(pMac, LOG1,FL("FW doesn't support channelBondingMode24GHz"));
11885 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11886 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011887 }
11888 }
11889 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011890 return eRet;
11891}
Jeff Johnson295189b2012-06-20 16:38:30 -070011892tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
11893{
11894 tANI_BOOLEAN fFound = FALSE;
11895 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011896 for( idx = 0; idx < pCipherList->numEntries; idx++ )
11897 {
11898 if( pCipherList->encryptionType[idx] == encryptionType )
11899 {
11900 fFound = TRUE;
11901 break;
11902 }
11903 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011904 return fFound;
11905}
Jeff Johnson295189b2012-06-20 16:38:30 -070011906tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
11907{
11908 tANI_BOOLEAN fFound = FALSE;
11909 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011910 for( idx = 0; idx < pAuthList->numEntries; idx++ )
11911 {
11912 if( pAuthList->authType[idx] == authType )
11913 {
11914 fFound = TRUE;
11915 break;
11916 }
11917 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011918 return fFound;
11919}
Jeff Johnson295189b2012-06-20 16:38:30 -070011920tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
11921{
11922 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11923 tCsrScanResultFilter *pScanFilter = NULL;
11924 eHalStatus status = eHAL_STATUS_SUCCESS;
11925
11926 if(pProfile1 && pProfile2)
11927 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011928 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
11929 if ( NULL == pScanFilter )
11930 status = eHAL_STATUS_FAILURE;
11931 else
11932 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011933 if(HAL_STATUS_SUCCESS(status))
11934 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011935 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011936 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
11937 if(HAL_STATUS_SUCCESS(status))
11938 {
11939 fCheck = eANI_BOOLEAN_FALSE;
11940 do
11941 {
11942 tANI_U32 i;
11943 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
11944 {
11945 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
11946 pScanFilter->SSIDs.SSIDList[i].SSID.length,
11947 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
11948 if ( fCheck ) break;
11949 }
11950 if(!fCheck)
11951 {
11952 break;
11953 }
11954 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
11955 || pProfile2->BSSType != pProfile1->BSSType
11956 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
11957 )
11958 {
11959 fCheck = eANI_BOOLEAN_FALSE;
11960 break;
11961 }
11962#ifdef WLAN_FEATURE_VOWIFI_11R
11963 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
11964 {
11965 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
11966 {
11967 fCheck = eANI_BOOLEAN_FALSE;
11968 break;
11969 }
11970 }
11971#endif
11972 //Match found
11973 fCheck = eANI_BOOLEAN_TRUE;
11974 }while(0);
11975 csrFreeScanFilter(pMac, pScanFilter);
11976 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011977 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011978 }
11979 }
11980
11981 return (fCheck);
11982}
11983
Jeff Johnson295189b2012-06-20 16:38:30 -070011984tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
11985{
11986 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11987 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011988 do
11989 {
11990 //Only check for static WEP
11991 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
11992 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
11993 {
11994 fCheck = eANI_BOOLEAN_TRUE;
11995 break;
11996 }
11997 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
11998 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
11999 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
12000 {
12001 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012002 if (!vos_mem_compare(&pConnProfile->Keys.KeyMaterial[i],
12003 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
Jeff Johnson295189b2012-06-20 16:38:30 -070012004 {
12005 break;
12006 }
12007 }
12008 if( i == CSR_MAX_NUM_KEY)
12009 {
12010 fCheck = eANI_BOOLEAN_TRUE;
12011 }
12012 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012013 return (fCheck);
12014}
12015
Jeff Johnson295189b2012-06-20 16:38:30 -070012016//IBSS
12017
Jeff Johnson295189b2012-06-20 16:38:30 -070012018tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
12019{
12020 tANI_U8 channel = 0;
12021 tANI_U32 idx;
12022 tANI_U32 idxValidChannels;
12023 tANI_BOOLEAN fFound = FALSE;
12024 tANI_U32 len = sizeof(pMac->roam.validChannelList);
12025
12026 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
12027 {
12028 channel = pMac->roam.configParam.AdHocChannel5G;
12029 if(!csrRoamIsChannelValid(pMac, channel))
12030 {
12031 channel = 0;
12032 }
12033 }
12034 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
12035 {
12036 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
12037 {
12038 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
12039 {
12040 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
12041 {
12042 fFound = TRUE;
12043 channel = csrStartIbssChannels50[ idx ];
12044 }
12045 }
12046 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012047 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
12048 if (!fFound)
12049 {
12050 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
12051 {
Girish Gowli386e76c2014-10-20 22:00:29 +053012052 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idxValidChannels ]) ) // the max channel# in 11g is 14
Jeff Johnson295189b2012-06-20 16:38:30 -070012053 {
Girish Gowli386e76c2014-10-20 22:00:29 +053012054 channel = pMac->roam.validChannelList[ idxValidChannels ];
Jeff Johnson295189b2012-06-20 16:38:30 -070012055 break;
12056 }
12057 }
12058 }
12059 }//if
12060
12061 return( channel );
12062}
12063
Jeff Johnson295189b2012-06-20 16:38:30 -070012064tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
12065{
12066 tANI_U8 channel = 1;
12067 tANI_U32 idx;
12068 tANI_U32 idxValidChannels;
12069 tANI_BOOLEAN fFound = FALSE;
12070 tANI_U32 len = sizeof(pMac->roam.validChannelList);
12071
12072 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
12073 {
12074 channel = pMac->roam.configParam.AdHocChannel24;
12075 if(!csrRoamIsChannelValid(pMac, channel))
12076 {
12077 channel = 0;
12078 }
12079 }
12080
12081 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
12082 {
12083 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
12084 {
12085 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
12086 {
12087 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
12088 {
12089 fFound = TRUE;
12090 channel = csrStartIbssChannels24[ idx ];
12091 }
12092 }
12093 }
12094 }
12095
12096 return( channel );
12097}
12098
Jeff Johnson295189b2012-06-20 16:38:30 -070012099static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
12100 tCsrRoamStartBssParams *pParam )
12101{
12102 eCsrCfgDot11Mode cfgDot11Mode;
12103 eCsrBand eBand;
12104 tANI_U8 channel = 0;
12105 tSirNwType nwType;
12106 tANI_U8 operationChannel = 0;
12107
12108 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
12109 {
12110 operationChannel = pProfile->ChannelInfo.ChannelList[0];
12111 }
12112
Jeff Johnson295189b2012-06-20 16:38:30 -070012113 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070012114
Jeff Johnson295189b2012-06-20 16:38:30 -070012115 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
12116 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
12117 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
12118 )
12119 {
12120 /* This should never happen */
12121 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012122 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070012123 pProfile->csrPersona);
12124 VOS_ASSERT(0);
12125 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012126 switch( cfgDot11Mode )
12127 {
12128 case eCSR_CFG_DOT11_MODE_11G:
12129 nwType = eSIR_11G_NW_TYPE;
12130 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012131 case eCSR_CFG_DOT11_MODE_11B:
12132 nwType = eSIR_11B_NW_TYPE;
12133 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012134 case eCSR_CFG_DOT11_MODE_11A:
12135 nwType = eSIR_11A_NW_TYPE;
12136 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012137 default:
12138 case eCSR_CFG_DOT11_MODE_11N:
12139 case eCSR_CFG_DOT11_MODE_TAURUS:
12140 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
12141 if(eCSR_BAND_24 == eBand)
12142 {
12143 nwType = eSIR_11G_NW_TYPE;
12144 }
12145 else
12146 {
12147 nwType = eSIR_11A_NW_TYPE;
12148 }
12149 break;
12150 }
12151
12152 pParam->extendedRateSet.numRates = 0;
12153
12154 switch ( nwType )
12155 {
12156 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012157 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012158 case eSIR_11A_NW_TYPE:
12159
12160 pParam->operationalRateSet.numRates = 8;
12161
12162 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
12163 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
12164 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
12165 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
12166 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
12167 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
12168 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
12169 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
12170
12171 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
12172 {
12173 channel = csrRoamGetIbssStartChannelNumber50( pMac );
12174 if( 0 == channel &&
12175 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
12176 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
12177 )
12178 {
12179 //We could not find a 5G channel by auto pick, let's try 2.4G channels
12180 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
12181 nwType = eSIR_11B_NW_TYPE;
12182 channel = csrRoamGetIbssStartChannelNumber24( pMac );
12183 pParam->operationalRateSet.numRates = 4;
12184 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
12185 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
12186 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
12187 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
12188 }
12189 }
12190 else
12191 {
12192 channel = operationChannel;
12193 }
12194 break;
12195
12196 case eSIR_11B_NW_TYPE:
12197 pParam->operationalRateSet.numRates = 4;
12198 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
12199 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
12200 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
12201 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070012202 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
12203 {
12204 channel = csrRoamGetIbssStartChannelNumber24( pMac );
12205 }
12206 else
12207 {
12208 channel = operationChannel;
12209 }
12210
12211 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070012212 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070012213 /* For P2P Client and P2P GO, disable 11b rates */
12214 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
12215 (pProfile->csrPersona == VOS_P2P_GO_MODE)
12216 )
12217 {
12218 pParam->operationalRateSet.numRates = 8;
12219
12220 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
12221 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
12222 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
12223 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
12224 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
12225 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
12226 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
12227 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
12228 }
12229 else
Jeff Johnson295189b2012-06-20 16:38:30 -070012230 {
12231 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070012232 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
12233 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
12234 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
12235 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
12236
12237 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070012238 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
12239 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
12240 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
12241 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
12242 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
12243 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
12244 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
12245 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
12246 }
12247
12248 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
12249 {
12250 channel = csrRoamGetIbssStartChannelNumber24( pMac );
12251 }
12252 else
12253 {
12254 channel = operationChannel;
12255 }
12256
12257 break;
12258 }
12259 pParam->operationChn = channel;
12260 pParam->sirNwType = nwType;
12261}
12262
Jeff Johnson295189b2012-06-20 16:38:30 -070012263static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
12264 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
12265{
12266
12267 if( pParam )
12268 {
12269 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070012270 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012271 pParam->operationChn = pBssDesc->channelId;
Kiet Lam64c1b492013-07-12 13:56:44 +053012272 vos_mem_copy(&pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012273
12274 if( pIes )
12275 {
12276 if(pIes->SuppRates.present)
12277 {
12278 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
12279 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
12280 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012281 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 -070012282 pIes->SuppRates.num_rates);
12283 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
12284 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012285 vos_mem_copy(pParam->operationalRateSet.rate, pIes->SuppRates.rates,
12286 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012287 }
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070012288 if (pIes->ExtSuppRates.present)
12289 {
12290 pParam->extendedRateSet.numRates = pIes->ExtSuppRates.num_rates;
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053012291 if(pIes->ExtSuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070012292 {
12293 smsLog(pMac, LOGE, FL("num_rates :%d is more than \
12294 SIR_MAC_RATESET_EID_MAX, resetting to \
12295 SIR_MAC_RATESET_EID_MAX"),
12296 pIes->ExtSuppRates.num_rates);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053012297 pIes->ExtSuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070012298 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053012299 vos_mem_copy(pParam->extendedRateSet.rate,
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070012300 pIes->ExtSuppRates.rates,
12301 sizeof(*pIes->ExtSuppRates.rates) * pIes->ExtSuppRates.num_rates);
12302 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012303 if( pIes->SSID.present )
12304 {
12305 pParam->ssId.length = pIes->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +053012306 vos_mem_copy(pParam->ssId.ssId, pIes->SSID.ssid,
12307 pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070012308 }
12309 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012310 }
12311 else
12312 {
12313 pParam->ssId.length = 0;
12314 pParam->operationalRateSet.numRates = 0;
12315 }
12316 }
12317}
12318
Jeff Johnson295189b2012-06-20 16:38:30 -070012319static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
12320{
12321 tANI_U8 MaxRate = 0;
12322 tANI_U32 i;
12323 tANI_U8 *pRate;
12324
12325 pRate = pSirRateSet->rate;
12326 for ( i = 0; i < pSirRateSet->numRates; i++ )
12327 {
12328 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
12329 }
12330
12331 // Save the max rate in the connected state information...
12332
12333 // modify LastRates variable as well
12334
12335 return;
12336}
12337
Jeff Johnson295189b2012-06-20 16:38:30 -070012338eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
12339 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
12340{
12341 eHalStatus status = eHAL_STATUS_SUCCESS;
12342 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070012343 // Set the roaming substate to 'Start BSS attempt'...
12344 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012345#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12346 //Need to figure out whether we need to log WDS???
12347 if( CSR_IS_IBSS( pProfile ) )
12348 {
12349 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070012350 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
12351 if(pIbssLog)
12352 {
12353 if(pBssDesc)
12354 {
12355 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
Kiet Lam64c1b492013-07-12 13:56:44 +053012356 vos_mem_copy(pIbssLog->bssid, pBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070012357 }
12358 else
12359 {
12360 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
12361 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012362 vos_mem_copy(pIbssLog->ssid, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070012363 if(pProfile->ChannelInfo.numOfChannels == 0)
12364 {
12365 pIbssLog->channelSetting = AUTO_PICK;
12366 }
12367 else
12368 {
12369 pIbssLog->channelSetting = SPECIFIED;
12370 }
12371 pIbssLog->operatingChannel = pParam->operationChn;
12372 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
12373 }
12374 }
12375#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
12376 //Put RSN information in for Starting BSS
Abhishek Singh00e46532014-11-13 05:34:55 -080012377 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
12378 pParam->pRSNIE = pProfile->pRSNReqIE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012379
Jeff Johnson295189b2012-06-20 16:38:30 -070012380 pParam->privacy = pProfile->privacy;
12381 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
12382 pParam->authType = pProfile->csr80211AuthType;
12383 pParam->beaconInterval = pProfile->beaconInterval;
12384 pParam->dtimPeriod = pProfile->dtimPeriod;
12385 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
12386 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
12387 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
12388 {
12389 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
12390 {
12391 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
12392 }
12393 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012394 pParam->protEnabled = pProfile->protEnabled;
12395 pParam->obssProtEnabled = pProfile->obssProtEnabled;
12396 pParam->ht_protection = pProfile->cfg_protection;
12397 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080012398
Jeff Johnson295189b2012-06-20 16:38:30 -070012399 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
12400 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070012401 pParam->bssPersona = pProfile->csrPersona;
Chet Lanctot8cecea22014-02-11 19:09:36 -080012402
12403#ifdef WLAN_FEATURE_11W
12404 pParam->mfpCapable = (0 != pProfile->MFPCapable);
12405 pParam->mfpRequired = (0 != pProfile->MFPRequired);
12406#endif
12407
Jeff Johnson295189b2012-06-20 16:38:30 -070012408 // When starting an IBSS, start on the channel from the Profile.
12409 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070012410 return (status);
12411}
12412
Jeff Johnson295189b2012-06-20 16:38:30 -070012413static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070012414 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070012415{
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012416 tANI_U8 Channel;
Jeff Johnsone7245742012-09-05 17:12:55 -070012417 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012418 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012419
12420 if(!pSession)
12421 {
12422 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12423 return;
12424 }
12425
Jeff Johnson295189b2012-06-20 16:38:30 -070012426 if( pBssDesc )
12427 {
12428 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
12429 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
12430 //The following code has to be do after that.
12431 //For WDS station, use selfMac as the self BSSID
12432 if( CSR_IS_WDS_STA( pProfile ) )
12433 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012434 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
12435 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012436 }
12437 }
12438 else
12439 {
12440 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070012441 //Use the first SSID
12442 if(pProfile->SSIDs.numOfSSIDs)
12443 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012444 vos_mem_copy(&pSession->bssParams.ssId, pProfile->SSIDs.SSIDList,
12445 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012446 }
12447 //For WDS station, use selfMac as the self BSSID
12448 if( CSR_IS_WDS_STA( pProfile ) )
12449 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012450 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
12451 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012452 }
12453 //Use the first BSSID
12454 else if( pProfile->BSSIDs.numOfBSSIDs )
12455 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012456 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid,
12457 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012458 }
12459 else
12460 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012461 vos_mem_set(&pSession->bssParams.bssid, sizeof(tCsrBssid), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012462 }
12463 }
12464 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070012465 //Set operating channel in pProfile which will be used
12466 //in csrRoamSetBssConfigCfg() to determine channel bonding
12467 //mode and will be configured in CFG later
12468 pProfile->operationChannel = Channel;
12469
12470 if(Channel == 0)
12471 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053012472 smsLog(pMac, LOGE, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070012473 }
12474 else
12475 {
12476
12477 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012478 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS( pProfile ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070012479 {
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012480 if(CSR_IS_CHANNEL_24GHZ(Channel) )
Jeff Johnsone7245742012-09-05 17:12:55 -070012481 {
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053012482#ifdef WLAN_FEATURE_AP_HT40_24G
12483 if (CSR_IS_INFRA_AP(pProfile))
12484 cbMode = pMac->roam.configParam.channelBondingAPMode24GHz;
12485 else
12486 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
12487#else
Sandeep Puligillae3f239f2014-04-17 02:11:46 +053012488 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053012489#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070012490 }
12491 else
12492 {
12493 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
12494 }
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012495 smsLog(pMac, LOG1, "## cbMode %d", cbMode);
Jeff Johnsone7245742012-09-05 17:12:55 -070012496 pBssConfig->cbMode = cbMode;
12497 pSession->bssParams.cbMode = cbMode;
12498 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012499 }
12500}
12501
Jeff Johnson295189b2012-06-20 16:38:30 -070012502static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
12503 tANI_BOOLEAN *pfSameIbss )
12504{
12505 eHalStatus status = eHAL_STATUS_SUCCESS;
12506 tANI_BOOLEAN fSameIbss = FALSE;
12507
12508 if ( csrIsConnStateIbss( pMac, sessionId ) )
12509 {
12510 // Check if any profile parameter has changed ? If any profile parameter
12511 // has changed then stop old BSS and start a new one with new parameters
12512 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
12513 {
12514 fSameIbss = TRUE;
12515 }
12516 else
12517 {
12518 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
12519 }
12520 }
12521 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
12522 {
12523 // Disassociate from the connected Infrastructure network...
12524 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
12525 }
12526 else
12527 {
12528 tBssConfigParam *pBssConfig;
12529
Kiet Lam64c1b492013-07-12 13:56:44 +053012530 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
12531 if ( NULL == pBssConfig )
12532 status = eHAL_STATUS_FAILURE;
12533 else
12534 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012535 if(HAL_STATUS_SUCCESS(status))
12536 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012537 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012538 // there is no Bss description before we start an IBSS so we need to adopt
12539 // all Bss configuration parameters from the Profile.
12540 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
12541 if(HAL_STATUS_SUCCESS(status))
12542 {
12543 //save dotMode
12544 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
12545 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070012546 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012547 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
12548 NULL, pBssConfig,
12549 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012550 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012551
12552 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -070012553 }//Allocate memory
12554 }
12555
12556 if(pfSameIbss)
12557 {
12558 *pfSameIbss = fSameIbss;
12559 }
12560 return( status );
12561}
12562
Jeff Johnson295189b2012-06-20 16:38:30 -070012563static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
12564 tSirSmeNewBssInfo *pNewBss )
12565{
12566 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012567
12568 if(!pSession)
12569 {
12570 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12571 return;
12572 }
12573
Jeff Johnson295189b2012-06-20 16:38:30 -070012574 if( pNewBss )
12575 {
12576 // Set the operating channel.
12577 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
12578 // move the BSSId from the BSS description into the connected state information.
Kiet Lam64c1b492013-07-12 13:56:44 +053012579 vos_mem_copy(&pSession->connectedProfile.bssid, &(pNewBss->bssId),
12580 sizeof( tCsrBssid ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012581 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012582 return;
12583}
12584
Jeff Johnson295189b2012-06-20 16:38:30 -070012585#ifdef FEATURE_WLAN_WAPI
12586eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
12587 tANI_U32 numItems )
12588{
12589 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +053012590 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012591 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
12592 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012593 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012594 return status;
12595 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012596 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070012597 pSession = CSR_GET_SESSION( pMac, sessionId );
12598 if(numItems <= CSR_MAX_BKID_ALLOWED)
12599 {
12600 status = eHAL_STATUS_SUCCESS;
12601 //numItems may be 0 to clear the cache
12602 pSession->NumBkidCache = (tANI_U16)numItems;
12603 if(numItems && pBKIDCache)
12604 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012605 vos_mem_copy(pSession->BkidCacheInfo, pBKIDCache,
12606 sizeof(tBkidCacheInfo) * numItems);
12607 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012608 }
12609 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012610 return (status);
12611}
Jeff Johnson295189b2012-06-20 16:38:30 -070012612eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
12613 tBkidCacheInfo *pBkidCache)
12614{
12615 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +053012616 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070012617 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
12618 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012619 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012620 return status;
12621 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012622 pSession = CSR_GET_SESSION( pMac, sessionId );
12623 if(pNum && pBkidCache)
12624 {
12625 if(pSession->NumBkidCache == 0)
12626 {
12627 *pNum = 0;
12628 status = eHAL_STATUS_SUCCESS;
12629 }
12630 else if(*pNum >= pSession->NumBkidCache)
12631 {
Girish Gowli2c26e902014-10-20 22:18:17 +053012632 if(pSession->NumBkidCache > CSR_MAX_BKID_ALLOWED)
Jeff Johnson295189b2012-06-20 16:38:30 -070012633 {
Girish Gowli2c26e902014-10-20 22:18:17 +053012634 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 -070012635 pSession->NumBkidCache);
Girish Gowli2c26e902014-10-20 22:18:17 +053012636 pSession->NumBkidCache = CSR_MAX_BKID_ALLOWED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012637 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012638 vos_mem_copy(pBkidCache, pSession->BkidCacheInfo,
12639 sizeof(tBkidCacheInfo) * pSession->NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012640 *pNum = pSession->NumBkidCache;
12641 status = eHAL_STATUS_SUCCESS;
12642 }
12643 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012644 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070012645}
Jeff Johnson295189b2012-06-20 16:38:30 -070012646tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
12647{
12648 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012649}
12650#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012651eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012652 tPmkidCacheInfo *pPMKIDCache,
12653 tANI_U32 numItems,
12654 tANI_BOOLEAN update_entire_cache )
Jeff Johnson295189b2012-06-20 16:38:30 -070012655{
12656 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12657 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012658
12659 if (!pSession)
Jeff Johnson32d95a32012-09-10 13:15:23 -070012660 {
12661 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12662 return eHAL_STATUS_FAILURE;
12663 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012664
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012665 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012666
12667 if (numItems <= CSR_MAX_PMKID_ALLOWED)
Jeff Johnson295189b2012-06-20 16:38:30 -070012668 {
12669#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12670 {
12671 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053012672 vos_mem_set(&secEvent,
12673 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012674 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
12675 secEvent.encryptionModeMulticast =
12676 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
12677 secEvent.encryptionModeUnicast =
12678 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053012679 vos_mem_copy(secEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070012680 secEvent.authMode =
12681 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
12682 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
12683 }
12684#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070012685 status = eHAL_STATUS_SUCCESS;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012686 if (update_entire_cache) {
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012687 if (numItems && pPMKIDCache)
12688 {
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012689 pSession->NumPmkidCache = (tANI_U16)numItems;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012690 vos_mem_copy(pSession->PmkidCacheInfo, pPMKIDCache,
12691 sizeof(tPmkidCacheInfo) * numItems);
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012692 pSession->CurCacheIndex = (tANI_U16)numItems;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012693 }
12694 } else {
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012695 tANI_U32 i = 0;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012696 tPmkidCacheInfo *pmksa;
12697
12698 for (i = 0; i < numItems; i++) {
12699 pmksa = &pPMKIDCache[i];
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012700
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012701 /* Delete the entry if present */
12702 csrRoamDelPMKIDfromCache(pMac,sessionId,pmksa->BSSID,FALSE);
12703
12704 /* Add entry to the cache */
12705 vos_mem_copy(
12706 pSession->PmkidCacheInfo[pSession->CurCacheIndex].BSSID,
12707 pmksa->BSSID, VOS_MAC_ADDR_SIZE);
12708 vos_mem_copy(
12709 pSession->PmkidCacheInfo[pSession->CurCacheIndex].PMKID,
12710 pmksa->PMKID, CSR_RSN_PMKID_SIZE);
12711
12712 /* Increment the CSR local cache index */
12713 if (pSession->CurCacheIndex < (CSR_MAX_PMKID_ALLOWED - 1))
12714 pSession->CurCacheIndex++;
12715 else
12716 pSession->CurCacheIndex = 0;
12717
12718 pSession->NumPmkidCache++;
12719 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
12720 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012721 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012722 }
12723 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012724 return (status);
12725}
12726
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012727eHalStatus csrRoamDelPMKIDfromCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012728#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
12729 const tANI_U8 *pBSSId,
12730#else
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012731 tANI_U8 *pBSSId,
Anand N Sunkadb3ab97d2015-07-29 09:58:13 +053012732#endif
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012733 tANI_BOOLEAN flush_cache )
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012734{
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012735 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12736 tANI_BOOLEAN fMatchFound = FALSE;
12737 tANI_U32 Index;
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012738 tANI_U32 CurIndex;
12739 tANI_U32 i;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012740
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012741 if(!pSession)
12742 {
12743 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12744 return eHAL_STATUS_FAILURE;
12745 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012746
12747 /* Check if there are no entries to delete */
12748 if (0 == pSession->NumPmkidCache) {
12749 smsLog(pMac, LOG1, FL("No entries to delete/Flush"));
12750 return eHAL_STATUS_SUCCESS;
12751 }
12752
12753 if (!flush_cache) {
12754 for (Index = 0; Index < CSR_MAX_PMKID_ALLOWED; Index++) {
12755 if (vos_mem_compare(pSession->PmkidCacheInfo[Index].BSSID,
12756 pBSSId, VOS_MAC_ADDR_SIZE)) {
12757 fMatchFound = 1;
12758
12759 /* Clear this - the matched entry */
12760 vos_mem_zero(&pSession->PmkidCacheInfo[Index],
12761 sizeof(tPmkidCacheInfo));
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012762 break;
12763 }
12764 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012765
12766 if (Index == CSR_MAX_PMKID_ALLOWED && !fMatchFound) {
12767 smsLog(pMac, LOG1, FL("No such PMKSA entry exists "MAC_ADDRESS_STR),
12768 MAC_ADDR_ARRAY(pBSSId));
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012769 }
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012770 else {
12771 /* Match Found */
12772 CurIndex = pSession->CurCacheIndex;
12773 if(Index < CurIndex) {
12774 for(i = Index; i < (CurIndex-1); i++) {
12775 vos_mem_copy(&pSession->PmkidCacheInfo[i],
12776 &pSession->PmkidCacheInfo[i+1],sizeof(tPmkidCacheInfo));
12777 }
12778 pSession->CurCacheIndex--;
12779 vos_mem_zero(&pSession->PmkidCacheInfo[pSession->CurCacheIndex],
12780 sizeof(tPmkidCacheInfo));
12781 } else if(Index > CurIndex) {
12782 for(i = Index; i > (CurIndex); i--) {
12783 vos_mem_copy(&pSession->PmkidCacheInfo[i],
12784 &pSession->PmkidCacheInfo[i-1],sizeof(tPmkidCacheInfo));
12785 }
12786 vos_mem_zero(&pSession->PmkidCacheInfo[pSession->CurCacheIndex],
12787 sizeof(tPmkidCacheInfo));
12788 }
12789 pSession->NumPmkidCache--;
12790 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012791 } else {
12792 /* Flush the entire cache */
12793 vos_mem_zero(pSession->PmkidCacheInfo,
12794 sizeof(tPmkidCacheInfo) * CSR_MAX_PMKID_ALLOWED);
12795 pSession->NumPmkidCache = 0;
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012796 pSession->CurCacheIndex = 0;
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012797 }
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012798
12799 return eHAL_STATUS_SUCCESS;
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012800}
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012801
Jeff Johnson295189b2012-06-20 16:38:30 -070012802tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
12803{
12804 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
12805}
12806
Jeff Johnson295189b2012-06-20 16:38:30 -070012807eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
12808{
12809 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12810 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012811 tPmkidCacheInfo *pmksa;
12812 tANI_U16 i,j;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012813
12814 if(!pSession)
12815 {
12816 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12817 return eHAL_STATUS_FAILURE;
12818 }
12819
Jeff Johnson295189b2012-06-20 16:38:30 -070012820 if(pNum && pPmkidCache)
12821 {
12822 if(pSession->NumPmkidCache == 0)
12823 {
12824 *pNum = 0;
12825 status = eHAL_STATUS_SUCCESS;
12826 }
12827 else if(*pNum >= pSession->NumPmkidCache)
12828 {
12829 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
12830 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012831 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 -070012832 pSession->NumPmkidCache);
12833 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
12834 }
Kanchanapally, Vidyullatha0c611b02014-11-26 21:30:05 +053012835
12836 for(i = 0,j = 0; (j<pSession->NumPmkidCache)&&(i<CSR_MAX_PMKID_ALLOWED); i++) {
12837 pmksa = &pSession->PmkidCacheInfo[i];
12838 if(!csrIsMacAddressZero(pMac, &pmksa->BSSID)) {
12839 vos_mem_copy(pPmkidCache,pmksa,sizeof(tPmkidCacheInfo));
12840 pPmkidCache++;
12841 j++;
12842 }
12843 }
12844
Jeff Johnson295189b2012-06-20 16:38:30 -070012845 *pNum = pSession->NumPmkidCache;
12846 status = eHAL_STATUS_SUCCESS;
12847 }
12848 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012849 return (status);
12850}
12851
Jeff Johnson295189b2012-06-20 16:38:30 -070012852eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12853{
12854 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12855 tANI_U32 len;
12856 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012857
12858 if(!pSession)
12859 {
12860 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12861 return eHAL_STATUS_FAILURE;
12862 }
12863
Jeff Johnson295189b2012-06-20 16:38:30 -070012864 if(pLen)
12865 {
12866 len = *pLen;
12867 *pLen = pSession->nWpaRsnReqIeLength;
12868 if(pBuf)
12869 {
12870 if(len >= pSession->nWpaRsnReqIeLength)
12871 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012872 vos_mem_copy(pBuf, pSession->pWpaRsnReqIE,
12873 pSession->nWpaRsnReqIeLength);
12874 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012875 }
12876 }
12877 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012878 return (status);
12879}
12880
Jeff Johnson295189b2012-06-20 16:38:30 -070012881eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12882{
12883 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12884 tANI_U32 len;
12885 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012886
12887 if(!pSession)
12888 {
12889 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12890 return eHAL_STATUS_FAILURE;
12891 }
12892
Jeff Johnson295189b2012-06-20 16:38:30 -070012893 if(pLen)
12894 {
12895 len = *pLen;
12896 *pLen = pSession->nWpaRsnRspIeLength;
12897 if(pBuf)
12898 {
12899 if(len >= pSession->nWpaRsnRspIeLength)
12900 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012901 vos_mem_copy(pBuf, pSession->pWpaRsnRspIE,
12902 pSession->nWpaRsnRspIeLength);
12903 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012904 }
12905 }
12906 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012907 return (status);
12908}
Jeff Johnson295189b2012-06-20 16:38:30 -070012909#ifdef FEATURE_WLAN_WAPI
12910eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12911{
12912 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12913 tANI_U32 len;
12914 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012915
12916 if(!pSession)
12917 {
12918 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12919 return eHAL_STATUS_FAILURE;
12920 }
12921
Jeff Johnson295189b2012-06-20 16:38:30 -070012922 if(pLen)
12923 {
12924 len = *pLen;
12925 *pLen = pSession->nWapiReqIeLength;
12926 if(pBuf)
12927 {
12928 if(len >= pSession->nWapiReqIeLength)
12929 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012930 vos_mem_copy(pBuf, pSession->pWapiReqIE,
12931 pSession->nWapiReqIeLength);
12932 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012933 }
12934 }
12935 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012936 return (status);
12937}
Jeff Johnson295189b2012-06-20 16:38:30 -070012938eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12939{
12940 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12941 tANI_U32 len;
12942 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012943
12944 if(!pSession)
12945 {
12946 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12947 return eHAL_STATUS_FAILURE;
12948 }
12949
Jeff Johnson295189b2012-06-20 16:38:30 -070012950 if(pLen)
12951 {
12952 len = *pLen;
12953 *pLen = pSession->nWapiRspIeLength;
12954 if(pBuf)
12955 {
12956 if(len >= pSession->nWapiRspIeLength)
12957 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012958 vos_mem_copy(pBuf, pSession->pWapiRspIE,
12959 pSession->nWapiRspIeLength);
12960 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012961 }
12962 }
12963 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012964 return (status);
12965}
12966#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012967eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
12968{
12969 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
12970 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012971
12972 if(!pSession)
12973 {
12974 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12975 return (retStatus);
12976 }
12977
Jeff Johnson295189b2012-06-20 16:38:30 -070012978 if(CSR_IS_ROAMING(pSession))
12979 {
12980 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
12981 pSession->fRoaming = eANI_BOOLEAN_FALSE;
12982 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012983 return (retStatus);
12984}
12985
Jeff Johnson295189b2012-06-20 16:38:30 -070012986//This function remove the connected BSS from te cached scan result
12987eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
12988 tCsrRoamConnectedProfile *pConnProfile)
12989{
12990 eHalStatus status = eHAL_STATUS_FAILURE;
12991 tCsrScanResultFilter *pScanFilter = NULL;
12992 tListElem *pEntry;
12993 tCsrScanResult *pResult;
12994 tDot11fBeaconIEs *pIes;
12995 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070012996 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
12997 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
12998 {
12999 do
13000 {
13001 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
Kiet Lam64c1b492013-07-12 13:56:44 +053013002 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
13003 if ( NULL == pScanFilter )
13004 status = eHAL_STATUS_FAILURE;
13005 else
13006 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013007 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013008 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
13009 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
13010 if ( NULL == pScanFilter->BSSIDs.bssid )
13011 status = eHAL_STATUS_FAILURE;
13012 else
13013 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013014 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013015 vos_mem_copy(pScanFilter->BSSIDs.bssid, &pConnProfile->bssid,
13016 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070013017 pScanFilter->BSSIDs.numOfBSSIDs = 1;
13018 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
13019 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013020 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
13021 if ( NULL == pScanFilter->SSIDs.SSIDList )
13022 status = eHAL_STATUS_FAILURE;
13023 else
13024 status = eHAL_STATUS_SUCCESS;
13025 if (!HAL_STATUS_SUCCESS(status)) break;
13026 vos_mem_copy(&pScanFilter->SSIDs.SSIDList[0].SSID,
13027 &pConnProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070013028 }
13029 pScanFilter->authType.numEntries = 1;
13030 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
13031 pScanFilter->BSSType = pConnProfile->BSSType;
13032 pScanFilter->EncryptionType.numEntries = 1;
13033 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
13034 pScanFilter->mcEncryptionType.numEntries = 1;
13035 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
13036 //We ignore the channel for now, BSSID should be enough
13037 pScanFilter->ChannelInfo.numOfChannels = 0;
13038 //Also ignore the following fields
13039 pScanFilter->uapsd_mask = 0;
13040 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070013041 pScanFilter->bOSENAssociation = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013042 pScanFilter->countryCode[0] = 0;
13043 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013044 csrLLLock(&pMac->scan.scanResultList);
13045 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
13046 while( pEntry )
13047 {
13048 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
13049 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
13050 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
13051 pScanFilter, NULL, NULL, NULL, &pIes);
13052 //Release the IEs allocated by csrMatchBSS is needed
13053 if( !pResult->Result.pvIes )
13054 {
13055 //need to free the IEs since it is allocated by csrMatchBSS
Kiet Lam64c1b492013-07-12 13:56:44 +053013056 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070013057 }
13058 if(fMatch)
13059 {
13060 //We found the one
13061 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
13062 {
13063 //Free the memory
13064 csrFreeScanResultEntry( pMac, pResult );
13065 }
13066 break;
13067 }
13068 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
13069 }//while
13070 csrLLUnlock(&pMac->scan.scanResultList);
13071 }while(0);
13072 if(pScanFilter)
13073 {
13074 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +053013075 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070013076 }
13077 }
13078 return (status);
13079}
13080
Jeff Johnson295189b2012-06-20 16:38:30 -070013081//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070013082eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
13083{
13084 eHalStatus status = eHAL_STATUS_SUCCESS;
13085 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013086 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
13087 {
13088 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
13089 {
13090 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
13091 {
13092 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013093 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013094 status = eHAL_STATUS_CSR_WRONG_STATE;
13095 break;
13096 }
13097 if( csrIsConnStateInfra( pMac, sessionId ) )
13098 {
13099 if( chnId &&
13100 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
13101 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013102 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070013103 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
13104 status = eHAL_STATUS_CSR_WRONG_STATE;
13105 break;
13106 }
13107 }
13108 }
13109 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013110 return ( status );
13111}
13112
Jeff Johnson295189b2012-06-20 16:38:30 -070013113static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
13114{
13115 eHalStatus status = eHAL_STATUS_SUCCESS;
13116 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13117 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013118
13119 if(!pSession)
13120 {
13121 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13122 return eHAL_STATUS_FAILURE;
13123 }
13124
Jeff Johnson295189b2012-06-20 16:38:30 -070013125 if ( csrIsConnStateIbss( pMac, sessionId ) )
13126 {
13127 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
13128 }
13129 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
13130 {
13131 // Disassociate from the connected Infrastructure network...
13132 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
13133 }
13134 else
13135 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013136 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
13137 //Otherwise we need to add code to handle the
13138 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
13139 //send stop_bss to PE, before we can continue.
13140 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013141 vos_mem_set(&bssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013142 /* Assume HDD provide bssid in profile */
Kiet Lam64c1b492013-07-12 13:56:44 +053013143 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0],
13144 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070013145 // there is no Bss description before we start an WDS so we need
13146 // to adopt all Bss configuration parameters from the Profile.
13147 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
13148 if(HAL_STATUS_SUCCESS(status))
13149 {
13150 //Save profile for late use
13151 csrFreeRoamProfile( pMac, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +053013152 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
13153 if (pSession->pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -070013154 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013155 vos_mem_set(pSession->pCurRoamProfile,
13156 sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013157 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
13158 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013159 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070013160 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053013161 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
13162 NULL, &bssConfig,
13163 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013164 }
13165 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053013166
Jeff Johnson295189b2012-06-20 16:38:30 -070013167 return( status );
13168}
13169
Jeff Johnson295189b2012-06-20 16:38:30 -070013170////////////////////Mail box
13171
Jeff Johnson295189b2012-06-20 16:38:30 -070013172//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
13173//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053013174static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
13175 tSirBssDescription *pBssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -070013176 tANI_U8 *pBuf, tANI_U8 uapsdMask)
13177{
13178 tCsrChannelSet channelGroup;
13179 tSirMacCapabilityInfo *pAP_capabilityInfo;
13180 tAniBool fTmp;
13181 tANI_BOOLEAN found = FALSE;
13182 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080013183 tANI_S8 pwrLimit = 0;
13184 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070013185 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
13186 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
13187 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
13188 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070013189 // 802.11h
13190 //We can do this because it is in HOST CPU order for now.
13191 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080013192 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
13193 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
13194 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013195 fTmp = (tAniBool)pal_cpu_to_be32(1);
13196 }
13197 else
13198 fTmp = (tAniBool)0;
13199
13200 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
Kiet Lam64c1b492013-07-12 13:56:44 +053013201 vos_mem_copy(pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool));
Jeff Johnson295189b2012-06-20 16:38:30 -070013202 pBuf += sizeof(tAniBool);
13203 *pBuf++ = MIN_STA_PWR_CAP_DBM; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080013204 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070013205 // This is required for 11k test VoWiFi Ent: Test 2.
13206 // We need the power capabilities for Assoc Req.
13207 // This macro is provided by the halPhyCfg.h. We pick our
13208 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080013209 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
13210 if (0 != pwrLimit)
13211 {
13212 *pBuf++ = pwrLimit;
13213 }
13214 else
13215 {
13216 *pBuf++ = MAX_STA_PWR_CAP_DBM;
13217 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013218 size = sizeof(pMac->roam.validChannelList);
13219 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
Abhishek Singhfabfae72015-06-17 18:01:15 +053013220 {
13221 tANI_U8 *actualSize = pBuf++;
13222 *actualSize = 0;
13223
13224 for ( i = 0; i < size; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -070013225 {
Abhishek Singhfabfae72015-06-17 18:01:15 +053013226 /* Only add 5ghz channels*/
13227 if (CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ i ]))
13228 {
13229 *actualSize +=1;
13230 *pBuf++ = pMac->roam.validChannelList[ i ];
13231 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013232 }
13233 }
13234 else
13235 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013236 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070013237 *pBuf++ = 0; //tSirSupChnl->numChnl
13238 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013239 //Check whether it is ok to enter UAPSD
13240#ifndef WLAN_MDM_CODE_REDUCTION_OPT
13241 if( btcIsReadyForUapsd(pMac) )
13242#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
13243 {
13244 *pBuf++ = uapsdMask;
13245 }
13246#ifndef WLAN_MDM_CODE_REDUCTION_OPT
13247 else
13248 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013249 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070013250 *pBuf++ = 0;
13251 }
13252#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
13253
Jeff Johnson295189b2012-06-20 16:38:30 -070013254 // move the entire BssDescription into the join request.
Kiet Lam64c1b492013-07-12 13:56:44 +053013255 vos_mem_copy(pBuf, pBssDescription,
13256 pBssDescription->length + sizeof( pBssDescription->length ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013257 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
13258}
13259
Jeff Johnson295189b2012-06-20 16:38:30 -070013260/*
13261 * The communication between HDD and LIM is thru mailbox (MB).
13262 * Both sides will access the data structure "tSirSmeJoinReq".
13263 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
13264 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
13265 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
13266 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
13267 */
13268eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013269 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013270{
13271 eHalStatus status = eHAL_STATUS_SUCCESS;
13272 tSirSmeJoinReq *pMsg;
13273 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013274 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070013275 tANI_U16 msgLen, wTmp, ieLen;
13276 tSirMacRateSet OpRateSet;
13277 tSirMacRateSet ExRateSet;
13278 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13279 tANI_U32 dwTmp;
13280 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Ravi Joshi83bfaa12013-05-28 22:12:08 -070013281 tANI_U32 ucDot11Mode = 0;
Abhishek Singhcb4d15c2014-11-04 16:09:49 +053013282 tANI_U8 txBFCsnValue = 0;
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +053013283 tANI_U16 rateBitmap = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013284
13285 if(!pSession)
13286 {
13287 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13288 return eHAL_STATUS_FAILURE;
13289 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013290 /* To satisfy klockworks */
13291 if (NULL == pBssDescription)
13292 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013293 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013294 return eHAL_STATUS_FAILURE;
13295 }
13296
Jeff Johnson295189b2012-06-20 16:38:30 -070013297 do {
13298 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
13299 pSession->joinFailStatusCode.reasonCode = 0;
Rajesh Babu Prathipati20cdffa2014-07-01 22:24:59 +053013300 vos_mem_copy (&pSession->joinFailStatusCode.bssId, &pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013301 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
13302 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
13303 // IE fields, but the length field in the bssDescription needs to be interpreted to
13304 // determine length of the IE fields.
13305 //
13306 // So, take the size of the JoinReq, subtract the size of the bssDescription and
13307 // add in the length from the bssDescription (then add the size of the 'length' field
13308 // itself because that is NOT included in the length field).
13309 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
13310 pBssDescription->length + sizeof( pBssDescription->length ) +
13311 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 +053013312 pMsg = vos_mem_malloc(msgLen);
13313 if (NULL == pMsg)
13314 status = eHAL_STATUS_FAILURE;
13315 else
13316 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013317 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013318 vos_mem_set(pMsg, msgLen , 0);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013319 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070013320 pMsg->length = pal_cpu_to_be16(msgLen);
13321 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013322 // sessionId
13323 *pBuf = (tANI_U8)sessionId;
13324 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013325 // transactionId
13326 *pBuf = 0;
13327 *( pBuf + 1 ) = 0;
13328 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013329 // ssId
13330 if( pIes->SSID.present && pIes->SSID.num_ssid )
13331 {
13332 // ssId len
13333 *pBuf = pIes->SSID.num_ssid;
13334 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053013335 vos_mem_copy(pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -070013336 pBuf += pIes->SSID.num_ssid;
13337 }
13338 else
13339 {
13340 *pBuf = 0;
13341 pBuf++;
13342 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013343 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013344 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
13345 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013346 pBuf += sizeof(tSirMacAddr);
13347 // bsstype
13348 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
13349 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
Kiet Lam64c1b492013-07-12 13:56:44 +053013350 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013351 pBuf += sizeof(tSirBssType);
13352 // dot11mode
Ravi Joshi83bfaa12013-05-28 22:12:08 -070013353 ucDot11Mode = csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
13354 if (pBssDescription->channelId <= 14 &&
13355 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
13356 WNI_CFG_DOT11_MODE_11AC == ucDot11Mode)
13357 {
13358 //Need to disable VHT operation in 2.4 GHz band
13359 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
13360 }
13361 *pBuf = (tANI_U8)ucDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -070013362 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013363 //Persona
13364 *pBuf = (tANI_U8)pProfile->csrPersona;
13365 pBuf++;
Sushant Kaushik74df8db2015-03-11 18:09:05 +053013366 *pBuf = (tANI_U8)pProfile->bOSENAssociation;
13367 pBuf++;
Abhishek Singheef5c992016-01-27 13:41:54 +053013368 *pBuf = (tANI_U8)pProfile->bWPSAssociation;
13369 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070013370 //CBMode
13371 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
13372 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013373
13374 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -070013375 FL("CSR PERSONA=%d CSR CbMode %d"), pProfile->csrPersona, pSession->bssParams.cbMode);
13376
Jeff Johnson295189b2012-06-20 16:38:30 -070013377 // uapsdPerAcBitmask
13378 *pBuf = pProfile->uapsd_mask;
13379 pBuf++;
13380
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013381
13382
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +053013383 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet,&rateBitmap);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013384 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013385 {
13386 // OperationalRateSet
13387 if (OpRateSet.numRates) {
13388 *pBuf++ = OpRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053013389 vos_mem_copy(pBuf, OpRateSet.rate, OpRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070013390 pBuf += OpRateSet.numRates;
13391 } else *pBuf++ = 0;
13392 // ExtendedRateSet
13393 if (ExRateSet.numRates) {
13394 *pBuf++ = ExRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053013395 vos_mem_copy(pBuf, ExRateSet.rate, ExRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070013396 pBuf += ExRateSet.numRates;
13397 } else *pBuf++ = 0;
13398 }
13399 else
13400 {
13401 *pBuf++ = 0;
13402 *pBuf++ = 0;
13403 }
Masti, Narayanraddi67ea5912015-01-08 12:34:05 +053013404
13405 //rateBitmap
13406 vos_mem_copy(pBuf, &rateBitmap, sizeof(tANI_U16));
13407 pBuf += sizeof(tANI_U16);
13408
Jeff Johnson295189b2012-06-20 16:38:30 -070013409 // rsnIE
13410 if ( csrIsProfileWpa( pProfile ) )
13411 {
13412 // Insert the Wpa IE into the join request
13413 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
13414 (tCsrWpaIe *)( wpaRsnIE ) );
13415 }
13416 else if( csrIsProfileRSN( pProfile ) )
13417 {
13418 // Insert the RSN IE into the join request
13419 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
13420 (tCsrRSNIe *)( wpaRsnIE ) );
13421 }
13422#ifdef FEATURE_WLAN_WAPI
13423 else if( csrIsProfileWapi( pProfile ) )
13424 {
13425 // Insert the WAPI IE into the join request
13426 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
13427 (tCsrWapiIe *)( wpaRsnIE ) );
13428 }
13429#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070013430 else
13431 {
13432 ieLen = 0;
13433 }
13434 //remember the IE for future use
13435 if( ieLen )
13436 {
13437 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
13438 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013439 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 -070013440 ieLen = DOT11F_IE_RSN_MAX_LEN;
13441 }
13442#ifdef FEATURE_WLAN_WAPI
13443 if( csrIsProfileWapi( pProfile ) )
13444 {
13445 //Check whether we need to allocate more memory
13446 if(ieLen > pSession->nWapiReqIeLength)
13447 {
13448 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
13449 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013450 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013451 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013452 pSession->pWapiReqIE = vos_mem_malloc(ieLen);
13453 if (NULL == pSession->pWapiReqIE)
13454 status = eHAL_STATUS_FAILURE;
13455 else
13456 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013457 if(!HAL_STATUS_SUCCESS(status)) break;
13458 }
13459 pSession->nWapiReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053013460 vos_mem_copy(pSession->pWapiReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013461 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013462 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013463 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013464 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013465 pBuf += ieLen;
13466 }
13467 else//should be WPA/WPA2 otherwise
13468#endif /* FEATURE_WLAN_WAPI */
13469 {
13470 //Check whether we need to allocate more memory
13471 if(ieLen > pSession->nWpaRsnReqIeLength)
13472 {
13473 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
13474 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013475 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013476 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013477 pSession->pWpaRsnReqIE = vos_mem_malloc(ieLen);
13478 if (NULL == pSession->pWpaRsnReqIE)
13479 status = eHAL_STATUS_FAILURE;
13480 else
13481 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013482 if(!HAL_STATUS_SUCCESS(status)) break;
13483 }
13484 pSession->nWpaRsnReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053013485 vos_mem_copy(pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013486 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013487 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013488 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013489 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013490 pBuf += ieLen;
13491 }
13492 }
13493 else
13494 {
13495 //free whatever old info
13496 pSession->nWpaRsnReqIeLength = 0;
13497 if(pSession->pWpaRsnReqIE)
13498 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013499 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013500 pSession->pWpaRsnReqIE = NULL;
13501 }
13502#ifdef FEATURE_WLAN_WAPI
13503 pSession->nWapiReqIeLength = 0;
13504 if(pSession->pWapiReqIE)
13505 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013506 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013507 pSession->pWapiReqIE = NULL;
13508 }
13509#endif /* FEATURE_WLAN_WAPI */
13510 //length is two bytes
13511 *pBuf = 0;
13512 *(pBuf + 1) = 0;
13513 pBuf += 2;
13514 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013515#ifdef FEATURE_WLAN_ESE
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013516 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013517 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013518 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070013519 //length is two bytes
13520 *pBuf = 0;
13521 *(pBuf + 1) = 0;
13522 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013523 }
13524 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013525 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013526 // cckmIE
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013527 if( csrIsProfileESE( pProfile ) )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013528 {
13529 // Insert the CCKM IE into the join request
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013530#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070013531 ieLen = pSession->suppCckmIeInfo.cckmIeLen;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080013532 vos_mem_copy((void *) (wpaRsnIE),
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070013533 pSession->suppCckmIeInfo.cckmIe, ieLen);
13534#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013535 ieLen = csrConstructEseCckmIe( pMac,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013536 pSession,
13537 pProfile,
13538 pBssDescription,
13539 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070013540 pSession->nWpaRsnReqIeLength,
13541 (void *)( wpaRsnIE ) );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013542#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013543 }
13544 else
13545 {
13546 ieLen = 0;
13547 }
13548 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
13549 if( ieLen )
13550 {
13551 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
13552 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013553 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013554 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013555 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013556 pBuf += ieLen;
13557 }
13558 else
13559 {
13560 //Indicate you have no CCKM IE
13561 //length is two bytes
13562 *pBuf = 0;
13563 *(pBuf + 1) = 0;
13564 pBuf += 2;
13565 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013566 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013567#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -070013568 // addIEScan
Agarwal Ashish4f616132013-12-30 23:32:50 +053013569 if (pProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070013570 {
13571 ieLen = pProfile->nAddIEScanLength;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013572 memset(pSession->addIEScan, 0 , pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013573 pSession->nAddIEScanLength = ieLen;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013574 vos_mem_copy(pSession->addIEScan, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013575 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013576 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013577 pBuf += sizeof(tANI_U16);
Agarwal Ashish4f616132013-12-30 23:32:50 +053013578 vos_mem_copy(pBuf, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013579 pBuf += ieLen;
13580 }
13581 else
13582 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053013583 memset(pSession->addIEScan, 0, pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013584 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013585 *pBuf = 0;
13586 *(pBuf + 1) = 0;
13587 pBuf += 2;
13588 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013589 // addIEAssoc
13590 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
13591 {
13592 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070013593 if(ieLen > pSession->nAddIEAssocLength)
13594 {
13595 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
Kiet Lam64c1b492013-07-12 13:56:44 +053013596 {
13597 vos_mem_free(pSession->pAddIEAssoc);
13598 }
13599 pSession->pAddIEAssoc = vos_mem_malloc(ieLen);
13600 if (NULL == pSession->pAddIEAssoc)
13601 status = eHAL_STATUS_FAILURE;
13602 else
13603 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013604 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013605 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013606 pSession->nAddIEAssocLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053013607 vos_mem_copy(pSession->pAddIEAssoc, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013608 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013609 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013610 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013611 vos_mem_copy(pBuf, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013612 pBuf += ieLen;
13613 }
13614 else
13615 {
13616 pSession->nAddIEAssocLength = 0;
13617 if(pSession->pAddIEAssoc)
13618 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013619 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070013620 pSession->pAddIEAssoc = NULL;
13621 }
13622 *pBuf = 0;
13623 *(pBuf + 1) = 0;
13624 pBuf += 2;
13625 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013626
13627 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013628 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013629 //Unmask any AC in reassoc that is ACM-set
13630 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
13631 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013632 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013633 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
13634 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013635#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013636 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070013637#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013638 }
13639 else
13640 {
13641 uapsd_mask = 0;
13642 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013643 }
13644 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013645
Jeff Johnson295189b2012-06-20 16:38:30 -070013646 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013647 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013648 pBuf += sizeof(tANI_U32);
13649
Jeff Johnson295189b2012-06-20 16:38:30 -070013650 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013651 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013652 pBuf += sizeof(tANI_U32);
Chet Lanctot186b5732013-03-18 10:26:30 -070013653#ifdef WLAN_FEATURE_11W
13654 //MgmtEncryption
13655 if (pProfile->MFPEnabled)
13656 {
13657 dwTmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
13658 }
13659 else
13660 {
13661 dwTmp = pal_cpu_to_be32(eSIR_ED_NONE);
13662 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013663 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Chet Lanctot186b5732013-03-18 10:26:30 -070013664 pBuf += sizeof(tANI_U32);
13665#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013666#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013667 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053013668 if (csrIsProfile11r( pProfile )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013669#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala09dd66b2013-04-01 17:13:01 +053013670 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013671 (pIes->ESEVersion.present) && (pMac->roam.configParam.isEseIniFeatureEnabled))
Saurabh Gupta775073c2013-02-14 13:31:36 +053013672#endif
13673 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013674 {
13675 // is11Rconnection;
13676 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013677 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool)) ;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013678 pBuf += sizeof(tAniBool);
13679 }
13680 else
13681 {
13682 // is11Rconnection;
13683 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013684 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013685 pBuf += sizeof(tAniBool);
13686 }
13687#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013688#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013689
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013690 // isESEFeatureIniEnabled
13691 if (TRUE == pMac->roam.configParam.isEseIniFeatureEnabled)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013692 {
13693 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013694 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013695 pBuf += sizeof(tAniBool);
13696 }
13697 else
13698 {
13699 dwTmp = pal_cpu_to_be32(FALSE);
Srinivas Girigowda18112782013-11-27 12:21:19 -080013700 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013701 pBuf += sizeof(tAniBool);
13702 }
13703
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013704 /* A profile can not be both ESE and 11R. But an 802.11R AP
13705 * may be advertising support for ESE as well. So if we are
13706 * associating Open or explicitly ESE then we will get ESE.
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013707 * If we are associating explictly 11R only then we will get
13708 * 11R.
13709 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013710 if ((csrIsProfileESE(pProfile) ||
13711 ((pIes->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013712 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
13713 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
13714 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
13715 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
13716#ifdef WLAN_FEATURE_11W
13717 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
Abhishek Singh83080e02014-11-07 12:04:16 +053013718 || (pProfile->negotiatedAuthType ==
13719 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013720#endif
13721 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013722 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013723 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013724 // isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013725 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013726 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013727 pBuf += sizeof(tAniBool);
13728 }
13729 else
13730 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013731 //isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013732 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013733 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013734 pBuf += sizeof(tAniBool);
13735 }
13736
13737 if (eWNI_SME_JOIN_REQ == messageType)
13738 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013739 tESETspecInfo eseTspec;
13740 // ESE-Tspec IEs in the ASSOC request is presently not supported
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013741 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013742 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13743 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
13744 pBuf += sizeof(tESETspecInfo);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013745 }
13746 else if (eWNI_SME_REASSOC_REQ == messageType)
13747 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013748 if ((csrIsProfileESE(pProfile) ||
13749 ((pIes->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013750 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
13751 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
13752 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
13753 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
13754#ifdef WLAN_FEATURE_11W
13755 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
Abhishek Singh83080e02014-11-07 12:04:16 +053013756 || (pProfile->negotiatedAuthType ==
13757 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013758#endif
13759 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013760 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070013761 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013762 tESETspecInfo eseTspec;
13763 // ESE Tspec information
13764 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13765 eseTspec.numTspecs = sme_QosESERetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &eseTspec.tspec[0]);
13766 *pBuf = eseTspec.numTspecs;
Jeff Johnson295189b2012-06-20 16:38:30 -070013767 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013768 // Copy the TSPEC information only if present
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013769 if (eseTspec.numTspecs) {
13770 vos_mem_copy(pBuf, (void*)&eseTspec.tspec[0],
13771 (eseTspec.numTspecs*sizeof(tTspecInfo)));
Jeff Johnson295189b2012-06-20 16:38:30 -070013772 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013773 pBuf += sizeof(eseTspec.tspec);
Jeff Johnson295189b2012-06-20 16:38:30 -070013774 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013775 else
Jeff Johnson295189b2012-06-20 16:38:30 -070013776 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013777 tESETspecInfo eseTspec;
13778 // ESE-Tspec IEs in the ASSOC request is presently not supported
Jeff Johnson295189b2012-06-20 16:38:30 -070013779 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013780 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13781 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
13782 pBuf += sizeof(tESETspecInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070013783 }
13784 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013785#endif // FEATURE_WLAN_ESE
13786#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070013787 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013788 if (pMac->roam.configParam.isFastTransitionEnabled
13789#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053013790 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013791#endif
13792 )
Jeff Johnson295189b2012-06-20 16:38:30 -070013793 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013794 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013795 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013796 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070013797 }
13798 else
13799 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013800 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013801 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013802 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070013803 }
13804#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070013805#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053013806 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070013807 {
13808 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013809 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013810 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013811 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070013812 }
13813 else
13814 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013815 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013816 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013817 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070013818 }
13819#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013820
13821 // txLdpcIniFeatureEnabled
13822 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
13823 pBuf++;
13824
Kiran4a17ebe2013-01-31 10:43:43 -080013825 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
13826 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
13827 {
13828 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
13829 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
13830 csrApplyPower2Current(pMac);
13831 }
13832
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080013833#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080013834 // txBFIniFeatureEnabled
13835 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
13836 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080013837
13838 // txBFCsnValue
Kanchanapally, Vidyullatha3f3b6542015-08-21 14:38:49 +053013839 if (IS_BSS_VHT_CAPABLE(pIes->VHTCaps))
Abhishek Singhcb4d15c2014-11-04 16:09:49 +053013840 {
Kanchanapally, Vidyullatha3f3b6542015-08-21 14:38:49 +053013841 txBFCsnValue = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
13842 if (pIes->VHTCaps.numSoundingDim)
13843 txBFCsnValue = CSR_ROAM_MIN
13844 (txBFCsnValue, pIes->VHTCaps.numSoundingDim);
Abhishek Singhcb4d15c2014-11-04 16:09:49 +053013845 }
13846 *pBuf = txBFCsnValue;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080013847 pBuf++;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +053013848
13849 /* Only enable MuBf if no other MuBF session exist
13850 * and FW and HOST is MuBF capable.
13851 */
13852 if ( IS_MUMIMO_BFORMEE_CAPABLE && (FALSE == pMac->isMuBfsessionexist) )
13853 {
13854 *pBuf = (tANI_U8)pMac->roam.configParam.txMuBformee;
13855 pBuf++;
13856 }
13857 else
13858 {
13859 *pBuf = 0;
13860 pBuf++;
13861 }
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080013862#endif
krunal soni5afa96c2013-09-06 22:19:02 -070013863 *pBuf = (tANI_U8)pMac->roam.configParam.isAmsduSupportInAMPDU;
13864 pBuf++;
13865
Sandeep Puligillaaea98a22013-12-04 13:36:32 +053013866 // WME
13867 if(pMac->roam.roamSession[sessionId].fWMMConnection)
13868 {
13869 //WME enabled
13870 dwTmp = pal_cpu_to_be32(TRUE);
13871 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13872 pBuf += sizeof(tAniBool);
13873 }
13874 else
13875 {
13876 dwTmp = pal_cpu_to_be32(FALSE);
13877 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13878 pBuf += sizeof(tAniBool);
13879 }
13880
13881 // QOS
13882 if(pMac->roam.roamSession[sessionId].fQOSConnection)
13883 {
13884 //QOS enabled
13885 dwTmp = pal_cpu_to_be32(TRUE);
13886 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13887 pBuf += sizeof(tAniBool);
13888 }
13889 else
13890 {
13891 dwTmp = pal_cpu_to_be32(FALSE);
13892 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13893 pBuf += sizeof(tAniBool);
13894 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013895 //BssDesc
13896 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
13897 (tANI_U8)pProfile->uapsd_mask);
krunal soni5afa96c2013-09-06 22:19:02 -070013898
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013899 status = palSendMBMessage(pMac->hHdd, pMsg );
Girish Gowlicc337b12014-07-31 19:10:35 +053013900 /* Memory allocated to pMsg will get free'd in palSendMBMessage */
13901 pMsg = NULL;
13902
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013903 if(!HAL_STATUS_SUCCESS(status))
13904 {
13905 break;
13906 }
13907 else
13908 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013909#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013910 if (eWNI_SME_JOIN_REQ == messageType)
13911 {
13912 //Tush-QoS: notify QoS module that join happening
13913 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
13914 }
13915 else if (eWNI_SME_REASSOC_REQ == messageType)
13916 {
13917 //Tush-QoS: notify QoS module that reassoc happening
13918 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
13919 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013920#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013921 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013922 } while( 0 );
Girish Gowlicc337b12014-07-31 19:10:35 +053013923
13924 if (pMsg != NULL)
13925 {
13926 vos_mem_free( pMsg );
13927 }
13928
Jeff Johnson295189b2012-06-20 16:38:30 -070013929 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013930}
13931
Jeff Johnson295189b2012-06-20 16:38:30 -070013932//
13933eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13934{
13935 eHalStatus status = eHAL_STATUS_SUCCESS;
13936 tSirSmeDisassocReq *pMsg;
13937 tANI_U8 *pBuf;
13938 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013939 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13940 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13941 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013942 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013943 pMsg = vos_mem_malloc(sizeof(tSirSmeDisassocReq));
13944 if (NULL == pMsg)
13945 status = eHAL_STATUS_FAILURE;
13946 else
13947 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013948 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013949 vos_mem_set(pMsg, sizeof( tSirSmeDisassocReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013950 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
13951 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013952 pBuf = &pMsg->sessionId;
13953 // sessionId
13954 *pBuf++ = (tANI_U8)sessionId;
13955 // transactionId
13956 *pBuf = 0;
13957 *( pBuf + 1 ) = 0;
13958 pBuf += sizeof(tANI_U16);
13959
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053013960 if ( (pSession->pCurRoamProfile != NULL) &&
13961 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
13962 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013963 {
13964 // Set the bssid address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013965 vos_mem_copy((tSirMacAddr *)pBuf, pSession->selfMacAddr,
13966 sizeof( tSirMacAddr ));
13967 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013968 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070013969 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013970 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
13971 //perMacAddr is passed as bssId for softAP
13972 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013973 pBuf = pBuf + sizeof ( tSirMacAddr );
13974 }
13975 else
13976 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013977 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013978 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
13979 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013980 pBuf = pBuf + sizeof ( tSirMacAddr );
Kiet Lam64c1b492013-07-12 13:56:44 +053013981 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ));
13982 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013983 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070013984 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013985 if(!HAL_STATUS_SUCCESS(status))
13986 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013987 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013988 break;
13989 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013990 // reasonCode
13991 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013992 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
13993 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013994 if(!HAL_STATUS_SUCCESS(status))
13995 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013996 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013997 break;
13998 }
13999 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070014000 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
14001 Here we should not send the disassoc over the air to the AP */
14002 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
14003#ifdef WLAN_FEATURE_VOWIFI_11R
14004 && csrRoamIs11rAssoc(pMac)
14005#endif
14006 )
14007 {
14008 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
14009 }
14010 pBuf += sizeof(tANI_U8);
14011 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070014012 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014013 return( status );
14014}
Jeff Johnson295189b2012-06-20 16:38:30 -070014015eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
14016{
14017 eHalStatus status = eHAL_STATUS_SUCCESS;
14018 tSirSmeTkipCntrMeasReq *pMsg;
14019 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070014020 do
14021 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014022 pMsg = vos_mem_malloc(sizeof( tSirSmeTkipCntrMeasReq ));
14023 if ( NULL == pMsg )
14024 status = eHAL_STATUS_FAILURE;
14025 else
14026 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014027 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053014028 vos_mem_set(pMsg, sizeof( tSirSmeTkipCntrMeasReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014029 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
14030 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014031 pBuf = &pMsg->sessionId;
14032 // sessionId
14033 *pBuf++ = (tANI_U8)sessionId;
14034 // transactionId
14035 *pBuf = 0;
14036 *( pBuf + 1 ) = 0;
14037 pBuf += sizeof(tANI_U16);
14038 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053014039 vos_mem_copy(pMsg->bssId, bssId, sizeof( tSirMacAddr ));
14040 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014041 pBuf = pBuf + sizeof ( tSirMacAddr );
14042 // bEnable
14043 *pBuf = (tANI_BOOLEAN)bEnable;
14044 if(!HAL_STATUS_SUCCESS(status))
14045 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014046 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014047 break;
14048 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014049 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070014050 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014051 return( status );
14052}
Jeff Johnson295189b2012-06-20 16:38:30 -070014053eHalStatus
14054csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
14055 VOS_MODULE_ID modId, tSirMacAddr bssId,
14056 void *pUsrContext, void *pfnSapEventCallback,
14057 tANI_U8 *pAssocStasBuf )
14058{
14059 eHalStatus status = eHAL_STATUS_SUCCESS;
14060 tSirSmeGetAssocSTAsReq *pMsg;
14061 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
14062 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014063 do
14064 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014065 pMsg = vos_mem_malloc(sizeof( tSirSmeGetAssocSTAsReq ));
14066 if ( NULL == pMsg )
14067 status = eHAL_STATUS_FAILURE;
14068 else
14069 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014070 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053014071 vos_mem_set(pMsg, sizeof( tSirSmeGetAssocSTAsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014072 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070014073 pBuf = (tANI_U8 *)&pMsg->bssId;
14074 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070014075 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053014076 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014077 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014078 // modId
14079 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
Kiet Lam64c1b492013-07-12 13:56:44 +053014080 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070014081 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070014082 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080014083 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void *));
14084 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070014085 // pfnSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080014086 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void*));
14087 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070014088 // pAssocStasBuf
krunal soni4f802b22014-02-11 17:01:13 -080014089 vos_mem_copy(pBuf, pAssocStasBuf, sizeof(void*));
14090 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070014091 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070014092 status = palSendMBMessage( pMac->hHdd, pMsg );
14093 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014094 return( status );
14095 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014096eHalStatus
14097csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
14098 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
14099 {
14100 eHalStatus status = eHAL_STATUS_SUCCESS;
14101 tSirSmeGetWPSPBCSessionsReq *pMsg;
14102 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
krunal soni4f802b22014-02-11 17:01:13 -080014103
Jeff Johnson295189b2012-06-20 16:38:30 -070014104 do
14105 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014106 pMsg = vos_mem_malloc(sizeof(tSirSmeGetWPSPBCSessionsReq));
14107 if ( NULL == pMsg )
14108 status = eHAL_STATUS_FAILURE;
14109 else
14110 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014111 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053014112 vos_mem_set(pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014113 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070014114 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
lukez3c809222013-05-03 10:23:02 -070014115 VOS_ASSERT(pBuf);
14116
Jeff Johnson295189b2012-06-20 16:38:30 -070014117 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070014118 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080014119 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void*));
14120 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070014121 // pSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080014122 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void *));
14123 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070014124 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053014125 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014126 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014127 // MAC Address of STA in WPS session
Kiet Lam64c1b492013-07-12 13:56:44 +053014128 vos_mem_copy((tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
Jeff Johnson295189b2012-06-20 16:38:30 -070014129 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070014130 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070014131 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070014132 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014133 return( status );
14134}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080014135
14136eHalStatus
14137csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
14138{
14139 tpSirChangeBIParams pMsg;
14140 tANI_U16 len = 0;
14141 eHalStatus status = eHAL_STATUS_SUCCESS;
14142 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14143
14144 if(!pSession)
14145 {
14146 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14147 return eHAL_STATUS_FAILURE;
14148 }
14149
14150 //NO need to update the Beacon Params if update beacon parameter flag is not set
14151 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
14152 return eHAL_STATUS_SUCCESS;
14153
14154 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
14155
14156 /* Create the message and send to lim */
14157 len = sizeof(tSirChangeBIParams);
Kiet Lam64c1b492013-07-12 13:56:44 +053014158 pMsg = vos_mem_malloc(len);
14159 if ( NULL == pMsg )
14160 status = eHAL_STATUS_FAILURE;
14161 else
14162 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080014163 if(HAL_STATUS_SUCCESS(status))
14164 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014165 vos_mem_set(pMsg, sizeof(tSirChangeBIParams), 0);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080014166 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
14167 pMsg->length = len;
14168
14169 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053014170 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
14171 sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -080014172 smsLog( pMac, LOG1, FL("CSR Attempting to change BI for Bssid= "MAC_ADDRESS_STR),
14173 MAC_ADDR_ARRAY(pMsg->bssId));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080014174 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014175 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080014176 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
14177 status = palSendMBMessage(pMac->hHdd, pMsg);
14178 }
14179 return status;
14180}
14181
Hardik Kantilal Patel62a3a762014-11-21 12:55:57 +053014182#ifdef WLAN_FEATURE_AP_HT40_24G
14183eHalStatus csrSetHT2040Mode(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U8 cbMode)
14184{
14185 tpSirSetHT2040Mode pMsg;
14186 tANI_U16 len = 0;
14187 eHalStatus status = eHAL_STATUS_SUCCESS;
14188 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14189
14190 if(!pSession)
14191 {
14192 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14193 return eHAL_STATUS_FAILURE;
14194 }
14195
14196 /* Create the message and send to lim */
14197 len = sizeof(tSirSetHT2040Mode);
14198 pMsg = vos_mem_malloc(len);
14199
14200 if ( NULL == pMsg )
14201 {
14202 smsLog( pMac, LOGE, FL("Memory Allocation Fail !!!"));
14203 status = eHAL_STATUS_FAILURE;
14204 }
14205 else
14206 status = eHAL_STATUS_SUCCESS;
14207
14208 if(HAL_STATUS_SUCCESS(status))
14209 {
14210 vos_mem_set(pMsg, sizeof(tSirSetHT2040Mode), 0);
14211 pMsg->messageType = eWNI_SME_SET_HT_2040_MODE;
14212 pMsg->length = len;
14213
14214 // bssId
14215 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
14216 sizeof(tSirMacAddr));
14217
14218 smsLog( pMac, LOGW, FL("CSR Attempting to set "
14219 "HT20/40 mode for Bssid= "MAC_ADDRESS_STR),
14220 MAC_ADDR_ARRAY(pMsg->bssId));
14221
14222 pMsg->sessionId = sessionId;
14223 pMsg->cbMode = cbMode;
14224
14225 smsLog(pMac, LOGW, FL("session %d Channel Bonding: %d"),
14226 sessionId, cbMode);
14227
14228 status = palSendMBMessage(pMac->hHdd, pMsg);
14229 }
14230 return status;
14231}
14232#endif
14233
Jeff Johnson295189b2012-06-20 16:38:30 -070014234eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
14235{
14236 eHalStatus status = eHAL_STATUS_SUCCESS;
14237 tSirSmeDeauthReq *pMsg;
14238 tANI_U8 *pBuf;
14239 tANI_U16 wTmp;
14240 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14241 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
14242 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014243 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053014244 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthReq ));
14245 if ( NULL == pMsg )
14246 status = eHAL_STATUS_FAILURE;
14247 else
14248 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014249 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053014250 vos_mem_set(pMsg, sizeof( tSirSmeDeauthReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014251 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
14252 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
14253 //sessionId
14254 pBuf = &pMsg->sessionId;
14255 *pBuf++ = (tANI_U8)sessionId;
14256
14257 //tansactionId
14258 *pBuf = 0;
14259 *(pBuf + 1 ) = 0;
14260 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070014261 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070014262 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070014263 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
14264 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053014265 vos_mem_copy( (tSirMacAddr *)pBuf, pSession->selfMacAddr,
14266 sizeof( pMsg->peerMacAddr ) );
14267 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014268 pBuf = pBuf + sizeof(tSirMacAddr);
14269 }
14270 else
14271 {
14272 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053014273 vos_mem_copy( (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
14274 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014275 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014276 }
14277 if(!HAL_STATUS_SUCCESS(status))
14278 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014279 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014280 break;
14281 }
14282 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053014283 vos_mem_copy( (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
14284 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014285 pBuf = pBuf + sizeof(tSirMacAddr);
14286 if(!HAL_STATUS_SUCCESS(status))
14287 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014288 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014289 break;
14290 }
14291 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053014292 vos_mem_copy( pBuf, &wTmp,sizeof( tANI_U16 ) );
14293 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014294 if(!HAL_STATUS_SUCCESS(status))
14295 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014296 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014297 break;
14298 }
14299 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070014300 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014301 return( status );
14302}
14303
Jeff Johnson295189b2012-06-20 16:38:30 -070014304eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
14305{
14306 eHalStatus status = eHAL_STATUS_SUCCESS;
14307 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070014308 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053014309 pMsg = vos_mem_malloc(sizeof( tSirSmeDisassocCnf ));
14310 if ( NULL == pMsg )
14311 status = eHAL_STATUS_FAILURE;
14312 else
14313 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014314 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053014315 vos_mem_set(pMsg, sizeof( tSirSmeDisassocCnf), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014316 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
14317 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
14318 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
Wu Gao742b7352015-10-16 19:10:40 +080014319 pMsg->assocId = pal_cpu_to_be16((tANI_U16)pDisassocInd->assocId);
Kiet Lam64c1b492013-07-12 13:56:44 +053014320 vos_mem_copy(pMsg->peerMacAddr, pDisassocInd->peerMacAddr,
14321 sizeof(pMsg->peerMacAddr));
14322 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014323 if(!HAL_STATUS_SUCCESS(status))
14324 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014325 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014326 break;
14327 }
14328//To test reconn
Kiet Lam64c1b492013-07-12 13:56:44 +053014329 vos_mem_copy(pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
14330 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014331 if(!HAL_STATUS_SUCCESS(status))
14332 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014333 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014334 break;
14335 }
14336//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070014337 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070014338 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014339 return( status );
14340}
14341
Jeff Johnson295189b2012-06-20 16:38:30 -070014342eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
14343{
14344 eHalStatus status = eHAL_STATUS_SUCCESS;
14345 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070014346 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053014347 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthCnf ));
14348 if ( NULL == pMsg )
14349 status = eHAL_STATUS_FAILURE;
14350 else
14351 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014352 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053014353 vos_mem_set(pMsg, sizeof( tSirSmeDeauthCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014354 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
14355 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
14356 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
Wu Gao742b7352015-10-16 19:10:40 +080014357 pMsg->assocId = pal_cpu_to_be16((tANI_U16)pDeauthInd->assocId);
Kiet Lam64c1b492013-07-12 13:56:44 +053014358 vos_mem_copy(pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
14359 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014360 if(!HAL_STATUS_SUCCESS(status))
14361 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014362 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014363 break;
14364 }
Kiet Lam64c1b492013-07-12 13:56:44 +053014365 vos_mem_copy(pMsg->peerMacAddr, pDeauthInd->peerMacAddr,
14366 sizeof(pMsg->peerMacAddr));
14367 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014368 if(!HAL_STATUS_SUCCESS(status))
14369 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014370 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014371 break;
14372 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014373 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070014374 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014375 return( status );
14376}
Jeff Johnson295189b2012-06-20 16:38:30 -070014377eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
14378{
14379 eHalStatus status = eHAL_STATUS_SUCCESS;
14380 tSirSmeAssocCnf *pMsg;
14381 tANI_U8 *pBuf;
14382 tSirResultCodes statusCode;
14383 tANI_U16 wTmp;
Sachin Ahuja2fea3d12014-12-18 17:31:31 +053014384
14385 smsLog( pMac, LOG1, FL("Posting eWNI_SME_ASSOC_CNF to LIM. "
14386 "HalStatus : %d"),
14387 Halstatus);
Jeff Johnson295189b2012-06-20 16:38:30 -070014388 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053014389 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocCnf ));
14390 if ( NULL == pMsg )
14391 status = eHAL_STATUS_FAILURE;
14392 else
14393 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014394 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053014395 vos_mem_set(pMsg, sizeof( tSirSmeAssocCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014396 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
14397 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014398 pBuf = (tANI_U8 *)&pMsg->statusCode;
14399 if(HAL_STATUS_SUCCESS(Halstatus))
14400 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
14401 else
14402 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053014403 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes));
Jeff Johnson295189b2012-06-20 16:38:30 -070014404 pBuf += sizeof(tSirResultCodes);
14405 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053014406 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
14407 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014408 pBuf += sizeof (tSirMacAddr);
14409 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053014410 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
14411 sizeof(tSirMacAddr));
14412 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014413 pBuf += sizeof (tSirMacAddr);
14414 // aid
14415 wTmp = pal_cpu_to_be16(pAssocInd->aid);
Kiet Lam64c1b492013-07-12 13:56:44 +053014416 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070014417 pBuf += sizeof (tANI_U16);
14418 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053014419 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
14420 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014421 pBuf += sizeof (tSirMacAddr);
14422 // alternateChannelId
14423 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070014424 status = palSendMBMessage( pMac->hHdd, pMsg );
14425 if(!HAL_STATUS_SUCCESS(status))
14426 {
14427 //pMsg is freed by palSendMBMessage
14428 break;
14429 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014430 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014431 return( status );
14432}
Jeff Johnson295189b2012-06-20 16:38:30 -070014433eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
14434 tpSirSmeAssocInd pAssocInd,
14435 eHalStatus Halstatus,
14436 tANI_U8 sessionId)
14437{
14438 tSirMsgQ msgQ;
Jeff Johnson295189b2012-06-20 16:38:30 -070014439 tSirSmeAssocIndToUpperLayerCnf *pMsg;
14440 tANI_U8 *pBuf;
14441 tSirResultCodes statusCode;
14442 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014443 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053014444 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocIndToUpperLayerCnf ));
14445 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14446 vos_mem_set(pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ), 0);
Jeff Johnsone7245742012-09-05 17:12:55 -070014447
Jeff Johnson295189b2012-06-20 16:38:30 -070014448 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
14449 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
14450
14451 pMsg->sessionId = sessionId;
14452
14453 pBuf = (tANI_U8 *)&pMsg->statusCode;
14454 if(HAL_STATUS_SUCCESS(Halstatus))
14455 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
14456 else
14457 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053014458 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes)) ;
Jeff Johnson295189b2012-06-20 16:38:30 -070014459 pBuf += sizeof(tSirResultCodes);
14460 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053014461 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014462 pBuf += sizeof (tSirMacAddr);
14463 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053014464 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
14465 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014466 pBuf += sizeof (tSirMacAddr);
14467 // StaId
14468 wTmp = pal_cpu_to_be16(pAssocInd->staId);
Kiet Lam64c1b492013-07-12 13:56:44 +053014469 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070014470 pBuf += sizeof (tANI_U16);
14471 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053014472 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014473 pBuf += sizeof (tSirMacAddr);
14474 // alternateChannelId
14475 *pBuf = 11;
14476 pBuf += sizeof (tANI_U8);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014477 // Instead of copying roam Info, we just copy only WmmEnabled, RsnIE information
Jeff Johnson295189b2012-06-20 16:38:30 -070014478 //Wmm
14479 *pBuf = pAssocInd->wmmEnabledSta;
14480 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070014481 //RSN IE
Kiet Lam64c1b492013-07-12 13:56:44 +053014482 vos_mem_copy((tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070014483 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070014484 //Additional IE
Kiet Lam64c1b492013-07-12 13:56:44 +053014485 vos_mem_copy((void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
Jeff Johnson295189b2012-06-20 16:38:30 -070014486 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070014487 //reassocReq
14488 *pBuf = pAssocInd->reassocReq;
14489 pBuf += sizeof (tANI_U8);
Hardik Kantilal Patel1ba630f2014-11-21 04:32:05 +053014490#ifdef WLAN_FEATURE_AP_HT40_24G
14491 // 40 MHz Intolerant
14492 *pBuf = pAssocInd->HT40MHzIntoEnabledSta;
14493 pBuf += sizeof (tANI_U8);
14494#endif
Deepthi Gowriae6a1662015-10-12 12:59:37 +053014495 *pBuf = pAssocInd->rate_flags;
14496 pBuf += sizeof (uint32_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070014497 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
14498 msgQ.bodyptr = pMsg;
14499 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014500 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070014501 } while( 0 );
Kiet Lam64c1b492013-07-12 13:56:44 +053014502 return( eHAL_STATUS_SUCCESS );
Jeff Johnson295189b2012-06-20 16:38:30 -070014503}
Jeff Johnson295189b2012-06-20 16:38:30 -070014504
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014505eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -070014506 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
14507 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
14508 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
14509 tANI_U8 *pKeyRsc )
14510{
14511 tSirSmeSetContextReq *pMsg;
14512 tANI_U16 msgLen;
14513 eHalStatus status = eHAL_STATUS_FAILURE;
14514 tAniEdType tmpEdType;
14515 tAniKeyDirection tmpDirection;
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +053014516 tANI_U8 *pBuf = NULL;
14517 tANI_U8 *p = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014518 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Sushant Kaushike7de85f2014-06-16 17:13:30 +053014519 smsLog( pMac, LOG1, FL("keylength is %d, Encry type is : %d"),
14520 keyLength, edType);
Jeff Johnson295189b2012-06-20 16:38:30 -070014521 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070014522 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014523 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
14524 // key set. Since we only support upto one key, we always allocate memory for 1 key
14525 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
14526 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
14527 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
14528 ( sizeof( pMsg->keyMaterial.key ) );
14529
Kiet Lam64c1b492013-07-12 13:56:44 +053014530 pMsg = vos_mem_malloc(msgLen);
14531 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14532 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014533 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
14534 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014535 //sessionId
14536 pBuf = &pMsg->sessionId;
14537 *pBuf = (tANI_U8)sessionId;
14538 pBuf++;
14539 // transactionId
14540 *pBuf = 0;
14541 *(pBuf + 1) = 0;
14542 pBuf += sizeof(tANI_U16);
14543 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053014544 vos_mem_copy(pBuf, (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014545
14546 pBuf += sizeof(tSirMacAddr);
14547
14548 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053014549 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
14550 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014551
14552 pBuf += sizeof(tSirMacAddr);
14553
14554 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070014555 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
14556 // in the tSirKeyMaterial keyMaterial; field).
14557 //
14558 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
14559 // shorter than this max size. Is LIM interpreting this ok ?
14560 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 -070014561 // set pMsg->keyMaterial.edType
14562 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
Kiet Lam64c1b492013-07-12 13:56:44 +053014563 vos_mem_copy(p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType));
Jeff Johnson295189b2012-06-20 16:38:30 -070014564 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070014565 // set the pMsg->keyMaterial.numKeys field
14566 *p = numKeys;
14567 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070014568 // set pSirKey->keyId = keyId;
14569 *p = keyId;
14570 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014571 // set pSirKey->unicast = (tANI_U8)fUnicast;
14572 *p = (tANI_U8)fUnicast;
14573 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070014574 // set pSirKey->keyDirection = aniKeyDirection;
14575 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
Kiet Lam64c1b492013-07-12 13:56:44 +053014576 vos_mem_copy(p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection));
Jeff Johnson295189b2012-06-20 16:38:30 -070014577 p += sizeof(tAniKeyDirection);
14578 // pSirKey->keyRsc = ;;
Kiet Lam64c1b492013-07-12 13:56:44 +053014579 vos_mem_copy(p, pKeyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -070014580 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070014581 // set pSirKey->paeRole
14582 *p = paeRole; // 0 is Supplicant
14583 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014584 // set pSirKey->keyLength = keyLength;
14585 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070014586 if ( keyLength && pKey )
14587 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014588 vos_mem_copy(p, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070014589 if(keyLength == 16)
14590 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014591 smsLog(pMac, LOG1, " SME Set keyIdx (%d) encType(%d) key = %02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X-%02X",
Jeff Johnson295189b2012-06-20 16:38:30 -070014592 keyId, edType, pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
14593 pKey[5], pKey[6], pKey[7], pKey[8],
14594 pKey[9], pKey[10], pKey[11], pKey[12], pKey[13], pKey[14], pKey[15]);
14595 }
14596 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014597 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014598 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014599 return( status );
14600}
14601
Jeff Johnson295189b2012-06-20 16:38:30 -070014602eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
14603 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
14604{
14605 eHalStatus status;
14606 tSirSmeStartBssReq *pMsg;
14607 tANI_U8 *pBuf = NULL;
14608 tANI_U8 *wTmpBuf = NULL;
14609 tANI_U16 msgLen, wTmp;
14610 tANI_U32 dwTmp;
14611 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070014612 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070014613 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070014614 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014615
14616 if(!pSession)
14617 {
14618 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14619 return eHAL_STATUS_FAILURE;
14620 }
14621
Jeff Johnson295189b2012-06-20 16:38:30 -070014622 do {
14623 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
14624 pSession->joinFailStatusCode.reasonCode = 0;
14625 msgLen = sizeof(tSirSmeStartBssReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053014626 pMsg = vos_mem_malloc(msgLen);
14627 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14628 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014629 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070014630 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070014631 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070014632 //sessionId
14633 *pBuf = (tANI_U8)sessionId;
14634 pBuf++;
14635 // transactionId
14636 *pBuf = 0;
14637 *(pBuf + 1) = 0;
14638 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070014639 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053014640 vos_mem_copy(pBuf, pParam->bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014641 pBuf += sizeof(tSirMacAddr);
14642 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053014643 vos_mem_copy(pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014644 pBuf += sizeof(tSirMacAddr);
14645 // beaconInterval
14646 if( pBssDesc && pBssDesc->beaconInterval )
14647 {
14648 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
14649 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014650 else if(pParam->beaconInterval)
14651 {
14652 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
14653 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014654 else
14655 {
14656 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
14657 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -070014658 if(csrIsconcurrentsessionValid (pMac, sessionId,
14659 pParam->bssPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -070014660 == eHAL_STATUS_SUCCESS )
14661 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080014662 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070014663 pParam->bssPersona);
14664 //Update the beacon Interval
14665 pParam->beaconInterval = wTmp;
14666 }
14667 else
14668 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014669 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070014670 status = eHAL_STATUS_FAILURE;
Kiet Lam64c1b492013-07-12 13:56:44 +053014671 vos_mem_free(pMsg);
Jeff Johnsone7245742012-09-05 17:12:55 -070014672 return status;
14673 }
14674
Kiet Lam64c1b492013-07-12 13:56:44 +053014675 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014676 pBuf += sizeof(tANI_U16);
14677 // dot11mode
14678 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
14679 pBuf += 1;
14680 // bssType
14681 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053014682 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070014683 pBuf += sizeof(tSirBssType);
14684 // ssId
14685 if( pParam->ssId.length )
14686 {
14687 // ssId len
14688 *pBuf = pParam->ssId.length;
14689 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053014690 vos_mem_copy(pBuf, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070014691 pBuf += pParam->ssId.length;
14692 }
14693 else
14694 {
14695 *pBuf = 0;
14696 pBuf++;
14697 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014698 // set the channel Id
14699 *pBuf = pParam->operationChn;
14700 pBuf++;
14701 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070014702 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
Kiet Lam64c1b492013-07-12 13:56:44 +053014703 vos_mem_copy(pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState));
Jeff Johnsone7245742012-09-05 17:12:55 -070014704 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070014705
Jeff Johnson295189b2012-06-20 16:38:30 -070014706 // Set privacy
14707 *pBuf = pParam->privacy;
14708 pBuf++;
14709
14710 //Set Uapsd
14711 *pBuf = pParam->ApUapsdEnable;
14712 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014713 //Set SSID hidden
14714 *pBuf = pParam->ssidHidden;
14715 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014716 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
14717 pBuf++;
14718
14719 //Ht protection Enable/Disable
14720 *pBuf = (tANI_U8)pParam->protEnabled;
14721 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014722 //Enable Beacons to Receive for OBSS protection Enable/Disable
14723 *pBuf = (tANI_U8)pParam->obssProtEnabled;
14724 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014725 //set cfg related to protection
14726 wTmp = pal_cpu_to_be16( pParam->ht_protection );
Kiet Lam64c1b492013-07-12 13:56:44 +053014727 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014728 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070014729 // Set Auth type
14730 authType = pal_cpu_to_be32(pParam->authType);
Kiet Lam64c1b492013-07-12 13:56:44 +053014731 vos_mem_copy(pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070014732 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070014733 // Set DTIM
14734 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
Kiet Lam64c1b492013-07-12 13:56:44 +053014735 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070014736 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070014737 // Set wps_state
14738 *pBuf = pParam->wps_state;
14739 pBuf++;
krunal sonie9002db2013-11-25 14:24:17 -080014740 // set isCoalesingInIBSSAllowed
14741 *pBuf = pMac->isCoalesingInIBSSAllowed;
14742 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014743 //Persona
14744 *pBuf = (tANI_U8)pParam->bssPersona;
14745 pBuf++;
14746
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080014747 //txLdpcIniFeatureEnabled
14748 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
14749 pBuf++;
krunal soni4f087d22013-07-29 16:32:26 -070014750
Chet Lanctot8cecea22014-02-11 19:09:36 -080014751#ifdef WLAN_FEATURE_11W
14752 // Set MFP capable/required
14753 *pBuf = (tANI_U8)pParam->mfpCapable;
14754 pBuf++;
14755 *pBuf = (tANI_U8)pParam->mfpRequired;
14756 pBuf++;
14757#endif
14758
krunal soni4f087d22013-07-29 16:32:26 -070014759 // set RSN IE
Jeff Johnson295189b2012-06-20 16:38:30 -070014760 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
14761 {
14762 status = eHAL_STATUS_INVALID_PARAMETER;
Kiet Lam64c1b492013-07-12 13:56:44 +053014763 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014764 break;
14765 }
14766 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
Kiet Lam64c1b492013-07-12 13:56:44 +053014767 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070014768 pBuf += sizeof(tANI_U16);
14769 if( wTmp )
14770 {
14771 wTmp = pParam->nRSNIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +053014772 vos_mem_copy(pBuf, pParam->pRSNIE, wTmp);
Jeff Johnson295189b2012-06-20 16:38:30 -070014773 pBuf += wTmp;
14774 }
14775 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
Kiet Lam64c1b492013-07-12 13:56:44 +053014776 vos_mem_copy(pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType));
Jeff Johnson295189b2012-06-20 16:38:30 -070014777 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070014778 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
14779 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053014780 vos_mem_copy(pBuf, pParam->operationalRateSet.rate,
14781 pParam->operationalRateSet.numRates );
Jeff Johnson295189b2012-06-20 16:38:30 -070014782 pBuf += pParam->operationalRateSet.numRates ;
14783 *pBuf++ = pParam->extendedRateSet.numRates;
14784 if(0 != pParam->extendedRateSet.numRates)
14785 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014786 vos_mem_copy(pBuf, pParam->extendedRateSet.rate,
14787 pParam->extendedRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070014788 pBuf += pParam->extendedRateSet.numRates;
14789 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053014790#ifdef WLAN_FEATURE_AP_HT40_24G
14791 *pBuf++ = (tANI_U8)pMac->roam.configParam.apHT40_24GEnabled;
14792#endif
krunal sonie9002db2013-11-25 14:24:17 -080014793
Jeff Johnson295189b2012-06-20 16:38:30 -070014794 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
14795 pMsg->length = pal_cpu_to_be16(msgLen);
14796
14797 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014798 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014799 return( status );
14800}
14801
Jeff Johnson295189b2012-06-20 16:38:30 -070014802eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
14803{
14804 eHalStatus status = eHAL_STATUS_FAILURE;
14805 tSirSmeStopBssReq *pMsg;
14806 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14807 tANI_U8 *pBuf;
14808 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070014809
14810 if(!pSession)
14811 {
14812 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14813 return eHAL_STATUS_FAILURE;
14814 }
14815
Abhishek Singhe2bb7842015-03-12 17:34:03 +053014816 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
14817 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14818 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
14819 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
14820 pBuf = &pMsg->sessionId;
14821 //sessionId
14822 *pBuf = (tANI_U8)sessionId;
14823 pBuf++;
14824 // transactionId
14825 *pBuf = 0;
14826 pBuf += sizeof(tANI_U16);
14827 //reason code
14828 *pBuf = 0;
14829 pBuf += sizeof(tSirResultCodes);
14830 // bssid
14831 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
14832 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
14833 {
14834 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->selfMacAddr,
14835 sizeof(tSirMacAddr));
14836 }
14837 else
14838 {
14839 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
14840 sizeof(tSirMacAddr));
14841 }
14842 pBuf += sizeof(tSirMacAddr);
14843 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
14844 pMsg->length = pal_cpu_to_be16(msgLen);
14845 status = palSendMBMessage( pMac->hHdd, pMsg );
14846
Jeff Johnson295189b2012-06-20 16:38:30 -070014847 return( status );
14848}
14849
Jeff Johnson295189b2012-06-20 16:38:30 -070014850eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
14851 tCsrRoamModifyProfileFields *pModProfileFields,
14852 tANI_U32 *pRoamId, v_BOOL_t fForce)
14853{
Jeff Johnson295189b2012-06-20 16:38:30 -070014854 eHalStatus status = eHAL_STATUS_FAILURE;
14855 tANI_U32 roamId = 0;
14856 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014857 if((csrIsConnStateConnected(pMac, sessionId)) &&
Kiet Lam64c1b492013-07-12 13:56:44 +053014858 (fForce || (!vos_mem_compare( &pModProfileFields,
14859 &pSession->connectedProfile.modifyProfileFields,
14860 sizeof(tCsrRoamModifyProfileFields)))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070014861 {
14862 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
14863 if(pRoamId)
14864 {
14865 *pRoamId = roamId;
14866 }
14867
Jeff Johnson295189b2012-06-20 16:38:30 -070014868 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
14869 eCsrSmeIssuedReassocToSameAP, roamId,
14870 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014871 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014872 return status;
14873}
Jeff Johnson295189b2012-06-20 16:38:30 -070014874static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
14875{
14876 eHalStatus status = eHAL_STATUS_SUCCESS;
14877 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +053014878 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014879 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
14880 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
14881 return (status);
14882}
Jeff Johnson295189b2012-06-20 16:38:30 -070014883eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
14884{
14885 eHalStatus status = eHAL_STATUS_SUCCESS;
14886 tListElem *pEntry = NULL;
14887 tSmeCmd *pCommand = NULL;
14888 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014889 do
14890 {
14891 if(pMsg == NULL)
14892 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014893 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014894 status = eHAL_STATUS_FAILURE;
14895 break;
14896 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014897 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
14898 if(pEntry)
14899 {
14900 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14901 if(eSmeCommandAddStaSession == pCommand->command)
14902 {
14903 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014904 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Siddharth Bhal85f99b12014-05-09 08:09:07 +053014905 if (pRsp->status == eSIR_FAILURE) {
14906 VOS_ASSERT( 0 );
14907 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014908 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070014909 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014910 //Remove this command out of the active list
14911 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
14912 {
14913 //Now put this command back on the avilable command list
14914 csrReleaseCommand(pMac, pCommand);
14915 }
14916 smeProcessPendingQueue( pMac );
14917 }
14918 else
14919 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014920 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 -070014921 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014922 status = eHAL_STATUS_FAILURE;
14923 break;
14924 }
14925 }
14926 else
14927 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014928 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 -070014929 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014930 status = eHAL_STATUS_FAILURE;
14931 break;
14932 }
14933 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014934 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014935}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014936eHalStatus csrSendMBAddSelfStaReqMsg(tpAniSirGlobal pMac,
14937 tAddStaForSessionCmd *pAddStaReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070014938{
14939 tSirSmeAddStaSelfReq *pMsg;
14940 tANI_U16 msgLen;
14941 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014942 do {
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014943 msgLen = sizeof(tSirSmeAddStaSelfReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053014944 pMsg = vos_mem_malloc(msgLen);
14945 if ( NULL == pMsg ) break;
14946 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014947 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
14948 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014949 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053014950 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr,
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014951 (tANI_U8 *)&pAddStaReq->selfMacAddr, sizeof(tSirMacAddr));
14952
14953 pMsg->currDeviceMode = pAddStaReq->currDeviceMode;
14954
Arif Hussain24bafea2013-11-15 15:10:03 -080014955 smsLog( pMac, LOG1, FL("selfMac="MAC_ADDRESS_STR),
14956 MAC_ADDR_ARRAY(pMsg->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014957 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014958 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014959 return( status );
14960}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014961eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac,
14962 tANI_U32 sessionId,
14963 tSirMacAddr sessionMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -070014964{
14965 eHalStatus status = eHAL_STATUS_SUCCESS;
14966 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014967 pCommand = csrGetCommandBuffer(pMac);
14968 if(NULL == pCommand)
14969 {
14970 status = eHAL_STATUS_RESOURCES;
14971 }
14972 else
14973 {
14974 pCommand->command = eSmeCommandAddStaSession;
14975 pCommand->sessionId = (tANI_U8)sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053014976 vos_mem_copy(pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr,
14977 sizeof( tSirMacAddr ) );
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014978 pCommand->u.addStaSessionCmd.currDeviceMode = pMac->sme.currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070014979 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
14980 if( !HAL_STATUS_SUCCESS( status ) )
14981 {
14982 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014983 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014984 }
14985 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014986 return (status);
14987}
Jeff Johnson295189b2012-06-20 16:38:30 -070014988eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14989{
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014990 return csrSendMBAddSelfStaReqMsg(pMac, &pCommand->u.addStaSessionCmd);
Jeff Johnson295189b2012-06-20 16:38:30 -070014991}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014992eHalStatus csrRoamOpenSession(tpAniSirGlobal pMac,
14993 csrRoamCompleteCallback callback,
14994 void *pContext, tANI_U8 *pSelfMacAddr,
14995 tANI_U8 *pbSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -070014996{
14997 eHalStatus status = eHAL_STATUS_SUCCESS;
14998 tANI_U32 i;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +053014999 tCsrRoamSession *pSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015000 *pbSessionId = CSR_SESSION_ID_INVALID;
15001 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
15002 {
15003 if( !CSR_IS_SESSION_VALID( pMac, i ) )
15004 {
15005 pSession = CSR_GET_SESSION( pMac, i );
15006 status = eHAL_STATUS_SUCCESS;
15007 pSession->sessionActive = eANI_BOOLEAN_TRUE;
15008 pSession->sessionId = (tANI_U8)i;
15009 pSession->callback = callback;
15010 pSession->pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053015011 vos_mem_copy(&pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070015012 *pbSessionId = (tANI_U8)i;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015013 status = vos_timer_init(&pSession->hTimerRoaming, VOS_TIMER_TYPE_SW,
15014 csrRoamRoamingTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070015015 &pSession->roamingTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015016 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015017 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015018 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015019 break;
15020 }
15021#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015022 status = vos_timer_init(&pSession->hTimerJoinRetry, VOS_TIMER_TYPE_SW,
15023 csrRoamJoinRetryTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070015024 &pSession->joinRetryTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015025 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015026 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015027 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015028 break;
15029 }
15030#endif
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070015031 status = csrIssueAddStaForSessionReq (pMac, i, pSelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015032 break;
15033 }
15034 }
15035 if( CSR_ROAM_SESSION_MAX == i )
15036 {
15037 //No session is available
15038 status = eHAL_STATUS_RESOURCES;
15039 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015040 return ( status );
15041}
Jeff Johnson295189b2012-06-20 16:38:30 -070015042eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
15043{
15044 eHalStatus status = eHAL_STATUS_SUCCESS;
15045 tListElem *pEntry = NULL;
15046 tSmeCmd *pCommand = NULL;
15047 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070015048 do
15049 {
15050 if(pMsg == NULL)
15051 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015052 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015053 status = eHAL_STATUS_FAILURE;
15054 break;
15055 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015056 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
15057 if(pEntry)
15058 {
15059 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
15060 if(eSmeCommandDelStaSession == pCommand->command)
15061 {
15062 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070015063 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015064 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070015065 //This session is done.
15066 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070015067 if(pCommand->u.delStaSessionCmd.callback)
15068 {
15069
15070 status = sme_ReleaseGlobalLock( &pMac->sme );
15071 if ( HAL_STATUS_SUCCESS( status ) )
15072 {
15073 pCommand->u.delStaSessionCmd.callback(
15074 pCommand->u.delStaSessionCmd.pContext);
15075 status = sme_AcquireGlobalLock( &pMac->sme );
15076 if (! HAL_STATUS_SUCCESS( status ) )
15077 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015078 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015079 return status;
15080 }
15081 }
15082 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015083 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015084 }
15085 }
15086
15087 //Remove this command out of the active list
15088 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
15089 {
15090 //Now put this command back on the avilable command list
15091 csrReleaseCommand(pMac, pCommand);
15092 }
15093 smeProcessPendingQueue( pMac );
15094 }
15095 else
15096 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015097 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 -070015098 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015099 status = eHAL_STATUS_FAILURE;
15100 break;
15101 }
15102 }
15103 else
15104 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015105 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 -070015106 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070015107 status = eHAL_STATUS_FAILURE;
15108 break;
15109 }
15110 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015111 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015112}
Jeff Johnson295189b2012-06-20 16:38:30 -070015113eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
15114{
15115 tSirSmeDelStaSelfReq *pMsg;
15116 tANI_U16 msgLen;
15117 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015118 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070015119 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
15120 sizeof( tSirBssType )*/;
Kiet Lam64c1b492013-07-12 13:56:44 +053015121 pMsg = vos_mem_malloc(msgLen);
15122 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
15123 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070015124 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
15125 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070015126 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053015127 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr,
15128 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070015129 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015130 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070015131 return( status );
15132}
Jeff Johnson295189b2012-06-20 16:38:30 -070015133eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
mukul sharmabab477d2015-06-11 17:14:55 +053015134 tANI_BOOLEAN fHighPriority,
Jeff Johnson295189b2012-06-20 16:38:30 -070015135 tSirMacAddr sessionMacAddr,
15136 csrRoamSessionCloseCallback callback,
15137 void *pContext)
15138{
15139 eHalStatus status = eHAL_STATUS_SUCCESS;
15140 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070015141 pCommand = csrGetCommandBuffer(pMac);
15142 if(NULL == pCommand)
15143 {
15144 status = eHAL_STATUS_RESOURCES;
15145 }
15146 else
15147 {
15148 pCommand->command = eSmeCommandDelStaSession;
15149 pCommand->sessionId = (tANI_U8)sessionId;
15150 pCommand->u.delStaSessionCmd.callback = callback;
15151 pCommand->u.delStaSessionCmd.pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053015152 vos_mem_copy(pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr,
15153 sizeof( tSirMacAddr ));
mukul sharmabab477d2015-06-11 17:14:55 +053015154 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
Jeff Johnson295189b2012-06-20 16:38:30 -070015155 if( !HAL_STATUS_SUCCESS( status ) )
15156 {
15157 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015158 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070015159 }
15160 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015161 return (status);
15162}
Jeff Johnson295189b2012-06-20 16:38:30 -070015163eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
15164{
15165 return csrSendMBDelSelfStaReqMsg( pMac,
15166 pCommand->u.delStaSessionCmd.selfMacAddr );
15167}
Abhishek Singh7b2d0812016-04-28 11:44:29 +053015168static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId,
15169 bool flush_all)
Jeff Johnson295189b2012-06-20 16:38:30 -070015170{
15171 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
15172 tListElem *pEntry, *pNext;
15173 tSmeCmd *pCommand;
15174 tDblLinkList localList;
15175
15176 vos_mem_zero(&localList, sizeof(tDblLinkList));
15177 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
15178 {
15179 smsLog(pMac, LOGE, FL(" failed to open list"));
15180 return;
15181 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015182 csrLLLock(pList);
15183 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
15184 while(pEntry != NULL)
15185 {
15186 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
15187 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Abhishek Singh7b2d0812016-04-28 11:44:29 +053015188
15189 if (!flush_all &&
15190 csr_is_disconnect_full_power_cmd(pCommand)) {
15191 smsLog(pMac, LOGW, FL(" Ignore disconnect"));
15192 pEntry = pNext;
15193 continue;
15194 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015195 if(pCommand->sessionId == sessionId)
15196 {
15197 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
15198 {
15199 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
15200 }
15201 }
15202 pEntry = pNext;
15203 }
15204 csrLLUnlock(pList);
15205
15206 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
15207 {
15208 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
15209 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
15210 }
15211 csrLLClose(&localList);
15212}
15213
Jeff Johnson295189b2012-06-20 16:38:30 -070015214void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
15215{
15216 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
15217 {
15218 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070015219 csrRoamStop(pMac, sessionId);
15220 csrFreeConnectBssDesc(pMac, sessionId);
15221 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
15222 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015223 vos_timer_destroy(&pSession->hTimerRoaming);
Jeff Johnson295189b2012-06-20 16:38:30 -070015224#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015225 vos_timer_destroy(&pSession->hTimerJoinRetry);
Jeff Johnson295189b2012-06-20 16:38:30 -070015226#endif
Abhishek Singh7b2d0812016-04-28 11:44:29 +053015227 csrPurgeSmeCmdList(pMac, sessionId, true);
Jeff Johnson295189b2012-06-20 16:38:30 -070015228 csrInitSession(pMac, sessionId);
15229 }
15230}
15231
Abhishek Singh7b2d0812016-04-28 11:44:29 +053015232void csrPurgeSmeCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId,
15233 bool flush_all)
mukul sharmabab477d2015-06-11 17:14:55 +053015234{
15235 purgeSmeSessionCmdList(pMac, sessionId,
Abhishek Singh7b2d0812016-04-28 11:44:29 +053015236 &pMac->sme.smeCmdPendingList,
15237 flush_all);
mukul sharmabab477d2015-06-11 17:14:55 +053015238 if (pMac->fScanOffload)
15239 {
15240 purgeSmeSessionCmdList(pMac, sessionId,
Abhishek Singh7b2d0812016-04-28 11:44:29 +053015241 &pMac->sme.smeScanCmdPendingList,
15242 flush_all);
mukul sharmabab477d2015-06-11 17:14:55 +053015243 }
Abhishek Singh7b2d0812016-04-28 11:44:29 +053015244 purgeCsrSessionCmdList(pMac, sessionId,
15245 flush_all);
mukul sharmabab477d2015-06-11 17:14:55 +053015246}
15247
Jeff Johnson295189b2012-06-20 16:38:30 -070015248eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
mukul sharmabab477d2015-06-11 17:14:55 +053015249 tANI_BOOLEAN fSync, tANI_U8 bPurgeList,
Jeff Johnson295189b2012-06-20 16:38:30 -070015250 csrRoamSessionCloseCallback callback,
15251 void *pContext )
15252{
15253 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070015254 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
15255 {
15256 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
15257 if(fSync)
15258 {
15259 csrCleanupSession(pMac, sessionId);
15260 }
15261 else
mukul sharmabab477d2015-06-11 17:14:55 +053015262 {
Abhishek Singh7b2d0812016-04-28 11:44:29 +053015263 csrPurgeSmeCmdList(pMac, sessionId, bPurgeList);
mukul sharmabab477d2015-06-11 17:14:55 +053015264 /* If bPurgeList is FALSE, it means HDD already free all the
15265 * cmd and later queue few essential cmd. Now sme should process
15266 * the cmd in pending queue order only.Hence we should
15267 * avoid DEL_SELF_STA as high priority cmd.
15268 */
15269 status = csrIssueDelStaForSessionReq( pMac, sessionId, bPurgeList,
Jeff Johnson295189b2012-06-20 16:38:30 -070015270 pSession->selfMacAddr, callback, pContext);
15271 }
15272 }
15273 else
15274 {
15275 status = eHAL_STATUS_INVALID_PARAMETER;
15276 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015277 return ( status );
15278}
15279
Jeff Johnson295189b2012-06-20 16:38:30 -070015280static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
15281{
15282 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070015283
15284 if(!pSession)
15285 {
15286 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
15287 return;
15288 }
15289
Jeff Johnson295189b2012-06-20 16:38:30 -070015290 pSession->sessionActive = eANI_BOOLEAN_FALSE;
15291 pSession->sessionId = CSR_SESSION_ID_INVALID;
15292 pSession->callback = NULL;
15293 pSession->pContext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015294 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
15295 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
15296 csrFreeRoamProfile( pMac, sessionId );
15297 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
15298 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
15299 csrFreeConnectBssDesc(pMac, sessionId);
15300 csrScanEnable(pMac);
Kiet Lam64c1b492013-07-12 13:56:44 +053015301 vos_mem_set(&pSession->selfMacAddr, sizeof(tCsrBssid), 0);
15302 if (pSession->pWpaRsnReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070015303 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015304 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070015305 pSession->pWpaRsnReqIE = NULL;
15306 }
15307 pSession->nWpaRsnReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053015308 if (pSession->pWpaRsnRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070015309 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015310 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070015311 pSession->pWpaRsnRspIE = NULL;
15312 }
15313 pSession->nWpaRsnRspIeLength = 0;
15314#ifdef FEATURE_WLAN_WAPI
Kiet Lam64c1b492013-07-12 13:56:44 +053015315 if (pSession->pWapiReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070015316 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015317 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070015318 pSession->pWapiReqIE = NULL;
15319 }
15320 pSession->nWapiReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053015321 if (pSession->pWapiRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070015322 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015323 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070015324 pSession->pWapiRspIE = NULL;
15325 }
15326 pSession->nWapiRspIeLength = 0;
15327#endif /* FEATURE_WLAN_WAPI */
Agarwal Ashish4f616132013-12-30 23:32:50 +053015328 if (pSession->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070015329 {
Ganesh Kondabattini7500fb32015-04-10 14:50:32 +053015330 memset(pSession->addIEScan, 0 , SIR_MAC_MAX_ADD_IE_LENGTH);
Jeff Johnson295189b2012-06-20 16:38:30 -070015331 }
15332 pSession->nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053015333
Kiet Lam64c1b492013-07-12 13:56:44 +053015334 if (pSession->pAddIEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070015335 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015336 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070015337 pSession->pAddIEAssoc = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053015338 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015339 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015340}
15341
Jeff Johnson295189b2012-06-20 16:38:30 -070015342eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
15343{
15344 eHalStatus status = eHAL_STATUS_FAILURE;
15345 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070015346 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
15347 {
15348 if( CSR_IS_SESSION_VALID( pMac, i ) )
15349 {
15350 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
15351 {
15352 //Found it
15353 status = eHAL_STATUS_SUCCESS;
15354 *pSessionId = i;
15355 break;
15356 }
15357 }
15358 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015359 return( status );
15360}
15361
Jeff Johnson295189b2012-06-20 16:38:30 -070015362//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
15363//session because for IBSS, the bssid changes.
15364static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
15365{
15366 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
15367 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070015368 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
15369 {
15370 if( CSR_IS_SESSION_VALID( pMac, i ) )
15371 {
15372 pSession = CSR_GET_SESSION( pMac, i );
15373 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
15374 {
15375 //Found it
15376 nRet = i;
15377 break;
15378 }
15379 }
15380 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015381 return (nRet);
15382}
Jeff Johnson295189b2012-06-20 16:38:30 -070015383static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
15384{
Mukul Sharma20aa6582014-08-07 21:36:12 +053015385 VOS_STATUS status = VOS_STATUS_SUCCESS;
15386
15387 /* Update the current BSS info in ho control block based on connected
Jeff Johnson295189b2012-06-20 16:38:30 -070015388 profile info from pmac global structure */
15389
Arif Hussain24bafea2013-11-15 15:10:03 -080015390 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= "MAC_ADDRESS_STR,
15391 MAC_ADDR_ARRAY(bssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070015392 /* Check for user misconfig of RSSI trigger threshold */
15393 pMac->roam.configParam.vccRssiThreshold =
15394 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
15395 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
15396 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070015397 /* Check for user misconfig of UL MAC Loss trigger threshold */
15398 pMac->roam.configParam.vccUlMacLossThreshold =
15399 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
15400 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070015401#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
15402 {
15403 tANI_U32 sessionId = 0;
Mukul Sharmac353a5b2015-01-16 20:49:12 +053015404 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070015405 /* Indicate the neighbor roal algorithm about the connect indication */
15406 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
15407 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
Mukul Sharma20aa6582014-08-07 21:36:12 +053015408
Mukul Sharmac353a5b2015-01-16 20:49:12 +053015409 /* Making sure we are roaming force fully to 5GHz AP only once and
15410 * only when we connected to 2.4GH AP only during initial association.
15411 */
15412 if(pNeighborRoamInfo->cfgParams.neighborInitialForcedRoamTo5GhEnable &&
15413 (GetRFBand(pNeighborRoamInfo->currAPoperationChannel) ==
15414 SIR_BAND_2_4_GHZ)
15415 )
Mukul Sharma20aa6582014-08-07 21:36:12 +053015416 {
Mukul Sharmac353a5b2015-01-16 20:49:12 +053015417 status = vos_timer_start(
15418 &pNeighborRoamInfo->forcedInitialRoamTo5GHTimer,
15419 INITIAL_FORCED_ROAM_TO_5G_TIMER_PERIOD);
Mukul Sharma20aa6582014-08-07 21:36:12 +053015420 if ( status != VOS_STATUS_SUCCESS )
15421 {
Mukul Sharmac353a5b2015-01-16 20:49:12 +053015422 smsLog(pMac, LOGE,
15423 FL("forcedInitialRoamTo5GHTimer start failed status %d"),
15424 status);
15425 //Send RSO start because in case 5G roaming
15426 //host have not enabled at initial connection
15427 csrRoamOffloadScan(pMac,ROAM_SCAN_OFFLOAD_START,REASON_CONNECT);
Mukul Sharma20aa6582014-08-07 21:36:12 +053015428 }
Mukul Sharmac353a5b2015-01-16 20:49:12 +053015429 else
15430 {
15431 smsLog(pMac, LOG1, FL("%s: Forced roam to 5G started Timer"),
15432 __func__);
15433 }
15434 }
15435 /*
15436 * Making ini value to false here only so we just roam to
15437 * only once for whole driver load to unload tenure
15438 * This feature is only applicable for first connection only
15439 */
15440 if(pNeighborRoamInfo->cfgParams.neighborInitialForcedRoamTo5GhEnable)
15441 {
15442 pNeighborRoamInfo->cfgParams.neighborInitialForcedRoamTo5GhEnable
15443 = VOS_FALSE;
Mukul Sharma20aa6582014-08-07 21:36:12 +053015444 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015445 }
15446#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070015447}
15448
Jeff Johnson295189b2012-06-20 16:38:30 -070015449static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
15450{
15451 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070015452
15453 if(!pSession)
15454 {
15455 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
15456 return;
15457 }
15458
Jeff Johnson295189b2012-06-20 16:38:30 -070015459 //Only to handle the case for Handover on infra link
15460 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
15461 {
15462 return;
15463 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015464 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
15465 csrRoamDeregStatisticsReq(pMac);
15466 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
15467#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
15468 /* Indicate the neighbor roal algorithm about the disconnect indication */
15469 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
15470#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070015471
15472 //Remove this code once SLM_Sessionization is supported
15473 //BMPS_WORKAROUND_NOT_NEEDED
15474 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070015475 csrIsInfraApStarted( pMac ) &&
15476 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070015477 {
15478 pMac->roam.configParam.doBMPSWorkaround = 0;
15479 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015480}
15481
Jeff Johnson295189b2012-06-20 16:38:30 -070015482void csrRoamTlStatsTimerHandler(void *pv)
15483{
15484 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
15485 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070015486 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
15487
Jeff Johnsone7245742012-09-05 17:12:55 -070015488 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
15489
Jeff Johnson295189b2012-06-20 16:38:30 -070015490#if 0
15491 // TODO Persession .???
15492 //req TL for stats
15493 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
15494 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015495 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015496 }
15497 else
15498 {
15499 //save in SME
15500 csrRoamSaveStatsFromTl(pMac, tlStats);
15501 }
15502#endif
15503 if(!pMac->roam.tlStatsReqInfo.timerRunning)
15504 {
15505 if(pMac->roam.tlStatsReqInfo.periodicity)
15506 {
15507 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015508 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
15509 pMac->roam.tlStatsReqInfo.periodicity);
15510 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015511 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015512 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015513 return;
15514 }
15515 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
15516 }
15517 }
15518}
Jeff Johnson295189b2012-06-20 16:38:30 -070015519void csrRoamPeStatsTimerHandler(void *pv)
15520{
15521 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
15522 eHalStatus status;
15523 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
15524 VOS_STATUS vosStatus;
15525 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070015526 pPeStatsReqListEntry->timerRunning = FALSE;
15527 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
15528 {
15529 // If we entered here, meaning the timer could not be successfully
15530 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
15531
15532 /* Destroy the timer */
15533 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
15534 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15535 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015536 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015537 }
15538
15539 // Free the entry
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015540 vos_mem_free(pPeStatsReqListEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070015541 pPeStatsReqListEntry = NULL;
15542 }
15543 else
15544 {
15545 if(!pPeStatsReqListEntry->rspPending)
15546 {
15547 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
15548 pPeStatsReqListEntry->staId);
15549 if(!HAL_STATUS_SUCCESS(status))
15550 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015551 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015552 }
15553 else
15554 {
15555 pPeStatsReqListEntry->rspPending = TRUE;
15556 }
15557 }
15558
15559 //send down a req
15560 if(pPeStatsReqListEntry->periodicity &&
15561 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
15562 {
15563 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
15564 if(ePMC_FULL_POWER == powerState)
15565 {
15566 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
15567 {
15568 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
15569 }
15570 }
15571 else
15572 {
15573 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
15574 {
15575 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
15576 }
15577 }
15578 //start timer
15579 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
15580 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15581 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015582 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015583 return;
15584 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015585 pPeStatsReqListEntry->timerRunning = TRUE;
15586
15587 }
15588
15589 }
15590}
Jeff Johnson295189b2012-06-20 16:38:30 -070015591void csrRoamStatsClientTimerHandler(void *pv)
15592{
15593 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070015594 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
15595 {
15596#if 0
15597 // TODO Stats fix for multisession
15598 //start the timer
15599 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
15600
15601 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15602 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015603 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015604 }
15605#endif
15606 }
15607#if 0
15608 //send up the stats report
15609 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
15610 pStaEntry->staId, pStaEntry->pContext);
15611#endif
15612}
15613
15614
15615
Jeff Johnson295189b2012-06-20 16:38:30 -070015616eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
15617{
15618 tAniGetPEStatsReq *pMsg;
15619 eHalStatus status = eHAL_STATUS_SUCCESS;
Hanumantha Reddy Pothulab2a0c832015-11-06 19:44:55 +053015620 tSirMsgQ msgQ;
15621
Kiet Lam64c1b492013-07-12 13:56:44 +053015622 pMsg = vos_mem_malloc(sizeof(tAniGetPEStatsReq));
15623 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070015624 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015625 smsLog(pMac, LOGE, FL( "Failed to allocate mem for stats req "));
Kiet Lam64c1b492013-07-12 13:56:44 +053015626 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015627 }
15628 // need to initiate a stats request to PE
Hanumantha Reddy Pothulab2a0c832015-11-06 19:44:55 +053015629 pMsg->msgType = pal_cpu_to_be16((tANI_U16)WDA_GET_STATISTICS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070015630 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
15631 pMsg->staId = staId;
15632 pMsg->statsMask = statsMask;
Hanumantha Reddy Pothulab2a0c832015-11-06 19:44:55 +053015633
15634 msgQ.type = WDA_GET_STATISTICS_REQ;
15635 msgQ.reserved = 0;
15636 msgQ.bodyptr = pMsg;
15637 msgQ.bodyval = 0;
15638 status = wdaPostCtrlMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070015639 if(!HAL_STATUS_SUCCESS(status))
15640 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015641 smsLog(pMac, LOG1, FL("Failed to send down the stats req "));
Hanumantha Reddy Pothulab2a0c832015-11-06 19:44:55 +053015642 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015643 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015644 return status;
15645}
Jeff Johnson295189b2012-06-20 16:38:30 -070015646void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
15647{
15648 tAniGetPEStatsRsp *pSmeStatsRsp;
15649 eHalStatus status = eHAL_STATUS_FAILURE;
15650 tListElem *pEntry = NULL;
15651 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
15652 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
15653 tANI_U32 tempMask = 0;
15654 tANI_U8 counter = 0;
15655 tANI_U8 *pStats = NULL;
15656 tANI_U32 length = 0;
15657 v_PVOID_t pvosGCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015658 v_S7_t rssi = 0, snr = 0;
15659 tANI_U32 *pRssi = NULL, *pSnr = NULL;
Sushant Kaushik33200572015-08-05 16:46:20 +053015660 tAniPerTxPktStatsInfo * txPacketInfo;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015661 tANI_U32 linkCapacity;
Jeff Johnson295189b2012-06-20 16:38:30 -070015662 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
15663 if(pSmeStatsRsp->rc)
15664 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015665 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015666 goto post_update;
15667 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015668 tempMask = pSmeStatsRsp->statsMask;
15669 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070015670 /* subtract all statistics from this length, and after processing the entire
15671 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
15672 * in this 'stats' message.
15673 */
15674 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070015675 //new stats info from PE, fill up the stats strucutres in PMAC
15676 while(tempMask)
15677 {
15678 if(tempMask & 1)
15679 {
15680 switch(counter)
15681 {
15682 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015683 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015684 vos_mem_copy((tANI_U8 *)&pMac->roam.summaryStatsInfo,
15685 pStats, sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015686 pStats += sizeof(tCsrSummaryStatsInfo);
15687 length -= sizeof(tCsrSummaryStatsInfo);
15688 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015689 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015690 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015691 vos_mem_copy((tANI_U8 *)&pMac->roam.classAStatsInfo,
15692 pStats, sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015693 pStats += sizeof(tCsrGlobalClassAStatsInfo);
15694 length -= sizeof(tCsrGlobalClassAStatsInfo);
15695 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015696 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015697 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015698 vos_mem_copy((tANI_U8 *)&pMac->roam.classBStatsInfo,
15699 pStats, sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015700 pStats += sizeof(tCsrGlobalClassBStatsInfo);
15701 length -= sizeof(tCsrGlobalClassBStatsInfo);
15702 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015703 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015704 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015705 vos_mem_copy((tANI_U8 *)&pMac->roam.classCStatsInfo,
15706 pStats, sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015707 pStats += sizeof(tCsrGlobalClassCStatsInfo);
15708 length -= sizeof(tCsrGlobalClassCStatsInfo);
15709 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015710 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015711 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015712 if( CSR_MAX_STA > pSmeStatsRsp->staId )
15713 {
Padma, Santhosh Kumar8ac7a5d2015-11-13 16:58:32 +053015714 status = eHAL_STATUS_SUCCESS;
Kiet Lam64c1b492013-07-12 13:56:44 +053015715 vos_mem_copy((tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
15716 pStats, sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015717 }
15718 else
15719 {
15720 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015721 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070015722 VOS_ASSERT( 0 );
15723 }
15724 if(!HAL_STATUS_SUCCESS(status))
15725 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015726 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015727 }
15728 pStats += sizeof(tCsrPerStaStatsInfo);
15729 length -= sizeof(tCsrPerStaStatsInfo);
15730 break;
Sushant Kaushik33200572015-08-05 16:46:20 +053015731 case eCsrPerPktStats:
15732 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerPkt stats"));
15733 vos_mem_zero(&pMac->roam.perPktStatsInfo, sizeof(tPerTxPacketFrmFw));
15734 if (IS_FEATURE_SUPPORTED_BY_FW(PER_PKT_STATS_SUPPORTED))
15735 {
15736 txPacketInfo = (tAniPerTxPktStatsInfo *)pStats;
15737 pMac->roam.perPktStatsInfo.lastTxRate = txPacketInfo->lastTxRate;
15738 pMac->roam.perPktStatsInfo.txAvgRetry = txPacketInfo->txAvgRetry;
Sushant Kaushikf35bc222015-10-09 16:50:12 +053015739 /* for reserved bytes */
15740 pStats += (sizeof(tAniPerTxPktStatsInfo) + 2*sizeof(tANI_U32));
15741 length -= (sizeof(tAniPerTxPktStatsInfo) + 2*sizeof(tANI_U32));
Sushant Kaushik33200572015-08-05 16:46:20 +053015742 }
15743 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015744 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015745 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015746 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015747 }
15748 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015749 tempMask >>=1;
15750 counter++;
15751 }
15752 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
15753 if (length != 0)
15754 {
15755 pRssi = (tANI_U32*)pStats;
15756 rssi = (v_S7_t)*pRssi;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015757 pStats += sizeof(tANI_U32);
15758 length -= sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070015759 }
15760 else
15761 {
15762 /* If riva is not sending rssi, continue to use the hack */
15763 rssi = RSSI_HACK_BMPS;
15764 }
Sushant Kaushikec2d1c42015-10-05 12:12:33 +053015765 /* send positive value of rssi to wifi_hal */
15766 pMac->roam.perPktStatsInfo.avgRssi = (-1)*rssi;
Sushant Kaushik33200572015-08-05 16:46:20 +053015767 vos_updatePktStatsInfo(&pMac->roam.perPktStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070015768 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015769
15770 if (length != 0)
15771 {
15772 linkCapacity = *(tANI_U32*)pStats;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015773 pStats += sizeof(tANI_U32);
15774 length -= sizeof(tANI_U32);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015775 }
15776 else
15777 {
15778 linkCapacity = 0;
15779 }
15780
15781 WDA_UpdateLinkCapacity(pvosGCtx, pSmeStatsRsp->staId, linkCapacity);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015782
15783 if (length != 0)
15784 {
15785 pSnr = (tANI_U32*)pStats;
15786 snr = (v_S7_t)*pSnr;
15787 }
15788 else
15789 {
15790 snr = SNR_HACK_BMPS;
15791 }
15792
15793 WDA_UpdateSnrBmps(pvosGCtx, pSmeStatsRsp->staId, snr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015794post_update:
15795 //make sure to update the pe stats req list
15796 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
15797 if(pEntry)
15798 {
15799 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
15800 pPeStaEntry->rspPending = FALSE;
15801
15802 }
15803 //check the one timer cases
15804 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
15805 if(pEntry)
15806 {
Jeff Johnson295189b2012-06-20 16:38:30 -070015807 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015808 if(pTempStaEntry->timerExpired)
15809 {
15810 //send up the stats report
15811 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
15812 pTempStaEntry->staId, pTempStaEntry->pContext);
15813 //also remove from the client list
15814 csrRoamRemoveStatListEntry(pMac, pEntry);
15815 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015816 }
15817 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015818}
Jeff Johnson295189b2012-06-20 16:38:30 -070015819tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
15820{
15821 tListElem *pEntry = NULL;
15822 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015823 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015824 if(!pEntry)
15825 {
15826 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015827 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070015828 return NULL;
15829 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015830 while( pEntry )
15831 {
15832 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015833 if(pTempStaEntry->statsMask == statsMask)
15834 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015835 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015836 break;
15837 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015838 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
15839 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015840 return pEntry;
15841}
15842
Jeff Johnson295189b2012-06-20 16:38:30 -070015843tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
15844 tANI_BOOLEAN update)
15845{
15846 tListElem *pEntry;
15847 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070015848 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015849 if(!pEntry)
15850 {
15851 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070015852 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015853 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070015854 return NULL;
15855 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015856 while( pEntry )
15857 {
15858 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015859 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
15860 (pTempStaEntry->statsMask == pStaEntry->statsMask))
15861 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015862 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015863 if(update)
15864 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015865 pTempStaEntry->periodicity = pStaEntry->periodicity;
15866 pTempStaEntry->callback = pStaEntry->callback;
15867 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070015868 }
15869 break;
15870 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015871 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
15872 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015873 return pEntry;
15874}
Jeff Johnson295189b2012-06-20 16:38:30 -070015875tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
15876{
15877 tListElem *pEntry;
15878 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070015879 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015880 if(!pEntry)
15881 {
15882 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070015883 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015884 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070015885 return NULL;
15886 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015887 while( pEntry )
15888 {
15889 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015890 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
15891 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015892 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015893 break;
15894 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015895 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
15896 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015897 return pEntry;
15898}
Jeff Johnson295189b2012-06-20 16:38:30 -070015899eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
15900 csrRoamLinkQualityIndCallback callback,
15901 void *pContext)
15902{
15903 pMac->roam.linkQualityIndInfo.callback = callback;
15904 pMac->roam.linkQualityIndInfo.context = pContext;
15905 if( NULL == callback )
15906 {
15907 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
15908 }
15909 else
15910 {
15911 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070015912 /* do we need to invoke the callback to notify client of initial value ?? */
15913 }
15914 return eHAL_STATUS_SUCCESS;
15915}
Jeff Johnson295189b2012-06-20 16:38:30 -070015916void csrRoamVccTrigger(tpAniSirGlobal pMac)
15917{
15918 eCsrRoamLinkQualityInd newVccLinkQuality;
15919 tANI_U32 ul_mac_loss = 0;
15920 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070015921 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
15922 /*-------------------------------------------------------------------------
15923 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070015924 Check for a change in link quality and notify client if necessary
15925 -------------------------------------------------------------------------*/
15926 ul_mac_loss_trigger_threshold =
15927 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070015928 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015929 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015930 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070015931 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
15932 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015933 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070015934 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
15935 }
15936 else
15937 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015938 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070015939 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
15940 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015941 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
15942 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070015943 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
15944 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015945 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070015946 if(NULL != pMac->roam.linkQualityIndInfo.callback)
15947 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015948 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015949 newVccLinkQuality );
15950
15951 /* we now invoke the callback once to notify client of initial value */
15952 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
15953 pMac->roam.linkQualityIndInfo.context );
15954 //event: EVENT_WLAN_VCC
15955 }
15956 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015957 pMac->roam.vccLinkQuality = newVccLinkQuality;
15958
Jeff Johnson295189b2012-06-20 16:38:30 -070015959}
Jeff Johnson295189b2012-06-20 16:38:30 -070015960VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
15961 v_U8_t rssiNotification,
15962 void * context)
15963{
15964 tpAniSirGlobal pMac = PMAC_STRUCT( context );
15965 eCsrRoamLinkQualityInd newVccLinkQuality;
15966 // TODO : Session info unavailable
15967 tANI_U32 sessionId = 0;
15968 VOS_STATUS status = VOS_STATUS_SUCCESS;
15969 /*-------------------------------------------------------------------------
15970 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070015971 Check for a change in link quality and notify client if necessary
15972 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015973 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015974 pMac->roam.configParam.vccRssiThreshold);
15975 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
15976 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015977 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070015978 return VOS_STATUS_SUCCESS;
15979 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015980 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
15981 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015982 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070015983 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
15984 }
15985 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
15986 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015987 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070015988 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
15989 }
15990 else
15991 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015992 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070015993 //Set to this so the code below won't do anything
15994 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070015995 VOS_ASSERT(0);
15996 }
15997
Jeff Johnson295189b2012-06-20 16:38:30 -070015998 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
15999 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016000 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070016001 if(NULL != pMac->roam.linkQualityIndInfo.callback)
16002 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016003 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070016004 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070016005 /* we now invoke the callback once to notify client of initial value */
16006 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
16007 pMac->roam.linkQualityIndInfo.context );
16008 //event: EVENT_WLAN_VCC
16009 }
16010 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016011 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070016012 return status;
16013}
Jeff Johnson295189b2012-06-20 16:38:30 -070016014tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
16015 tDblLinkList *pStaList,
16016 tCsrStatsClientReqInfo *pStaEntry)
16017{
16018 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016019 //if same entity requested for same set of stats with different periodicity &
16020 // callback update it
16021 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
16022 {
16023
Kiet Lam64c1b492013-07-12 13:56:44 +053016024 pNewStaEntry = vos_mem_malloc(sizeof(tCsrStatsClientReqInfo));
16025 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070016026 {
16027 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016028 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070016029 return NULL;
16030 }
16031
Jeff Johnson295189b2012-06-20 16:38:30 -070016032 pNewStaEntry->callback = pStaEntry->callback;
16033 pNewStaEntry->pContext = pStaEntry->pContext;
16034 pNewStaEntry->periodicity = pStaEntry->periodicity;
16035 pNewStaEntry->requesterId = pStaEntry->requesterId;
16036 pNewStaEntry->statsMask = pStaEntry->statsMask;
16037 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
16038 pNewStaEntry->pMac = pStaEntry->pMac;
16039 pNewStaEntry->staId = pStaEntry->staId;
16040 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
16041
16042 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
16043 }
16044 return pNewStaEntry;
16045}
16046
Jeff Johnson295189b2012-06-20 16:38:30 -070016047tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
16048 tDblLinkList *pStaList,
16049 tCsrPeStatsReqInfo *pStaEntry)
16050{
16051 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053016052 pNewStaEntry = vos_mem_malloc(sizeof(tCsrPeStatsReqInfo));
16053 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070016054 {
16055 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016056 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070016057 return NULL;
16058 }
16059
Jeff Johnson295189b2012-06-20 16:38:30 -070016060 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
16061 pNewStaEntry->numClient = pStaEntry->numClient;
16062 pNewStaEntry->periodicity = pStaEntry->periodicity;
16063 pNewStaEntry->statsMask = pStaEntry->statsMask;
16064 pNewStaEntry->pMac = pStaEntry->pMac;
16065 pNewStaEntry->staId = pStaEntry->staId;
16066 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
16067 pNewStaEntry->rspPending = pStaEntry->rspPending;
16068
16069 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016070 return pNewStaEntry;
16071}
Jeff Johnson295189b2012-06-20 16:38:30 -070016072eHalStatus csrGetRssi(tpAniSirGlobal pMac,
16073 tCsrRssiCallback callback,
16074 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
16075{
16076 eHalStatus status = eHAL_STATUS_SUCCESS;
16077 vos_msg_t msg;
16078 tANI_U32 sessionId;
16079
16080 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016081 smsLog(pMac, LOG2, FL("called"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016082 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
16083 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070016084 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016085 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053016086 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070016087 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016088 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
16089
16090 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
16091 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
16092 pMsg->sessionId = sessionId;
16093 pMsg->staId = staId;
16094 pMsg->rssiCallback = callback;
16095 pMsg->pDevContext = pContext;
16096 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070016097 msg.type = eWNI_SME_GET_RSSI_REQ;
16098 msg.bodyptr = pMsg;
16099 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016100 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
16101 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016102 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053016103 vos_mem_free((void *)pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016104 status = eHAL_STATUS_FAILURE;
16105 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016106 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016107 return status;
16108}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080016109
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053016110eHalStatus csrGetSnr(tpAniSirGlobal pMac,
16111 tCsrSnrCallback callback,
16112 tANI_U8 staId, tCsrBssid bssId,
16113 void *pContext)
16114{
16115 eHalStatus status = eHAL_STATUS_SUCCESS;
16116 vos_msg_t msg;
16117 tANI_U32 sessionId;
16118
16119 tAniGetSnrReq *pMsg;
16120
16121 smsLog(pMac, LOG2, FL("called"));
16122
16123 pMsg =(tAniGetSnrReq *)vos_mem_malloc(sizeof(tAniGetSnrReq));
16124 if (NULL == pMsg )
16125 {
16126 smsLog(pMac, LOGE, "%s: failed to allocate mem for req",__func__);
16127 return status;
16128 }
16129
16130 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
16131
16132 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_SNR_REQ);
16133 pMsg->msgLen = (tANI_U16)sizeof(tAniGetSnrReq);
16134 pMsg->sessionId = sessionId;
16135 pMsg->staId = staId;
16136 pMsg->snrCallback = callback;
16137 pMsg->pDevContext = pContext;
16138 msg.type = eWNI_SME_GET_SNR_REQ;
16139 msg.bodyptr = pMsg;
16140 msg.reserved = 0;
16141
16142 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
16143 {
16144 smsLog(pMac, LOGE, "%s failed to post msg to self", __func__);
16145 vos_mem_free((v_VOID_t *)pMsg);
16146 status = eHAL_STATUS_FAILURE;
16147 }
16148
16149 smsLog(pMac, LOG2, FL("returned"));
16150 return status;
16151}
16152
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016153#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080016154eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
16155 tCsrRssiCallback callback,
16156 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
16157{
16158 eHalStatus status = eHAL_STATUS_SUCCESS;
16159 tAniGetRssiReq *pMsg;
16160
Kiet Lam64c1b492013-07-12 13:56:44 +053016161 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
16162 if ( NULL == pMsg )
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080016163 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016164 smsLog(pMac, LOGE, FL("Failed to allocate mem for req"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016165 return eHAL_STATUS_FAILURE;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080016166 }
16167 // need to initiate a stats request to PE
16168 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
16169 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
16170 pMsg->staId = staId;
16171 pMsg->rssiCallback = callback;
16172 pMsg->pDevContext = pContext;
16173 pMsg->pVosContext = pVosContext;
16174 status = palSendMBMessage(pMac->hHdd, pMsg );
16175 if(!HAL_STATUS_SUCCESS(status))
16176 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016177 smsLog(pMac, LOGE, FL(" Failed to send down get rssi req"));
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070016178 //pMsg is freed by palSendMBMessage
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080016179 status = eHAL_STATUS_FAILURE;
16180 }
16181 return status;
16182}
16183#endif
16184
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070016185
16186
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016187#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070016188eHalStatus csrGetTsmStats(tpAniSirGlobal pMac,
16189 tCsrTsmStatsCallback callback,
16190 tANI_U8 staId,
16191 tCsrBssid bssId,
16192 void *pContext,
16193 void* pVosContext,
16194 tANI_U8 tid)
16195{
16196 eHalStatus status = eHAL_STATUS_SUCCESS;
16197 tAniGetTsmStatsReq *pMsg = NULL;
16198
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080016199 pMsg = (tAniGetTsmStatsReq*)vos_mem_malloc(sizeof(tAniGetTsmStatsReq));
16200 if (NULL == pMsg)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070016201 {
16202 smsLog(pMac, LOGE, "csrGetTsmStats: failed to allocate mem for req");
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080016203 return eHAL_STATUS_FAILED_ALLOC;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070016204 }
16205 // need to initiate a stats request to PE
16206 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_TSM_STATS_REQ);
16207 pMsg->msgLen = (tANI_U16)sizeof(tAniGetTsmStatsReq);
16208 pMsg->staId = staId;
16209 pMsg->tid = tid;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080016210 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070016211 pMsg->tsmStatsCallback = callback;
16212 pMsg->pDevContext = pContext;
16213 pMsg->pVosContext = pVosContext;
16214 status = palSendMBMessage(pMac->hHdd, pMsg );
16215 if(!HAL_STATUS_SUCCESS(status))
16216 {
16217 smsLog(pMac, LOG1, " csrGetTsmStats: failed to send down the rssi req");
16218 //pMsg is freed by palSendMBMessage
16219 status = eHAL_STATUS_FAILURE;
16220 }
16221 return status;
16222}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016223#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070016224
16225
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053016226/* ---------------------------------------------------------------------------
16227 \fn csrGetTLSTAState
16228 \helper function to get teh TL STA State whenever the function is called.
16229
16230 \param staId - The staID to be passed to the TL
16231 to get the relevant TL STA State
16232 \return the state as tANI_U16
16233 ---------------------------------------------------------------------------*/
16234tANI_U16 csrGetTLSTAState(tpAniSirGlobal pMac, tANI_U8 staId)
16235{
16236 WLANTL_STAStateType tlSTAState;
16237 tlSTAState = WLANTL_STA_INIT;
16238
16239 //request TL for STA State
16240 if ( !VOS_IS_STATUS_SUCCESS(WLANTL_GetSTAState(pMac->roam.gVosContext, staId, &tlSTAState)) )
16241 {
16242 smsLog(pMac, LOGE, FL("csrGetTLSTAState:couldn't get the STA state from TL"));
16243 }
16244
16245 return tlSTAState;
16246}
16247
Jeff Johnson295189b2012-06-20 16:38:30 -070016248eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
16249 tANI_U32 statsMask,
16250 tCsrStatsCallback callback,
16251 tANI_U32 periodicity, tANI_BOOLEAN cache,
16252 tANI_U8 staId, void *pContext)
16253{
16254 tCsrStatsClientReqInfo staEntry;
16255 tCsrStatsClientReqInfo *pStaEntry = NULL;
16256 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
16257 tListElem *pEntry = NULL;
16258 tANI_BOOLEAN found = FALSE;
16259 eHalStatus status = eHAL_STATUS_SUCCESS;
16260 tANI_BOOLEAN insertInClientList = FALSE;
16261 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070016262 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070016263
16264 if( csrIsAllSessionDisconnected(pMac) )
16265 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016266 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070016267 return eHAL_STATUS_FAILURE;
16268 }
Hanumantha Reddy Pothula449aadf2014-02-07 13:53:35 +053016269
16270 if (csrNeighborMiddleOfRoaming((tHalHandle)pMac))
16271 {
16272 smsLog(pMac, LOG1, FL("in the middle of roaming states"));
16273 return eHAL_STATUS_FAILURE;
16274 }
16275
Jeff Johnson295189b2012-06-20 16:38:30 -070016276 if((!statsMask) && (!callback))
16277 {
16278 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016279 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070016280 return eHAL_STATUS_FAILURE;
16281 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016282 //for the search list method for deregister
16283 staEntry.requesterId = requesterId;
16284 staEntry.statsMask = statsMask;
16285 //requester wants to deregister or just an error
16286 if((statsMask) && (!callback))
16287 {
16288 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
16289 if(!pEntry)
16290 {
16291 //msg
16292 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016293 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070016294 return eHAL_STATUS_FAILURE;
16295 }
16296 else
16297 {
16298 //clean up & return
16299 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070016300 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070016301 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016302 pStaEntry->pPeStaEntry->numClient--;
16303 //check if we need to delete the entry from peStatsReqList too
16304 if(!pStaEntry->pPeStaEntry->numClient)
16305 {
16306 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
16307 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016308 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070016309
Jeff Johnson295189b2012-06-20 16:38:30 -070016310 //check if we need to stop the tl stats timer too
16311 pMac->roam.tlStatsReqInfo.numClient--;
16312 if(!pMac->roam.tlStatsReqInfo.numClient)
16313 {
16314 if(pMac->roam.tlStatsReqInfo.timerRunning)
16315 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016316 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
16317 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016318 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016319 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016320 return eHAL_STATUS_FAILURE;
16321 }
16322 }
16323 pMac->roam.tlStatsReqInfo.periodicity = 0;
16324 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
16325 }
Padma, Santhosh Kumar8ac7a5d2015-11-13 16:58:32 +053016326 if (periodicity)
Jeff Johnson295189b2012-06-20 16:38:30 -070016327 {
Padma, Santhosh Kumar8ac7a5d2015-11-13 16:58:32 +053016328 vos_timer_stop(&pStaEntry->timer);
16329 // Destroy the vos timer
16330 vosStatus = vos_timer_destroy(&pStaEntry->timer);
16331 if (!VOS_IS_STATUS_SUCCESS(vosStatus))
16332 {
16333 smsLog(pMac, LOGE, FL("Failed to destroy Client req timer"));
16334 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016335 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016336 csrRoamRemoveStatListEntry(pMac, pEntry);
16337 pStaEntry = NULL;
16338 return eHAL_STATUS_SUCCESS;
16339 }
16340 }
16341
16342 if(cache && !periodicity)
16343 {
16344 //return the cached stats
16345 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
16346 }
16347 else
16348 {
16349 //add the request in the client req list
16350 staEntry.callback = callback;
16351 staEntry.pContext = pContext;
16352 staEntry.periodicity = periodicity;
16353 staEntry.pPeStaEntry = NULL;
16354 staEntry.staId = staId;
16355 staEntry.pMac = pMac;
16356 staEntry.timerExpired = FALSE;
16357
16358
Jeff Johnson295189b2012-06-20 16:38:30 -070016359 //if periodic report requested with non cached result from PE/TL
16360 if(periodicity)
16361 {
16362
16363 //if looking for stats from PE
16364 if(statsMask & ~(1 << eCsrGlobalClassDStats))
16365 {
16366
16367 //check if same request made already & waiting for rsp
16368 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
16369 periodicity, &found, staId);
16370 if(!pPeStaEntry)
16371 {
16372 //bail out, maxed out on number of req for PE
16373 return eHAL_STATUS_FAILURE;
16374 }
16375 else
16376 {
16377 staEntry.pPeStaEntry = pPeStaEntry;
16378 }
16379
16380 }
16381 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
16382 if(statsMask & (1 << eCsrGlobalClassDStats))
16383 {
16384 if(cache && pMac->roam.tlStatsReqInfo.numClient)
16385 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016386 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016387 }
16388 else
16389 {
16390
16391 //update periodicity
16392 if(pMac->roam.tlStatsReqInfo.periodicity)
16393 {
16394 pMac->roam.tlStatsReqInfo.periodicity =
16395 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
16396 }
16397 else
16398 {
16399 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
16400 }
16401 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
16402 {
16403 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
16404 }
16405
16406 if(!pMac->roam.tlStatsReqInfo.timerRunning)
16407 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016408 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053016409 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070016410 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016411 //req TL for class D stats
16412 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
16413 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016414 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070016415 }
16416 else
16417 {
16418 //save in SME
16419 csrRoamSaveStatsFromTl(pMac, pTlStats);
16420 }
16421 vos_mem_free(pTlStats);
16422 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016423 }
16424 else
16425 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016426 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016427 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016428
Jeff Johnson295189b2012-06-20 16:38:30 -070016429 if(pMac->roam.tlStatsReqInfo.periodicity)
16430 {
16431 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016432 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
16433 pMac->roam.tlStatsReqInfo.periodicity);
16434 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016435 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016436 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016437 return eHAL_STATUS_FAILURE;
16438 }
16439 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
16440 }
16441 }
16442 }
16443 pMac->roam.tlStatsReqInfo.numClient++;
16444 }
16445
16446 insertInClientList = TRUE;
16447 }
16448 //if one time report requested with non cached result from PE/TL
16449 else if(!cache && !periodicity)
16450 {
16451 if(statsMask & ~(1 << eCsrGlobalClassDStats))
16452 {
16453 //send down a req
16454 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
16455 if(!HAL_STATUS_SUCCESS(status))
16456 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016457 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016458 }
16459 //so that when the stats rsp comes back from PE we respond to upper layer
16460 //right away
16461 staEntry.timerExpired = TRUE;
16462 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070016463 }
16464 if(statsMask & (1 << eCsrGlobalClassDStats))
16465 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016466 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053016467 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070016468 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016469 //req TL for class D stats
16470 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
16471 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016472 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070016473 }
16474 else
16475 {
16476 //save in SME
16477 csrRoamSaveStatsFromTl(pMac, pTlStats);
16478 }
16479 vos_mem_free(pTlStats);
16480 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016481 }
16482 else
16483 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016484 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016485 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016486
16487 }
16488 //if looking for stats from TL only
16489 if(!insertInClientList)
16490 {
16491 //return the stats
16492 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
16493 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016494 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016495 if(insertInClientList)
16496 {
16497 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
16498 if(!pStaEntry)
16499 {
16500 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016501 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070016502 return eHAL_STATUS_FAILURE;
16503 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016504 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070016505 //Init & start timer if needed
16506 if(periodicity)
16507 {
16508 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
16509 csrRoamStatsClientTimerHandler, pStaEntry );
16510 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16511 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016512 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016513 return eHAL_STATUS_FAILURE;
16514 }
16515 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
16516 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16517 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016518 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016519 return eHAL_STATUS_FAILURE;
16520 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016521 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016522 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016523 }
16524 return eHAL_STATUS_SUCCESS;
16525}
16526
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016527#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
16528
16529static tSirRetStatus
16530csrRoamScanOffloadPopulateMacHeader(tpAniSirGlobal pMac,
16531 tANI_U8* pBD,
16532 tANI_U8 type,
16533 tANI_U8 subType,
16534 tSirMacAddr peerAddr,
16535 tSirMacAddr selfMacAddr)
16536{
16537 tSirRetStatus statusCode = eSIR_SUCCESS;
16538 tpSirMacMgmtHdr pMacHdr;
16539
16540 /* Prepare MAC management header */
16541 pMacHdr = (tpSirMacMgmtHdr) (pBD);
16542
16543 /* Prepare FC */
16544 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
16545 pMacHdr->fc.type = type;
16546 pMacHdr->fc.subType = subType;
16547
16548 /* Prepare Address 1 */
Kiet Lam64c1b492013-07-12 13:56:44 +053016549 vos_mem_copy((tANI_U8 *) pMacHdr->da, (tANI_U8 *) peerAddr,
16550 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016551
16552 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
16553
16554 /* Prepare Address 3 */
Kiet Lam64c1b492013-07-12 13:56:44 +053016555 vos_mem_copy((tANI_U8 *) pMacHdr->bssId, (tANI_U8 *) peerAddr,
16556 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016557 return statusCode;
16558} /*** csrRoamScanOffloadPopulateMacHeader() ***/
16559
16560static tSirRetStatus
16561csrRoamScanOffloadPrepareProbeReqTemplate(tpAniSirGlobal pMac,
16562 tANI_U8 nChannelNum,
16563 tANI_U32 dot11mode,
16564 tSirMacAddr selfMacAddr,
16565 tANI_U8 *pFrame,
16566 tANI_U16 *pusLen)
16567{
16568 tDot11fProbeRequest pr;
16569 tANI_U32 nStatus, nBytes, nPayload;
16570 tSirRetStatus nSirStatus;
16571 /*Bcast tx*/
16572 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
16573 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
16574
16575
Kiet Lam64c1b492013-07-12 13:56:44 +053016576 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016577
16578 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
16579
16580 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
16581 {
16582 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
16583 }
16584
16585
16586 if (IS_DOT11_MODE_HT(dot11mode))
16587 {
16588 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
16589 }
16590
16591
16592 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
16593 if ( DOT11F_FAILED( nStatus ) )
16594 {
16595 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16596 "Failed to calculate the packed size f"
16597 "or a Probe Request (0x%08x).\n", nStatus );
16598
16599
16600 nPayload = sizeof( tDot11fProbeRequest );
16601 }
16602 else if ( DOT11F_WARNED( nStatus ) )
16603 {
16604 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16605 "There were warnings while calculating"
16606 "the packed size for a Probe Request ("
16607 "0x%08x).\n", nStatus );
16608 }
16609
16610 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
16611
16612 /* Prepare outgoing frame*/
Kiet Lam64c1b492013-07-12 13:56:44 +053016613 vos_mem_set(pFrame, nBytes , 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016614
16615
16616 nSirStatus = csrRoamScanOffloadPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016617 SIR_MAC_MGMT_PROBE_REQ, bssId,selfMacAddr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016618
16619 if ( eSIR_SUCCESS != nSirStatus )
16620 {
16621 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16622 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
16623 nSirStatus );
16624 return nSirStatus;
16625 }
16626
16627
16628 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
16629 sizeof( tSirMacMgmtHdr ),
16630 nPayload, &nPayload );
16631 if ( DOT11F_FAILED( nStatus ) )
16632 {
16633 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16634 "Failed to pack a Probe Request (0x%08x).\n", nStatus );
16635 return eSIR_FAILURE;
16636 }
16637 else if ( DOT11F_WARNED( nStatus ) )
16638 {
16639 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce8ad512013-10-30 12:34:42 -070016640 "There were warnings while packing a Probe Request (0x%08x).\n",
16641 nStatus );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016642 }
16643
16644 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
16645 return eSIR_SUCCESS;
16646}
16647
Mukul Sharmad68cda62015-03-20 21:25:41 +053016648/*
16649 * Below Table describe whether RSO command can be send down to fimrware or not.
16650 * Host check it on the basis of previous RSO command sent down to firmware.
16651||===========================================================================||
16652|| New cmd | LAST SENT COMMAND ---> ||
16653||====|======================================================================||
16654|| V | RSO_START | RSO_STOP | RSO_RESTART | RSO_UPDATE_CFG ||
16655|| --------------------------------------------------------------------------||
16656|| RSO_START | NO | YES | NO | NO ||
Kapil Gupta3834c0c2016-09-02 15:40:55 +053016657|| RSO_STOP | YES | NO | YES | YES ||
16658|| RSO_RESTART | YES | NO | YES | YES ||
Mukul Sharmad68cda62015-03-20 21:25:41 +053016659|| RSO_UPDATE_CFG | YES | NO | YES | YES ||
16660||===========================================================================||
16661*/
16662
16663#define RSO_START_BIT (1<<ROAM_SCAN_OFFLOAD_START)
16664#define RSO_STOP_BIT (1<<ROAM_SCAN_OFFLOAD_STOP)
16665#define RSO_RESTART_BIT (1<<ROAM_SCAN_OFFLOAD_RESTART)
16666#define RSO_UPDATE_CFG_BIT (1<<ROAM_SCAN_OFFLOAD_UPDATE_CFG)
16667
16668#define RSO_START_ALLOW_MASK ( RSO_STOP_BIT )
16669#define RSO_STOP_ALLOW_MASK ( RSO_UPDATE_CFG_BIT | RSO_RESTART_BIT | \
Kapil Gupta0c1aea82016-09-01 17:52:25 +053016670 RSO_START_BIT )
Kapil Gupta3834c0c2016-09-02 15:40:55 +053016671#define RSO_RESTART_ALLOW_MASK ( RSO_UPDATE_CFG_BIT | RSO_START_BIT | \
16672 RSO_RESTART_BIT )
Kapil Gupta7c132882016-09-03 16:15:06 +053016673#define RSO_UPDATE_CFG_ALLOW_MASK (RSO_UPDATE_CFG_BIT | RSO_RESTART_BIT | \
Mukul Sharmad68cda62015-03-20 21:25:41 +053016674 RSO_START_BIT)
16675
16676tANI_BOOLEAN CsrIsRSOCommandAllowed(tpAniSirGlobal pMac, tANI_U8 command)
16677{
16678 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
16679 tANI_U8 desiredMask = 0;
16680 switch(command)
16681 {
16682 case ROAM_SCAN_OFFLOAD_START:
16683 desiredMask = RSO_START_ALLOW_MASK;
16684 break;
16685 case ROAM_SCAN_OFFLOAD_STOP:
16686 desiredMask = RSO_STOP_ALLOW_MASK;
16687 break;
16688 case ROAM_SCAN_OFFLOAD_RESTART:
16689 desiredMask = RSO_RESTART_ALLOW_MASK;
16690 break;
16691 case ROAM_SCAN_OFFLOAD_UPDATE_CFG:
16692 desiredMask = RSO_UPDATE_CFG_ALLOW_MASK;
16693 break;
16694 default:
16695 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16696 FL("Wrong RSO command %d, not allowed"), command);
16697 return 0;/*Cmd Not allowed*/
16698 }
16699 return ( desiredMask & ( 1 << pNeighborRoamInfo->lastSentCmd) );
16700}
16701
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016702eHalStatus csrRoamOffloadScan(tpAniSirGlobal pMac, tANI_U8 command, tANI_U8 reason)
16703{
16704 vos_msg_t msg;
Kapil Gupta04ab1992016-06-26 13:36:51 +053016705 vos_msg_t PERroamScanConfigMsg = {0};
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016706 tSirRoamOffloadScanReq *pRequestBuf;
Kapil Gupta04ab1992016-06-26 13:36:51 +053016707 tSirPERRoamOffloadScanReq *PERRoamReqBuf;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016708 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Ratnam Rachurib5cffcd2015-10-13 18:18:21 +053016709 tCsrRoamSession *pSession = NULL;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016710 tANI_U8 i,j,num_channels = 0, ucDot11Mode;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016711 tANI_U8 *ChannelList = NULL;
Padma, Santhosh Kumare5f677e2015-11-27 17:39:31 +053016712 tANI_U32 sessionId = 0;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016713 eHalStatus status = eHAL_STATUS_SUCCESS;
16714 tpCsrChannelInfo currChannelListInfo;
Srinivas Girigowda56076852013-08-20 14:00:50 -070016715 tANI_U32 host_channels = 0;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016716 tANI_U8 ChannelCacheStr[128] = {0};
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016717 eCsrBand eBand;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016718 tSirBssDescription *pBssDesc = NULL;
16719 tDot11fBeaconIEs *pIes = NULL;
16720 tANI_U8 minRate = 0, dataRate;
Varun Reddy Yeturu52231ea2014-02-06 12:00:56 -080016721 tANI_U8 operationChannel = 0;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016722
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016723 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
16724
Srinivas Girigowda830bbd02013-06-13 19:44:16 -070016725 if (0 == csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016726 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016727 smsLog( pMac, LOGE,"isRoamOffloadScanEnabled not set");
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016728 return eHAL_STATUS_FAILURE;
16729 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016730
16731 if ((VOS_TRUE == bRoamScanOffloadStarted) && (ROAM_SCAN_OFFLOAD_START == command))
16732 {
16733 smsLog( pMac, LOGE,"Roam Scan Offload is already started");
16734 return eHAL_STATUS_FAILURE;
16735 }
Abhishek Singh3e915632014-11-01 17:14:50 +053016736
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016737 /*The Dynamic Config Items Update may happen even if the state is in INIT.
16738 * It is important to ensure that the command is passed down to the FW only
16739 * if the Infra Station is in a connected state.A connected station could also be
16740 * in a PREAUTH or REASSOC states.So, consider not sending the command down in INIT state.
16741 * We also have to ensure that if there is a STOP command we always have to inform Riva,
16742 * irrespective of whichever state we are in.*/
16743 if ((pMac->roam.neighborRoamInfo.neighborRoamState == eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
16744 (command != ROAM_SCAN_OFFLOAD_STOP))
16745 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053016746 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
16747 FL("Scan Command not sent to FW with state = %s and cmd=%d\n"),
16748 macTraceGetNeighbourRoamState(
16749 pMac->roam.neighborRoamInfo.neighborRoamState), command);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016750 return eHAL_STATUS_FAILURE;
16751 }
16752
Mukul Sharmad68cda62015-03-20 21:25:41 +053016753 if (!CsrIsRSOCommandAllowed(pMac, command))
16754 {
16755 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16756 FL("RSO command %d lastSentCmd %d, RSO is out of sync in HOST-FWR"),
16757 command, pNeighborRoamInfo->lastSentCmd);
16758 return eHAL_STATUS_FAILURE;
16759 }
16760
Abhishek Singh3e915632014-11-01 17:14:50 +053016761 /* We dont need psession during ROAM_SCAN_OFFLOAD_STOP
16762 * Also there are cases where pNeighborRoamInfo->currAPbssid
16763 * is set to 0 during disconnect and so we might return without stopping
16764 * the roam scan. So no need to find the session if command is
16765 * ROAM_SCAN_OFFLOAD_STOP.
16766 */
Padma, Santhosh Kumare5f677e2015-11-27 17:39:31 +053016767 status = csrRoamGetSessionIdFromBSSID(pMac,
16768 (tCsrBssid *)pNeighborRoamInfo->currAPbssid,
16769 &sessionId);
Abhishek Singh3e915632014-11-01 17:14:50 +053016770 if( ROAM_SCAN_OFFLOAD_STOP != command )
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016771 {
Abhishek Singh3e915632014-11-01 17:14:50 +053016772 if ( !HAL_STATUS_SUCCESS( status ) )
16773 {
16774 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16775 "%s: Not able to find the sessionId for Roam Offload scan request", __func__);
16776 return eHAL_STATUS_FAILURE;
16777 }
16778 pSession = CSR_GET_SESSION( pMac, sessionId );
16779 if (NULL == pSession)
16780 {
16781 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
krunal soni587bf012014-02-04 12:35:11 -080016782 "%s:pSession is null", __func__);
Abhishek Singh3e915632014-11-01 17:14:50 +053016783 return eHAL_STATUS_FAILURE;
16784 }
16785 pBssDesc = pSession->pConnectBssDesc;
16786 if (pBssDesc == NULL)
16787 {
16788 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16789 "%s: pBssDesc not found for current session", __func__);
16790 return eHAL_STATUS_FAILURE;
16791 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016792 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016793 pRequestBuf = vos_mem_malloc(sizeof(tSirRoamOffloadScanReq));
16794 if (NULL == pRequestBuf)
16795 {
Abhishek Singh3e915632014-11-01 17:14:50 +053016796 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16797 "%s: Not able to allocate memory for Roam Offload scan request", __func__);
16798 return eHAL_STATUS_FAILED_ALLOC;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016799 }
16800
Sushant Kaushikb97a0082015-08-31 12:36:45 +053016801#ifdef FEATURE_WLAN_DIAG_SUPPORT
16802 limDiagEventReport(pMac, WLAN_PE_DIAG_ROAM_REQUESTED, NULL,
16803 eSIR_SUCCESS, eSIR_SUCCESS);
16804#endif
16805
Abhishek Singh3e915632014-11-01 17:14:50 +053016806 vos_mem_zero(pRequestBuf, sizeof(tSirRoamOffloadScanReq));
16807 /* If command is STOP, then pass down ScanOffloadEnabled as Zero.This will handle the case of
16808 * host driver reloads, but Riva still up and running*/
16809 pRequestBuf->Command = command;
16810 if(command == ROAM_SCAN_OFFLOAD_STOP)
16811 {
16812 pRequestBuf->RoamScanOffloadEnabled = 0;
Kanchanapally, Vidyullathac9c9c942015-02-03 22:19:00 +053016813 pRequestBuf->StartScanReason = reason;
Abhishek Singh3e915632014-11-01 17:14:50 +053016814 /*For a STOP Command, there is no need to
16815 * go through filling up all the below parameters
16816 * since they are not required for the STOP command*/
16817 goto send_roam_scan_offload_cmd;
16818 }
16819 else
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016820 pRequestBuf->RoamScanOffloadEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
Kiet Lam64c1b492013-07-12 13:56:44 +053016821 vos_mem_copy(pRequestBuf->ConnectedNetwork.currAPbssid,
16822 pNeighborRoamInfo->currAPbssid,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016823 sizeof(tCsrBssid));
16824 pRequestBuf->ConnectedNetwork.ssId.length =
16825 pMac->roam.roamSession[sessionId].connectedProfile.SSID.length;
16826 vos_mem_copy(pRequestBuf->ConnectedNetwork.ssId.ssId,
16827 pMac->roam.roamSession[sessionId].connectedProfile.SSID.ssId,
16828 pRequestBuf->ConnectedNetwork.ssId.length);
16829 pRequestBuf->ConnectedNetwork.authentication =
16830 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
16831 pRequestBuf->ConnectedNetwork.encryption =
16832 pMac->roam.roamSession[sessionId].connectedProfile.EncryptionType;
16833 pRequestBuf->ConnectedNetwork.mcencryption =
16834 pMac->roam.roamSession[sessionId].connectedProfile.mcEncryptionType;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016835 if (pNeighborRoamInfo->cfgParams.neighborLookupThreshold)
16836 {
16837 pRequestBuf->LookupThreshold =
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016838 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborLookupThreshold * (-1);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016839 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
16840 }
16841 else
16842 {
16843 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Calculate Adaptive Threshold");
16844 operationChannel = pSession->connectedProfile.operationChannel;
16845
16846 if (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
16847 {
16848 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16849 "%s: csrGetParsedBssDescriptionIEs failed", __func__);
16850 vos_mem_free(pRequestBuf);
16851 return eHAL_STATUS_FAILURE;
16852 }
Kaushik, Sushant5874d032014-02-20 17:22:36 +053016853 if(NULL == pIes)
16854 {
16855 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16856 "%s : pIes is Null", __func__);
Mukul Sharmad2b81862014-07-01 21:01:04 +053016857 vos_mem_free(pRequestBuf);
Kaushik, Sushant5874d032014-02-20 17:22:36 +053016858 return eHAL_STATUS_FAILURE;
16859 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016860 if (pIes->SuppRates.present)
16861 {
16862 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Number \t Rate");
16863 /*Check for both basic rates and extended rates.*/
16864 for (i = 0; i < pIes->SuppRates.num_rates; i++)
16865 {
16866 /*Check if the Rate is Mandatory or Not*/
16867 if (csrRatesIsDot11RateSupported(pMac, pIes->SuppRates.rates[i])
16868 && (pIes->SuppRates.rates[i] & 0x80))
16869 {
16870 /*Retrieve the actual data rate*/
16871 dataRate = (pIes->SuppRates.rates[i] & 0x7F)/2;
16872 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
16873 if (minRate == 0)
16874 minRate = dataRate;
16875 else
16876 minRate = (minRate < dataRate) ? minRate:dataRate;
16877 }
16878 }
16879
16880 if (pIes->ExtSuppRates.present)
16881 {
16882 for (i = 0; i < pIes->ExtSuppRates.num_rates; i++)
16883 {
16884 /*Check if the Rate is Mandatory or Not*/
16885 if (csrRatesIsDot11RateSupported(pMac, pIes->ExtSuppRates.rates[i])
16886 && (pIes->ExtSuppRates.rates[i] & 0x80))
16887 {
16888 /*Retrieve the actual data rate*/
16889 dataRate = (pIes->ExtSuppRates.rates[i] & 0x7F)/2;
16890 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
16891 if (minRate == 0)
16892 minRate = dataRate;
16893 else
16894 minRate = (minRate < dataRate) ? minRate:dataRate;
16895 }
16896 }
16897 }
16898 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "MinRate = %d", minRate);
16899 }
16900 else
16901 {
16902 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16903 "%s: Supp Rates not present in pIes", __func__);
16904 vos_mem_free(pRequestBuf);
16905 return eHAL_STATUS_FAILURE;
16906 }
16907 if (NULL != pIes)
16908 {
16909 vos_mem_free(pIes);
16910 pIes = NULL;
16911 }
16912 switch (minRate)
16913 {
16914 case 1:
16915 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_1MBPS;
16916 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_1MBPS;
16917 break;
16918 case 2:
16919 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_2MBPS;
16920 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_2MBPS;
16921 break;
16922 case 5:
16923 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_5_5MBPS;
16924 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_5_5MBPS;
16925 break;
16926 case 6:
16927 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
16928 {
16929 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_2G;
16930 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_2G;
16931 }
16932 else
16933 {
16934 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_5G;
16935 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_5G;
16936 }
16937 break;
16938 case 11:
16939 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_11MBPS;
16940 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_11MBPS;
16941 break;
16942 case 12:
16943 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
16944 {
16945 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_2G;
16946 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_2G;
16947 }
16948 else
16949 {
16950 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_5G;
16951 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_5G;
16952 }
16953 break;
16954 case 24:
16955 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
16956 {
16957 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_2G;
16958 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_2G;
16959 }
16960 else
16961 {
16962 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_5G;
16963 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_5G;
16964 }
16965 break;
16966 default:
16967 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_DEFAULT;
16968 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
16969 break;
16970 }
16971 }
16972 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
16973 "Chnl=%d,MinRate=%d,RxSenThr=%d,LookupThr=%d",
16974 operationChannel, minRate,
16975 pRequestBuf->RxSensitivityThreshold,
16976 pRequestBuf->LookupThreshold);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016977 pRequestBuf->RoamRssiDiff =
16978 pMac->roam.configParam.RoamRssiDiff;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016979 pRequestBuf->StartScanReason = reason;
16980 pRequestBuf->NeighborScanTimerPeriod =
16981 pNeighborRoamInfo->cfgParams.neighborScanPeriod;
16982 pRequestBuf->NeighborRoamScanRefreshPeriod =
16983 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod;
16984 pRequestBuf->NeighborScanChannelMinTime =
16985 pNeighborRoamInfo->cfgParams.minChannelScanTime;
16986 pRequestBuf->NeighborScanChannelMaxTime =
16987 pNeighborRoamInfo->cfgParams.maxChannelScanTime;
16988 pRequestBuf->EmptyRefreshScanPeriod =
16989 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -080016990 /* MAWC feature */
16991 pRequestBuf->MAWCEnabled =
16992 pMac->roam.configParam.MAWCEnabled;
Kapil Gupta04ab1992016-06-26 13:36:51 +053016993
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016994#ifdef FEATURE_WLAN_ESE
16995 pRequestBuf->IsESEEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016996#endif
16997 if (
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016998#ifdef FEATURE_WLAN_ESE
16999 ((pNeighborRoamInfo->isESEAssoc) &&
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017000 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived ==
17001 eANI_BOOLEAN_FALSE)) ||
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017002 (pNeighborRoamInfo->isESEAssoc == eANI_BOOLEAN_FALSE) ||
17003#endif // ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017004 currChannelListInfo->numOfChannels == 0)
17005 {
17006
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080017007 /*Retrieve the Channel Cache either from ini or from the Occupied Channels list.
17008 * Give Preference to INI Channels.*/
17009 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
17010 {
17011 ChannelList = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
17012 /*The INI channels need to be filtered with respect to the current
17013 * band that is supported.*/
17014 eBand = pMac->roam.configParam.bandCapability;
17015 if ((eCSR_BAND_24 != eBand) && (eCSR_BAND_5G != eBand) && (eCSR_BAND_ALL != eBand))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017016 {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080017017 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17018 "Invalid band, No operation carried out (Band %d)", eBand);
17019 vos_mem_free(pRequestBuf);
17020 return eHAL_STATUS_FAILURE;
17021 }
17022 for (i=0; i<pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels; i++)
17023 {
17024 if(((eCSR_BAND_24 == eBand) && CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
17025 ((eCSR_BAND_5G == eBand) && CSR_IS_CHANNEL_5GHZ(*ChannelList)) ||
17026 (eCSR_BAND_ALL == eBand))
17027 {
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053017028 if(*ChannelList && csrRoamIsChannelValid(pMac, *ChannelList) &&
17029 ((pMac->roam.configParam.allowDFSChannelRoam) ||
17030 (!CSR_IS_CHANNEL_DFS(*ChannelList))) &&
17031 (num_channels < SIR_ROAM_MAX_CHANNELS))
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080017032 {
17033 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
17034 }
17035 }
17036 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017037 }
17038 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
17039 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080017040 }
17041 else
17042 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017043 ChannelList = pMac->scan.occupiedChannels.channelList;
17044 for(i=0; i<pMac->scan.occupiedChannels.numChannels; i++)
17045 {
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053017046 /*Allow DFS channels only if the DFS channel roam flag is enabled */
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053017047 if(*ChannelList && ((pMac->roam.configParam.allowDFSChannelRoam) ||
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053017048 (!CSR_IS_CHANNEL_DFS(*ChannelList))) &&
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053017049 (num_channels < SIR_ROAM_MAX_CHANNELS))
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080017050 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017051 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080017052 }
17053 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017054 }
17055 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
17056 /* If the profile changes as to what it was earlier, inform the FW through
17057 * FLUSH as ChannelCacheType in which case, the FW will flush the occupied channels
17058 * for the earlier profile and try to learn them afresh.*/
17059 if (reason == REASON_FLUSH_CHANNEL_LIST)
17060 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
17061 else {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080017062 if (csrNeighborRoamIsNewConnectedProfile(pMac))
17063 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
17064 else
17065 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017066 }
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080017067 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017068 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017069#ifdef FEATURE_WLAN_ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017070 else
17071 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017072 /* If ESE is enabled, and a neighbor Report is received,then
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017073 * Ignore the INI Channels or the Occupied Channel List. Consider
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017074 * the channels in the neighbor list sent by the ESE AP.*/
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070017075 if (currChannelListInfo->numOfChannels != 0)
17076 {
17077 ChannelList = currChannelListInfo->ChannelList;
17078 for (i=0;i<currChannelListInfo->numOfChannels;i++)
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017079 {
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053017080 if(*ChannelList && ((pMac->roam.configParam.allowDFSChannelRoam) ||
17081 (!CSR_IS_CHANNEL_DFS(*ChannelList))))
17082 {
17083 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] =
17084 *ChannelList;
17085 }
17086 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017087 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070017088 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
17089 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
17090 }
17091 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017092#endif
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053017093 for (i = 0, j = 0;j < (sizeof(ChannelCacheStr)/sizeof(ChannelCacheStr[0]))
17094 && i < pRequestBuf->ConnectedNetwork.ChannelCount; i++)
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070017095 {
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053017096 if (j < sizeof(ChannelCacheStr))
17097 {
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070017098 j += snprintf(ChannelCacheStr + j, sizeof(ChannelCacheStr) - j," %d",
17099 pRequestBuf->ConnectedNetwork.ChannelCache[i]);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053017100 }
17101 else
17102 {
17103 break;
17104 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070017105 }
17106 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
17107 "ChnlCacheType:%d, No of Chnls:%d,Channels: %s",
17108 pRequestBuf->ChannelCacheType,
17109 pRequestBuf->ConnectedNetwork.ChannelCount,
17110 ChannelCacheStr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017111 num_channels = 0;
17112 ChannelList = NULL;
17113
17114 /* Maintain the Valid Channels List*/
Srinivas Girigowda56076852013-08-20 14:00:50 -070017115 host_channels = sizeof(pMac->roam.validChannelList);
17116 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &host_channels)))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017117 {
Srinivas Girigowda56076852013-08-20 14:00:50 -070017118 ChannelList = pMac->roam.validChannelList;
17119 pMac->roam.numValidChannels = host_channels;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017120 }
Srinivas Girigowda56076852013-08-20 14:00:50 -070017121 else
17122 {
17123 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17124 "%s:Failed to get the valid channel list", __func__);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -070017125 vos_mem_free(pRequestBuf);
Srinivas Girigowda56076852013-08-20 14:00:50 -070017126 return eHAL_STATUS_FAILURE;
17127 }
17128 for(i=0; i<pMac->roam.numValidChannels; i++)
17129 {
Hema Aparna Medicharlaff739ec2015-04-26 04:53:18 +053017130 if(*ChannelList && ((pMac->roam.configParam.allowDFSChannelRoam) ||
17131 (!CSR_IS_CHANNEL_DFS(*ChannelList))))
Srinivas Girigowda56076852013-08-20 14:00:50 -070017132 {
17133 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
17134 }
17135 ChannelList++;
17136 }
17137 pRequestBuf->ValidChannelCount = num_channels;
17138
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070017139 pRequestBuf->MDID.mdiePresent =
17140 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent;
17141 pRequestBuf->MDID.mobilityDomain =
17142 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mobilityDomain;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070017143 pRequestBuf->nProbes = pMac->roam.configParam.nProbes;
17144
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070017145 pRequestBuf->HomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080017146 /* Home Away Time should be at least equal to (MaxDwell time + (2*RFS)),
17147 * where RFS is the RF Switching time. It is twice RFS to consider the
17148 * time to go off channel and return to the home channel. */
17149 if (pRequestBuf->HomeAwayTime < (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)))
17150 {
17151 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
17152 "%s: Invalid config, Home away time(%d) is less than (twice RF switching time + channel max time)(%d)"
17153 " Hence enforcing home away time to disable (0)",
17154 __func__, pRequestBuf->HomeAwayTime,
17155 (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)));
17156 pRequestBuf->HomeAwayTime = 0;
17157 }
17158 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,"HomeAwayTime:%d",pRequestBuf->HomeAwayTime);
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070017159
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017160 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
17161 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
17162 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
17163 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_24G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
17164 pRequestBuf->p24GProbeTemplate, &pRequestBuf->us24GProbeTemplateLen);
17165
17166 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_5G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
17167 pRequestBuf->p5GProbeTemplate, &pRequestBuf->us5GProbeTemplateLen);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080017168send_roam_scan_offload_cmd:
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070017169 msg.type = WDA_ROAM_SCAN_OFFLOAD_REQ;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017170 msg.reserved = 0;
17171 msg.bodyptr = pRequestBuf;
Konamki, Sreelakshmi5548ff92015-07-29 14:47:54 +053017172 MTRACE(vos_trace(VOS_MODULE_ID_SME,
17173 TRACE_CODE_SME_TX_WDA_MSG, sessionId, msg.type));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017174 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
17175 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070017176 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_ROAM_SCAN_OFFLOAD_REQ message to WDA", __func__);
17177 vos_mem_free(pRequestBuf);
17178 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017179 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070017180 else
17181 {
17182 if (ROAM_SCAN_OFFLOAD_START == command)
17183 bRoamScanOffloadStarted = VOS_TRUE;
17184 else if (ROAM_SCAN_OFFLOAD_STOP == command)
17185 bRoamScanOffloadStarted = VOS_FALSE;
Mukul Sharmad68cda62015-03-20 21:25:41 +053017186
17187 /*update the last sent cmd*/
17188 pNeighborRoamInfo->lastSentCmd = command;
Srinivas Girigowda577ed652013-08-14 11:38:29 -070017189 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017190
17191 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 +053017192
17193 if (sme_IsFeatureSupportedByFW(PER_BASED_ROAMING) &&
Kapil Gupta38ef58c2016-07-12 22:24:15 +053017194 (command != ROAM_SCAN_OFFLOAD_STOP) &&
17195 pMac->roam.configParam.isPERRoamEnabled)
Kapil Gupta04ab1992016-06-26 13:36:51 +053017196 {
17197
17198 /* PER ROAM SCAN */
17199 PERRoamReqBuf = vos_mem_malloc(sizeof(*PERRoamReqBuf));
17200 if (!PERRoamReqBuf)
17201 {
17202 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17203 "%s: Not able to allocate mem for PERRoamReqBuf", __func__);
17204 return eHAL_STATUS_FAILURE;
17205 }
17206 /* PER Roam Config */
17207 PERRoamReqBuf->rateUpThreshold =
17208 pMac->roam.configParam.rateUpThreshold;
17209 PERRoamReqBuf->rateDownThreshold =
17210 pMac->roam.configParam.rateDownThreshold;
17211 PERRoamReqBuf->waitPeriodForNextPERScan =
17212 pMac->roam.configParam.waitPeriodForNextPERScan;
17213 PERRoamReqBuf->PERtimerThreshold =
17214 pMac->roam.configParam.PERtimerThreshold;
17215 PERRoamReqBuf->isPERRoamCCAEnabled =
17216 pMac->roam.configParam.isPERRoamCCAEnabled;
Kapil Guptac69c28a2016-08-25 14:11:17 +053017217 PERRoamReqBuf->PERRoamFullScanThreshold =
17218 pMac->roam.configParam.PERRoamFullScanThreshold;
Kapil Gupta04ab1992016-06-26 13:36:51 +053017219 PERRoamReqBuf->PERroamTriggerPercent =
17220 pMac->roam.configParam.PERroamTriggerPercent;
17221 PERRoamReqBuf->sessionId = sessionId;
17222
17223 PERroamScanConfigMsg.type = WDA_PER_ROAM_SCAN_OFFLOAD_REQ;
17224 PERroamScanConfigMsg.reserved = 0;
17225 PERroamScanConfigMsg.bodyptr = PERRoamReqBuf;
17226 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA,
17227 &PERroamScanConfigMsg))) {
17228 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
17229 FL("Not able to post WDA_PER_ROAM_SCAN_OFFLOAD_REQ msg to WDA"));
17230 vos_mem_free(PERRoamReqBuf);
17231 return eHAL_STATUS_FAILURE;
17232 }
17233 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
17234 FL("rateUpThreshold =%x rateDownThreshold =%x waitPeriodForNextPERScan=%u PERtimerThreshold=%u"),
17235 PERRoamReqBuf->rateUpThreshold,
17236 PERRoamReqBuf->rateDownThreshold,
17237 PERRoamReqBuf->waitPeriodForNextPERScan,
17238 PERRoamReqBuf->PERtimerThreshold);
17239 }
17240
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017241 return status;
17242}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017243
17244eHalStatus csrRoamOffloadScanRspHdlr(tpAniSirGlobal pMac, tANI_U8 reason)
17245{
17246 switch(reason)
17247 {
17248 case 0:
17249 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with failure status");
17250 break;
17251 case REASON_OS_REQUESTED_ROAMING_NOW:
17252 csrNeighborRoamProceedWithHandoffReq(pMac);
17253 break;
Mukul Sharma20aa6582014-08-07 21:36:12 +053017254 case REASON_INITIAL_FORCED_ROAM_TO_5G:
17255 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "%s recevied REASON_INITIAL_FORCED_ROAM_TO_5G", __func__);
17256 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017257 default:
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -070017258 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 -070017259 }
17260 return eHAL_STATUS_SUCCESS;
17261}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017262#endif
17263
Jeff Johnson295189b2012-06-20 16:38:30 -070017264tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
17265 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
17266{
17267 tANI_BOOLEAN found = FALSE;
17268 eHalStatus status = eHAL_STATUS_SUCCESS;
17269 tCsrPeStatsReqInfo staEntry;
17270 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
17271 tListElem *pStaEntry = NULL;
17272 VOS_STATUS vosStatus;
17273 tPmcPowerState powerState;
17274 *pFound = FALSE;
17275
17276 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
17277 if(pStaEntry)
17278 {
17279 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
17280 if(pTempStaEntry->periodicity)
17281 {
17282 pTempStaEntry->periodicity =
17283 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
17284 }
17285 else
17286 {
17287 pTempStaEntry->periodicity = periodicity;
17288 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017289 pTempStaEntry->numClient++;
17290 found = TRUE;
17291 }
17292 else
17293 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017294 vos_mem_set(&staEntry, sizeof(tCsrPeStatsReqInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070017295 staEntry.numClient = 1;
17296 staEntry.periodicity = periodicity;
17297 staEntry.pMac = pMac;
17298 staEntry.rspPending = FALSE;
17299 staEntry.staId = staId;
17300 staEntry.statsMask = statsMask;
17301 staEntry.timerRunning = FALSE;
17302 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
17303 if(!pTempStaEntry)
17304 {
17305 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017306 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070017307 return NULL;
17308 }
17309 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017310 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
17311 if(ePMC_FULL_POWER == powerState)
17312 {
17313 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
17314 {
17315 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
17316 }
17317 }
17318 else
17319 {
17320 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
17321 {
17322 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
17323 }
17324 }
17325 if(!pTempStaEntry->timerRunning)
17326 {
17327 //send down a req in case of one time req, for periodic ones wait for timer to expire
17328 if(!pTempStaEntry->rspPending &&
17329 !pTempStaEntry->periodicity)
17330 {
17331 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
17332 if(!HAL_STATUS_SUCCESS(status))
17333 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017334 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017335 }
17336 else
17337 {
17338 pTempStaEntry->rspPending = TRUE;
17339 }
17340 }
17341 if(pTempStaEntry->periodicity)
17342 {
17343 if(!found)
17344 {
17345
17346 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
17347 csrRoamPeStatsTimerHandler, pTempStaEntry );
17348 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
17349 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017350 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017351 return NULL;
17352 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017353 }
17354 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017355 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070017356 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
17357 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
17358 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017359 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017360 return NULL;
17361 }
17362 pTempStaEntry->timerRunning = TRUE;
17363 }
17364 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017365 *pFound = found;
17366 return pTempStaEntry;
17367}
17368
Jeff Johnson295189b2012-06-20 16:38:30 -070017369/*
17370 pStaEntry is no longer invalid upon the return of this function.
17371*/
17372static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
17373{
17374 if(pEntry)
17375 {
17376 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
17377 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017378 vos_mem_free(GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070017379 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017380 }
17381 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017382
17383void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
17384{
17385 tListElem *pEntry;
17386 tCsrPeStatsReqInfo *pTempStaEntry;
17387 VOS_STATUS vosStatus;
17388 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070017389 if(!pEntry)
17390 {
17391 //list empty
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017392 smsLog(pMac, LOGE, FL(" List empty, no stats req for PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017393 return;
17394 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017395 while( pEntry )
17396 {
17397 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070017398 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
17399 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017400 smsLog(pMac, LOGW, FL("Match found"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017401 if(pTempStaEntry->timerRunning)
17402 {
17403 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
17404 /* If we are not able to stop the timer here, just remove
17405 * the entry from the linked list. Destroy the timer object
17406 * and free the memory in the timer CB
17407 */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017408 if ( vosStatus == VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -070017409 {
17410 /* the timer is successfully stopped */
17411 pTempStaEntry->timerRunning = FALSE;
17412
17413 /* Destroy the timer */
17414 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
17415 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
17416 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017417 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017418 }
17419 }
17420 else
17421 {
17422 // the timer could not be stopped. Hence destroy and free the
17423 // memory for the PE stat entry in the timer CB.
17424 pTempStaEntry->timerStopFailed = TRUE;
17425 }
Jeff Johnsone7245742012-09-05 17:12:55 -070017426 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017427
17428 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
17429 {
17430 // Only free the memory if we could stop the timer successfully
17431 if(!pTempStaEntry->timerStopFailed)
17432 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017433 vos_mem_free(pTempStaEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070017434 pTempStaEntry = NULL;
17435 }
17436 break;
17437 }
17438
17439 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
17440 }
17441 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017442 return;
17443}
17444
17445
Jeff Johnsone7245742012-09-05 17:12:55 -070017446void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070017447{
17448
Jeff Johnsone7245742012-09-05 17:12:55 -070017449 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
17450 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
17451 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
17452 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
17453 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
17454 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
17455 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070017456 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070017457 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
17458 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
17459 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
17460 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
17461 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
17462 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070017463 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070017464 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
17465 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070017466
17467}
17468
Jeff Johnson295189b2012-06-20 16:38:30 -070017469void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
17470 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
17471{
17472 tANI_U8 stats[500];
17473 tANI_U8 *pStats = NULL;
17474 tANI_U32 tempMask = 0;
17475 tANI_U8 counter = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070017476 if(!callback)
17477 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017478 smsLog(pMac, LOGE, FL("Cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017479 return;
17480 }
17481 if(!statsMask)
17482 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017483 smsLog(pMac, LOGE, FL("Cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017484 return;
17485 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017486 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070017487 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070017488 while(tempMask)
17489 {
17490 if(tempMask & 1)
17491 {
17492 //new stats info from PE, fill up the stats strucutres in PMAC
17493 switch(counter)
17494 {
17495 case eCsrSummaryStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017496 smsLog( pMac, LOG2, FL("Summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053017497 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
17498 sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070017499 pStats += sizeof(tCsrSummaryStatsInfo);
17500 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017501 case eCsrGlobalClassAStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017502 smsLog( pMac, LOG2, FL("ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053017503 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
17504 sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070017505 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070017506 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017507 case eCsrGlobalClassBStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017508 smsLog( pMac, LOG2, FL("ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053017509 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
17510 sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070017511 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070017512 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017513 case eCsrGlobalClassCStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017514 smsLog( pMac, LOG2, FL("ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053017515 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
17516 sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070017517 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070017518 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017519 case eCsrGlobalClassDStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017520 smsLog( pMac, LOG2, FL("ClassD stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053017521 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
17522 sizeof(tCsrGlobalClassDStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070017523 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070017524 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017525 case eCsrPerStaStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017526 smsLog( pMac, LOG2, FL("PerSta stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053017527 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
17528 sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070017529 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070017530 break;
Sushant Kaushik33200572015-08-05 16:46:20 +053017531 case eCsrPerPktStats:
17532 smsLog( pMac, LOG2, FL("PerPkt stats"));
17533 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.perPktStatsInfo,
17534 sizeof(tPerTxPacketFrmFw));
17535 pStats += sizeof(tPerTxPacketFrmFw);
17536 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017537 default:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017538 smsLog( pMac, LOGE, FL("Unknown stats type and counter %d"), counter);
Jeff Johnson295189b2012-06-20 16:38:30 -070017539 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017540 }
17541 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017542 tempMask >>=1;
17543 counter++;
17544 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017545 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070017546}
17547
Jeff Johnson295189b2012-06-20 16:38:30 -070017548eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
17549{
17550 tListElem *pEntry = NULL;
17551 tListElem *pPrevEntry = NULL;
17552 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
17553 eHalStatus status = eHAL_STATUS_SUCCESS;
17554 VOS_STATUS vosStatus;
17555 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070017556 if(!pEntry)
17557 {
17558 //list empty
17559 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017560 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070017561 return status;
17562 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017563 while( pEntry )
17564 {
17565 if(pPrevEntry)
17566 {
17567 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
17568 //send up the stats report
17569 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
17570 pTempStaEntry->staId, pTempStaEntry->pContext);
17571 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
17572 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017573 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070017574 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
17575 {
Jeff Johnsone7245742012-09-05 17:12:55 -070017576 pTempStaEntry->pPeStaEntry->numClient--;
17577 //check if we need to delete the entry from peStatsReqList too
17578 if(!pTempStaEntry->pPeStaEntry->numClient)
17579 {
17580 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
17581 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017582 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017583 //check if we need to stop the tl stats timer too
17584 pMac->roam.tlStatsReqInfo.numClient--;
17585 if(!pMac->roam.tlStatsReqInfo.numClient)
17586 {
17587 if(pMac->roam.tlStatsReqInfo.timerRunning)
17588 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017589 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
17590 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070017591 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017592 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070017593 //we will continue
17594 }
17595 }
17596 pMac->roam.tlStatsReqInfo.periodicity = 0;
17597 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
17598 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017599 if (pTempStaEntry->periodicity)
17600 {
17601 //While creating StaEntry in csrGetStatistics,
17602 //Initializing and starting timer only when periodicity is set.
17603 //So Stop and Destroy timer only when periodicity is set.
17604
Jeff Johnsone7245742012-09-05 17:12:55 -070017605 vos_timer_stop( &pTempStaEntry->timer );
17606 // Destroy the vos timer...
17607 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
17608 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
17609 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017610 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070017611 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017612 }
Jeff Johnsone7245742012-09-05 17:12:55 -070017613
Jeff Johnson295189b2012-06-20 16:38:30 -070017614
17615 pPrevEntry = pEntry;
17616 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
17617 }
17618 //the last one
17619 if(pPrevEntry)
17620 {
17621 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
17622 //send up the stats report
17623 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
17624 pTempStaEntry->staId, pTempStaEntry->pContext);
17625 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
17626 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017627 return status;
17628
17629}
17630
Jeff Johnson295189b2012-06-20 16:38:30 -070017631eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
17632 tRequestFullPowerReason *pReason,
17633 tANI_BOOLEAN *pfNeedPower )
17634{
17635 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
17636 tRequestFullPowerReason reason = eSME_REASON_OTHER;
17637 tPmcState pmcState;
17638 eHalStatus status = eHAL_STATUS_SUCCESS;
17639 // TODO : Session info unavailable
17640 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070017641 if( pfNeedPower )
17642 {
17643 *pfNeedPower = eANI_BOOLEAN_FALSE;
17644 }
17645 //We only handle CSR commands
17646 if( !(eSmeCsrCommandMask & pCommand->command) )
17647 {
17648 return eHAL_STATUS_SUCCESS;
17649 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017650 //Check PMC state first
17651 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070017652 switch( pmcState )
17653 {
17654 case REQUEST_IMPS:
17655 case IMPS:
17656 if( eSmeCommandScan == pCommand->command )
17657 {
17658 switch( pCommand->u.scanCmd.reason )
17659 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017660#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
17661 case eCsrScanGetLfrResult:
17662#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017663 case eCsrScanGetResult:
17664 case eCsrScanBGScanAbort:
17665 case eCsrScanBGScanEnable:
17666 case eCsrScanGetScanChnInfo:
17667 //Internal process, no need for full power
17668 fNeedFullPower = eANI_BOOLEAN_FALSE;
17669 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017670 default:
17671 //Other scans are real scan, ask for power
17672 fNeedFullPower = eANI_BOOLEAN_TRUE;
17673 break;
17674 } //switch
17675 }
17676 else
17677 {
17678 //ask for power for roam and status change
17679 fNeedFullPower = eANI_BOOLEAN_TRUE;
17680 }
17681 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017682 case REQUEST_BMPS:
17683 case BMPS:
17684 case REQUEST_START_UAPSD:
17685 case UAPSD:
17686 //We treat WOWL same as BMPS
17687 case REQUEST_ENTER_WOWL:
17688 case WOWL:
17689 if( eSmeCommandRoam == pCommand->command )
17690 {
17691 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
17692 tCsrScanResult *pScanResult;
17693 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070017694 switch ( pCommand->u.roamCmd.roamReason )
17695 {
17696 case eCsrForcedDisassoc:
17697 case eCsrForcedDisassocMICFailure:
17698 reason = eSME_LINK_DISCONNECTED_BY_HDD;
17699 fNeedFullPower = eANI_BOOLEAN_TRUE;
17700 break;
17701 case eCsrSmeIssuedDisassocForHandoff:
17702 case eCsrForcedDeauth:
17703 case eCsrHddIssuedReassocToSameAP:
17704 case eCsrSmeIssuedReassocToSameAP:
17705 fNeedFullPower = eANI_BOOLEAN_TRUE;
17706 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017707 case eCsrCapsChange:
17708 fNeedFullPower = eANI_BOOLEAN_TRUE;
17709 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017710 default:
17711 //Check whether the profile is already connected. If so, no need for full power
17712 //Note: IBSS is ignored for now because we don't support powersave in IBSS
17713 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
17714 {
17715 //Only need to check the first one
17716 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
17717 if( pEntry )
17718 {
17719 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
17720#if 0
17721 // TODO : Session Specific info pConnectBssDesc
17722 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
17723 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
17724 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
17725 {
17726 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
17727 // with Authenticating first. To force this, stop the current association (Disassociate) and
17728 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
17729 // a new Association.
17730 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
17731 {
17732 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
17733 {
17734 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
17735 //No need for full power
17736 //Set the flag so the code later can avoid to do the above
17737 //check again.
17738 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
17739 break;
17740 }
17741 }
17742 }
17743#endif
17744 }
17745 }
17746 //If we are here, full power is needed
17747 fNeedFullPower = eANI_BOOLEAN_TRUE;
17748 break;
17749 }
17750 }
17751 else if( eSmeCommandWmStatusChange == pCommand->command )
17752 {
17753 //need full power for all
17754 fNeedFullPower = eANI_BOOLEAN_TRUE;
17755 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
17756 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017757#ifdef FEATURE_WLAN_TDLS
17758 else if( eSmeCommandTdlsAddPeer == pCommand->command )
17759 {
17760 //TDLS link is getting established. need full power
17761 fNeedFullPower = eANI_BOOLEAN_TRUE;
17762 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
17763 }
17764#endif
mukul sharmabab477d2015-06-11 17:14:55 +053017765 else if (eSmeCommandDelStaSession == pCommand->command)
17766 {
17767 //need full power for all
17768 fNeedFullPower = eANI_BOOLEAN_TRUE;
17769 }
17770
Jeff Johnson295189b2012-06-20 16:38:30 -070017771 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017772 case REQUEST_STOP_UAPSD:
17773 case REQUEST_EXIT_WOWL:
17774 if( eSmeCommandRoam == pCommand->command )
17775 {
17776 fNeedFullPower = eANI_BOOLEAN_TRUE;
17777 switch ( pCommand->u.roamCmd.roamReason )
17778 {
17779 case eCsrForcedDisassoc:
17780 case eCsrForcedDisassocMICFailure:
17781 reason = eSME_LINK_DISCONNECTED_BY_HDD;
17782 break;
17783 default:
17784 break;
17785 }
17786 }
17787 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017788 case STOPPED:
17789 case REQUEST_STANDBY:
17790 case STANDBY:
17791 case LOW_POWER:
17792 //We are not supposed to do anything
Sushant Kaushike0d2cce2014-04-10 14:36:07 +053017793 smsLog( pMac, LOGE, FL( "cannot process because PMC is in"
17794 " stopped/standby state %s (%d)" ),
17795 sme_PmcStatetoString(pmcState), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070017796 status = eHAL_STATUS_FAILURE;
17797 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017798 case FULL_POWER:
17799 case REQUEST_FULL_POWER:
17800 default:
17801 //No need to ask for full power. This has to be FULL_POWER state
17802 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017803 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070017804 if( pReason )
17805 {
17806 *pReason = reason;
17807 }
17808 if( pfNeedPower )
17809 {
17810 *pfNeedPower = fNeedFullPower;
17811 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017812 return ( status );
17813}
17814
Jeff Johnson295189b2012-06-20 16:38:30 -070017815static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
17816{
17817 eHalStatus status = eHAL_STATUS_SUCCESS;
17818 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
17819 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070017820 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070017821 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
17822 {
17823 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
17824 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017825 return ( status );
17826}
17827
Jeff Johnson295189b2012-06-20 16:38:30 -070017828tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
17829{
17830 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070017831 if( pCmd )
17832 {
17833 pMac->roam.sPendingCommands++;
17834 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017835 return ( pCmd );
17836}
17837
Jeff Johnson295189b2012-06-20 16:38:30 -070017838void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
17839{
17840 if (pMac->roam.sPendingCommands > 0)
17841 {
17842 //All command allocated through csrGetCommandBuffer need to
17843 //decrement the pending count when releasing.
17844 pMac->roam.sPendingCommands--;
17845 smeReleaseCommand( pMac, pCommand );
17846 }
17847 else
17848 {
17849 smsLog(pMac, LOGE, FL( "no pending commands"));
17850 VOS_ASSERT(0);
17851 }
17852}
17853
Jeff Johnson295189b2012-06-20 16:38:30 -070017854//Return SUCCESS is the command is queued, failed
17855eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
17856{
17857 eHalStatus status;
Sushant Kaushik4928e542014-12-29 15:25:54 +053017858
17859 if (!SME_IS_START(pMac))
17860 {
17861 smsLog( pMac, LOGE, FL("Sme in stop state"));
17862 return eHAL_STATUS_FAILURE;
17863 }
17864
Jeff Johnson295189b2012-06-20 16:38:30 -070017865 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
17866 {
17867 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
17868 pCommand->u.scanCmd.reason);
17869 return eHAL_STATUS_CSR_WRONG_STATE;
17870 }
17871
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017872 if ((pMac->fScanOffload) && (pCommand->command == eSmeCommandScan))
17873 {
17874 csrLLInsertTail(&pMac->sme.smeScanCmdPendingList,
17875 &pCommand->Link, LL_ACCESS_LOCK);
17876 // process the command queue...
17877 smeProcessPendingQueue(pMac);
17878 status = eHAL_STATUS_SUCCESS;
17879 goto end;
17880 }
17881
Jeff Johnson295189b2012-06-20 16:38:30 -070017882 //We can call request full power first before putting the command into pending Q
17883 //because we are holding SME lock at this point.
17884 status = csrRequestFullPower( pMac, pCommand );
17885 if( HAL_STATUS_SUCCESS( status ) )
17886 {
17887 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070017888 //make sure roamCmdPendingList is not empty first
17889 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
17890 if( fNoCmdPending )
17891 {
17892 smePushCommand( pMac, pCommand, fHighPriority );
17893 }
17894 else
17895 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017896 //Other commands are waiting for PMC callback, queue the new command to the pending Q
Jeff Johnson295189b2012-06-20 16:38:30 -070017897 //no list lock is needed since SME lock is held
17898 if( !fHighPriority )
17899 {
17900 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
17901 }
17902 else {
17903 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
17904 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017905 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017906 }
17907 else if( eHAL_STATUS_PMC_PENDING == status )
17908 {
17909 //no list lock is needed since SME lock is held
17910 if( !fHighPriority )
17911 {
17912 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
17913 }
17914 else {
17915 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
17916 }
17917 //Let caller know the command is queue
17918 status = eHAL_STATUS_SUCCESS;
17919 }
17920 else
17921 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017922 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
Jeff Johnson295189b2012-06-20 16:38:30 -070017923 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017924 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070017925 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017926end:
Jeff Johnson295189b2012-06-20 16:38:30 -070017927 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070017928}
Jeff Johnson295189b2012-06-20 16:38:30 -070017929eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
17930{
17931 eHalStatus status = eHAL_STATUS_SUCCESS;
17932 tSirUpdateAPWPSIEsReq *pMsg;
17933 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
17934
17935 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
17936 if (NULL == pSession)
17937 {
17938 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
17939 return eHAL_STATUS_FAILURE;
17940 }
17941
Jeff Johnson295189b2012-06-20 16:38:30 -070017942 do
17943 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017944 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
17945 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
17946 vos_mem_set(pMsg, sizeof(tSirUpdateAPWPSIEsReq), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070017947 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
17948
17949 pBuf = (tANI_U8 *)&pMsg->transactionId;
lukez3c809222013-05-03 10:23:02 -070017950 VOS_ASSERT(pBuf);
17951
Jeff Johnson295189b2012-06-20 16:38:30 -070017952 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070017953 // transactionId
17954 *pBuf = 0;
17955 *( pBuf + 1 ) = 0;
17956 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070017957 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053017958 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
17959 sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070017960 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070017961 //sessionId
17962 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070017963 // APWPSIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053017964 vos_mem_copy((tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
Jeff Johnson295189b2012-06-20 16:38:30 -070017965 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070017966 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070017967 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070017968 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070017969 return ( status );
17970}
Jeff Johnson295189b2012-06-20 16:38:30 -070017971eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
17972{
17973 eHalStatus status = eHAL_STATUS_SUCCESS;
17974 tSirUpdateAPWPARSNIEsReq *pMsg;
17975 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070017976 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
17977 if (NULL == pSession)
17978 {
17979 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
17980 return eHAL_STATUS_FAILURE;
17981 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017982 do
17983 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017984 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPARSNIEsReq));
17985 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
17986 vos_mem_set(pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070017987 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070017988 pBuf = (tANI_U8 *)&pMsg->transactionId;
17989 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070017990 // transactionId
17991 *pBuf = 0;
17992 *( pBuf + 1 ) = 0;
17993 pBuf += sizeof(tANI_U16);
lukez3c809222013-05-03 10:23:02 -070017994 VOS_ASSERT(pBuf);
17995
Jeff Johnson295189b2012-06-20 16:38:30 -070017996 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053017997 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
17998 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070017999 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070018000 // sessionId
18001 *pBuf++ = (tANI_U8)sessionId;
18002
18003 // APWPARSNIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053018004 vos_mem_copy((tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070018005 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070018006 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070018007 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070018008 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070018009 return ( status );
18010}
Jeff Johnson295189b2012-06-20 16:38:30 -070018011
18012#ifdef WLAN_FEATURE_VOWIFI_11R
18013//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
18014eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
18015{
18016 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
18017 tpSirFTPreAuthReq pftPreAuthReq;
18018 tANI_U16 auth_req_len = 0;
18019 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070018020 auth_req_len = sizeof(tSirFTPreAuthReq);
18021 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
Kiet Lam64c1b492013-07-12 13:56:44 +053018022 if (NULL == pftPreAuthReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070018023 {
18024 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
18025 return eHAL_STATUS_RESOURCES;
18026 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018027 // Save the SME Session ID here. We need it while processing the preauth response
18028 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070018029 vos_mem_zero(pftPreAuthReq, auth_req_len);
18030
18031 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
18032 sizeof(pBssDescription->length) + pBssDescription->length);
18033
18034 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
18035
18036 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
18037
Kiet Lam64c1b492013-07-12 13:56:44 +053018038 vos_mem_copy((void *)&pftPreAuthReq->currbssId,
18039 (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
18040 vos_mem_copy((void *)&pftPreAuthReq->preAuthbssId,
18041 (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070018042
Jeff Johnson295189b2012-06-20 16:38:30 -070018043#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080018044 if (csrRoamIs11rAssoc(pMac) &&
18045 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070018046 {
18047 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
Kiet Lam64c1b492013-07-12 13:56:44 +053018048 vos_mem_copy(pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
18049 pMac->ft.ftSmeContext.auth_ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -070018050 }
18051 else
18052#endif
18053 {
18054 pftPreAuthReq->ft_ies_length = 0;
18055 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070018056 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
18057 sizeof(pBssDescription->length) + pBssDescription->length);
18058 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070018059 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
18060}
Jeff Johnson295189b2012-06-20 16:38:30 -070018061/*--------------------------------------------------------------------------
18062 * This will receive and process the FT Pre Auth Rsp from the current
18063 * associated ap.
18064 *
18065 * This will invoke the hdd call back. This is so that hdd can now
18066 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
18067 ------------------------------------------------------------------------*/
18068void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
18069{
18070 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
18071 eHalStatus status = eHAL_STATUS_SUCCESS;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080018072#if defined(FEATURE_WLAN_LFR) || defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070018073 tCsrRoamInfo roamInfo;
18074#endif
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053018075 eCsrAuthType conn_Auth_type;
Jeff Johnson295189b2012-06-20 16:38:30 -070018076
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070018077#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080018078 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070018079 if (status != eHAL_STATUS_SUCCESS) {
18080 /*
18081 * Bail out if pre-auth was not even processed.
18082 */
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053018083 smsLog(pMac, LOGE,FL("Preauth was not processed: %d SessionID: %d"),
18084 status, pFTPreAuthRsp->smeSessionId);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070018085 return;
18086 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018087#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070018088 /* The below function calls/timers should be invoked only if the pre-auth is successful */
18089 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
18090 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070018091 // Implies a success
18092 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070018093 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
18094 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
Sandeep Puligilla0c486ca2014-05-24 02:40:49 +053018095 /* No need to notify qos module if this is a non 11r & ESE roam*/
18096 if (csrRoamIs11rAssoc(pMac)
18097#if defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
18098 || csrRoamIsESEAssoc(pMac)
18099#endif
18100 )
Tushnim Bhattacharyya8436d772013-06-26 23:03:29 -070018101 {
18102 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
18103 }
Girish Gowli1c2fc802015-01-19 16:18:07 +053018104 if (pMac->roam.configParam.roamDelayStatsEnabled)
18105 {
18106 vos_record_roam_event(e_CACHE_ROAM_DELAY_DATA, NULL, 0);
18107 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018108 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
18109 * actual transition from the current to handoff AP is triggered */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053018110 status = vos_timer_start(&pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
18111 60);
Girish Gowli1c2fc802015-01-19 16:18:07 +053018112 if (pMac->roam.configParam.roamDelayStatsEnabled)
18113 {
18114 vos_record_roam_event(e_SME_PREAUTH_REASSOC_START, NULL, 0);
18115 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018116 if (eHAL_STATUS_SUCCESS != status)
18117 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018118 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070018119 return;
18120 }
Jeff Johnson295189b2012-06-20 16:38:30 -070018121 // Save the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053018122 vos_mem_copy((void *)&pMac->ft.ftSmeContext.preAuthbssId,
18123 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070018124 if (csrRoamIs11rAssoc(pMac))
18125 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
18126 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
18127
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080018128#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
18129 if (csrRoamIsESEAssoc(pMac))
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070018130 {
18131 /* read TSF */
18132 csrRoamReadTSF(pMac, (tANI_U8 *)roamInfo.timestamp);
18133
18134 // Save the bssid from the received response
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080018135 vos_mem_copy((void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070018136 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_CCKM_PREAUTH_NOTIFY, 0);
18137 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080018138#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson04dd8a82012-06-29 20:41:40 -070018139#ifdef FEATURE_WLAN_LFR
18140 // If Legacy Fast Roaming is enabled, signal the supplicant
18141 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053018142 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070018143 {
18144 // Save the bssid from the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053018145 vos_mem_copy((void *)&roamInfo.bssid,
18146 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070018147 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
18148 }
18149
18150#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070018151
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053018152 // If its an Open Auth, FT IEs are not provided by supplicant
18153 // Hence populate them here
18154 conn_Auth_type = pMac->roam.roamSession[pMac->ft.ftSmeContext.smeSessionId].connectedProfile.AuthType;
18155 pMac->ft.ftSmeContext.addMDIE = FALSE;
18156 if( csrRoamIs11rAssoc(pMac) &&
18157 (conn_Auth_type == eCSR_AUTH_TYPE_OPEN_SYSTEM))
18158 {
18159 tANI_U16 ft_ies_length;
18160 ft_ies_length = pFTPreAuthRsp->ric_ies_length;
18161
18162 if ( (pMac->ft.ftSmeContext.reassoc_ft_ies) &&
18163 (pMac->ft.ftSmeContext.reassoc_ft_ies_length))
18164 {
18165 vos_mem_free(pMac->ft.ftSmeContext.reassoc_ft_ies);
18166 pMac->ft.ftSmeContext.reassoc_ft_ies_length = 0;
18167 }
18168
18169 pMac->ft.ftSmeContext.reassoc_ft_ies = vos_mem_malloc(ft_ies_length);
18170 if ( NULL == pMac->ft.ftSmeContext.reassoc_ft_ies )
18171 {
18172 smsLog( pMac, LOGE, FL("Memory allocation failed for ft_ies"));
18173 }
18174 else
18175 {
18176 // Copy the RIC IEs to reassoc IEs
18177 vos_mem_copy(((tANI_U8 *)pMac->ft.ftSmeContext.reassoc_ft_ies),
18178 (tANI_U8 *)pFTPreAuthRsp->ric_ies,
18179 pFTPreAuthRsp->ric_ies_length);
18180 pMac->ft.ftSmeContext.reassoc_ft_ies_length = ft_ies_length;
18181 pMac->ft.ftSmeContext.addMDIE = TRUE;
18182 }
18183 }
18184
Jeff Johnson295189b2012-06-20 16:38:30 -070018185 // Done with it, init it.
18186 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
18187}
18188#endif
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053018189
Jeff Johnson295189b2012-06-20 16:38:30 -070018190#ifdef FEATURE_WLAN_BTAMP_UT_RF
18191void csrRoamJoinRetryTimerHandler(void *pv)
18192{
18193 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
18194 tpAniSirGlobal pMac = pInfo->pMac;
18195 tANI_U32 sessionId = pInfo->sessionId;
18196 tCsrRoamSession *pSession;
18197
18198 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
18199 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018200 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070018201 pSession = CSR_GET_SESSION( pMac, sessionId );
18202 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
18203 {
18204 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
18205 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018206 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070018207 }
18208 }
18209 }
18210}
Jeff Johnson295189b2012-06-20 16:38:30 -070018211eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
18212{
18213 eHalStatus status = eHAL_STATUS_FAILURE;
18214 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
18215
18216 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
18217 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018218 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070018219 pSession->maxRetryCount--;
18220 pSession->joinRetryTimerInfo.pMac = pMac;
18221 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053018222 status = vos_timer_start(&pSession->hTimerJoinRetry, interval/PAL_TIMER_TO_MS_UNIT);
18223 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070018224 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018225 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070018226 }
18227 }
18228 else
18229 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018230 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070018231 pSession->maxRetryCount);
18232 }
18233
18234 return (status);
18235}
Jeff Johnson295189b2012-06-20 16:38:30 -070018236eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
18237{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080018238 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070018239 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
18240 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053018241 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerJoinRetry));
Jeff Johnson295189b2012-06-20 16:38:30 -070018242 }
18243
18244 return eHAL_STATUS_SUCCESS;
18245}
18246#endif
18247
18248
18249/*
18250 pBuf points to the beginning of the message
18251 LIM packs disassoc rsp as below,
18252 messageType - 2 bytes
18253 messageLength - 2 bytes
18254 sessionId - 1 byte
18255 transactionId - 2 bytes (tANI_U16)
18256 reasonCode - 4 bytes (sizeof(tSirResultCodes))
18257 peerMacAddr - 6 bytes
18258 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
18259*/
18260static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
18261{
18262 if(pBuf && pRsp)
18263 {
18264 pBuf += 4; //skip type and length
18265 pRsp->sessionId = *pBuf++;
18266 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
18267 pBuf += 2;
18268 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
18269 pBuf += 4;
18270 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
18271 }
18272}
18273
Jeff Johnsond13512a2012-07-17 11:42:19 -070018274eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
18275{
18276 static uNvTables nvTables;
18277 eHalStatus status = eHAL_STATUS_SUCCESS;
18278 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
18279
18280 /* read the country code from NV and use it */
18281 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
18282 {
Kiet Lam64c1b492013-07-12 13:56:44 +053018283 vos_mem_copy(pCountry, nvTables.defaultCountryTable.countryCode,
18284 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070018285 return status;
18286 }
18287 else
18288 {
Kiet Lam64c1b492013-07-12 13:56:44 +053018289 vos_mem_copy(pCountry, "XXX", WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070018290 status = eHAL_STATUS_FAILURE;
18291 return status;
18292 }
18293}
18294
18295eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
18296{
Kiet Lam64c1b492013-07-12 13:56:44 +053018297 vos_mem_copy(pCountry, pMac->scan.countryCode11d, WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070018298 return eHAL_STATUS_SUCCESS;
18299}
schang86c22c42013-03-13 18:41:24 -070018300
18301eHalStatus csrSetTxPower(tpAniSirGlobal pMac, v_U8_t sessionId, v_U8_t mW)
18302{
18303 tSirSetTxPowerReq *pMsg = NULL;
18304 eHalStatus status = eHAL_STATUS_SUCCESS;
18305 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
18306
18307 if (!pSession)
18308 {
18309 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
18310 return eHAL_STATUS_FAILURE;
18311 }
18312
Kiet Lam64c1b492013-07-12 13:56:44 +053018313 pMsg = vos_mem_malloc(sizeof(tSirSetTxPowerReq));
18314 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
18315 vos_mem_set((void *)pMsg, sizeof(tSirSetTxPowerReq), 0);
18316 pMsg->messageType = eWNI_SME_SET_TX_POWER_REQ;
18317 pMsg->length = sizeof(tSirSetTxPowerReq);
18318 pMsg->mwPower = mW;
18319 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
18320 sizeof(tSirMacAddr));
18321 status = palSendMBMessage(pMac->hHdd, pMsg);
18322 if (!HAL_STATUS_SUCCESS(status))
schang86c22c42013-03-13 18:41:24 -070018323 {
Kiet Lam64c1b492013-07-12 13:56:44 +053018324 smsLog(pMac, LOGE, FL(" csr set TX Power Post MSG Fail %d "), status);
18325 //pMsg is freed by palSendMBMessage
schang86c22c42013-03-13 18:41:24 -070018326 }
18327 return status;
18328}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018329
Sandeep Puligilla332ea912014-02-04 00:16:24 +053018330eHalStatus csrHT40StopOBSSScan(tpAniSirGlobal pMac, v_U8_t sessionId)
18331{
18332 tSirSmeHT40OBSSStopScanInd *pMsg = NULL;
18333 eHalStatus status = eHAL_STATUS_SUCCESS;
18334 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
18335
18336 if (!pSession)
18337 {
18338 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
18339 return eHAL_STATUS_FAILURE;
18340 }
18341 if(IS_HT40_OBSS_SCAN_FEATURE_ENABLE)
18342 {
18343 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSStopScanInd));
Abhishek Singh11aa2902014-05-05 11:52:52 +053018344
18345 if( NULL == pMsg )
18346 {
18347 smsLog(pMac, LOGE, FL("PMsg is NULL "));
18348 return eHAL_STATUS_FAILURE;
18349 }
Sandeep Puligilla332ea912014-02-04 00:16:24 +053018350 vos_mem_zero((void *)pMsg, sizeof(tSirSmeHT40OBSSStopScanInd));
18351 pMsg->messageType = eWNI_SME_HT40_STOP_OBSS_SCAN_IND;
Sreelakshmi Konamkidb3f75a2016-05-26 15:41:04 +053018352 pMsg->length =
18353 pal_cpu_to_be16(sizeof(tSirSmeHT40OBSSStopScanInd));
Sandeep Puligilla332ea912014-02-04 00:16:24 +053018354 pMsg->seesionId = sessionId;
Sreelakshmi Konamkidb3f75a2016-05-26 15:41:04 +053018355 vos_mem_copy(pMsg->bssid, pSession->connectedProfile.bssid,
18356 sizeof(tSirMacAddr));
Sandeep Puligilla332ea912014-02-04 00:16:24 +053018357 status = palSendMBMessage(pMac->hHdd, pMsg);
18358 if (!HAL_STATUS_SUCCESS(status))
18359 {
18360 smsLog(pMac, LOGE, FL(" csr STOP OBSS SCAN Fail %d "), status);
18361 //pMsg is freed by palSendMBMessage
18362 }
18363 }
18364 else
18365 {
18366 smsLog(pMac, LOGE, FL(" OBSS STOP OBSS SCAN is not supported"));
18367 status = eHAL_STATUS_FAILURE;
18368 }
18369 return status;
18370}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070018371/* Returns whether a session is in VOS_STA_MODE...or not */
18372tANI_BOOLEAN csrRoamIsStaMode(tpAniSirGlobal pMac, tANI_U32 sessionId)
18373{
18374 tCsrRoamSession *pSession = NULL;
18375 pSession = CSR_GET_SESSION ( pMac, sessionId );
18376 if(!pSession)
18377 {
18378 smsLog(pMac, LOGE, FL(" %s: session %d not found "), __func__, sessionId);
18379 return eANI_BOOLEAN_FALSE;
18380 }
18381 if ( !CSR_IS_SESSION_VALID ( pMac, sessionId ) )
18382 {
18383 smsLog(pMac, LOGE, FL(" %s: Inactive session"), __func__);
18384 return eANI_BOOLEAN_FALSE;
18385 }
18386 if ( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
18387 {
18388 return eANI_BOOLEAN_FALSE;
18389 }
18390 /* There is a possibility that the above check may fail,because
18391 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
18392 * when it is connected.So,we may sneak through the above check even
18393 * if we are not a STA mode INFRA station. So, if we sneak through
18394 * the above condition, we can use the following check if we are
18395 * really in STA Mode.*/
18396
18397 if ( NULL != pSession->pCurRoamProfile )
18398 {
18399 if ( pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE )
18400 {
18401 return eANI_BOOLEAN_TRUE;
18402 } else {
18403 smsLog(pMac, LOGE, FL(" %s: pCurRoamProfile is NULL\n"), __func__);
18404 return eANI_BOOLEAN_FALSE;
18405 }
18406 }
18407
18408 return eANI_BOOLEAN_FALSE;
18409}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070018410
Selvaraj, Sridhar3714c4d2016-06-22 15:19:12 +053018411/**
18412 * csr_set_src_handoff_request() - Set handoff source to
18413 * SME handoff request
18414 * @pHandoffInfo: Pointer to Handoff info
18415 * @pMsg: Pointer to SME handoff request message
18416 *
18417 * Return: None
18418 */
18419#ifndef QCA_WIFI_ISOC
18420static inline void csr_set_src_handoff_request(tAniHandoffReq *pMsg,
18421 tCsrHandoffRequest *pHandoffInfo)
18422{
18423 pMsg->handoff_src = pHandoffInfo->src;
18424}
18425#else
18426static inline void csr_set_src_handoff_request(tAniHandoffReq *pMsg,
18427 tCsrHandoffRequest *pHandoffInfo)
18428{
18429}
18430#endif
18431
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070018432#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
18433eHalStatus csrHandoffRequest(tpAniSirGlobal pMac,
18434 tCsrHandoffRequest *pHandoffInfo)
18435{
18436 eHalStatus status = eHAL_STATUS_SUCCESS;
18437 vos_msg_t msg;
18438
18439 tAniHandoffReq *pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053018440 pMsg = vos_mem_malloc(sizeof(tAniHandoffReq));
18441 if ( NULL == pMsg )
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070018442 {
18443 smsLog(pMac, LOGE, " csrHandoffRequest: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053018444 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070018445 }
18446 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_HANDOFF_REQ);
18447 pMsg->msgLen = (tANI_U16)sizeof(tAniHandoffReq);
18448 pMsg->sessionId = pMac->roam.neighborRoamInfo.csrSessionId;
18449 pMsg->channel = pHandoffInfo->channel;
Selvaraj, Sridhar3714c4d2016-06-22 15:19:12 +053018450 csr_set_src_handoff_request(pMsg, pHandoffInfo);
Kiet Lam64c1b492013-07-12 13:56:44 +053018451 vos_mem_copy(pMsg->bssid,
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070018452 pHandoffInfo->bssid,
18453 6);
18454 msg.type = eWNI_SME_HANDOFF_REQ;
18455 msg.bodyptr = pMsg;
18456 msg.reserved = 0;
18457 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
18458 {
18459 smsLog(pMac, LOGE, " csrHandoffRequest failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053018460 vos_mem_free((void *)pMsg);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070018461 status = eHAL_STATUS_FAILURE;
18462 }
18463 return status;
18464}
18465#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070018466
Abhishek Singh00b71972016-01-07 10:51:04 +053018467#ifdef WLAN_FEATURE_RMC
18468eHalStatus csrEnableRMC(tpAniSirGlobal pMac, tANI_U32 sessionId)
18469{
18470 tSirSetRMCReq *pMsg = NULL;
18471 eHalStatus status = eHAL_STATUS_SUCCESS;
18472 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
18473
18474 if (!pSession)
18475 {
18476 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
18477 return eHAL_STATUS_FAILURE;
18478 }
18479
18480 pMsg = vos_mem_malloc(sizeof(tSirSetRMCReq));
18481 if (NULL != pMsg)
18482 {
18483 vos_mem_set((void *)pMsg, sizeof(tSirSetRMCReq), 0);
18484 pMsg->msgType = eWNI_SME_ENABLE_RMC_REQ;
18485 pMsg->msgLen = sizeof(tSirSetRMCReq);
18486 vos_mem_copy((v_U8_t *)pMsg->mcastTransmitter,
18487 &pSession->selfMacAddr, sizeof(tSirMacAddr));
18488
18489 status = palSendMBMessage(pMac->hHdd, pMsg);
18490 if (!HAL_STATUS_SUCCESS(status))
18491 {
18492 smsLog(pMac, LOGE, FL(" csr enable RMC Post MSG Fail %d "), status);
18493 //pMsg is freed by palSendMBMessage
18494 }
18495 }
18496 else
18497 {
18498 return eHAL_STATUS_FAILURE;
18499 }
18500 return status;
18501}
18502
18503eHalStatus csrDisableRMC(tpAniSirGlobal pMac, tANI_U32 sessionId)
18504{
18505 tSirSetRMCReq *pMsg = NULL;
18506 eHalStatus status = eHAL_STATUS_SUCCESS;
18507 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
18508
18509 if (!pSession)
18510 {
18511 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
18512 return eHAL_STATUS_FAILURE;
18513 }
18514
18515 pMsg = vos_mem_malloc(sizeof(tSirSetRMCReq));
18516 if (NULL != pMsg)
18517 {
18518 vos_mem_set((void *)pMsg, sizeof(tSirSetRMCReq), 0);
18519 pMsg->msgType = eWNI_SME_DISABLE_RMC_REQ;
18520 pMsg->msgLen = sizeof(tSirSetRMCReq);
18521 vos_mem_copy((v_U8_t *)pMsg->mcastTransmitter,
18522 &pSession->selfMacAddr, sizeof(tSirMacAddr));
18523
18524 status = palSendMBMessage(pMac->hHdd, pMsg);
18525 if (!HAL_STATUS_SUCCESS(status))
18526 {
18527 smsLog(pMac, LOGE, FL(" csr disable RMC Post MSG Fail %d "), status);
18528 //pMsg is freed by palSendMBMessage
18529 }
18530 }
18531 else
18532 {
18533 return eHAL_STATUS_FAILURE;
18534 }
18535 return status;
18536}
18537
18538#endif /* WLAN_FEATURE_RMC */
18539
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080018540
18541#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070018542/* ---------------------------------------------------------------------------
18543 \fn csrSetCCKMIe
18544 \brief This function stores the CCKM IE passed by the supplicant in a place holder
18545 data structure and this IE will be packed inside reassociation request
18546 \param pMac - pMac global structure
18547 \param sessionId - Current session id
18548 \param pCckmIe - pointer to CCKM IE data
18549 \param ccKmIeLen - length of the CCKM IE
18550 \- return Success or failure
18551 -------------------------------------------------------------------------*/
18552VOS_STATUS csrSetCCKMIe(tpAniSirGlobal pMac, const tANI_U8 sessionId,
18553 const tANI_U8 *pCckmIe,
18554 const tANI_U8 ccKmIeLen)
18555{
18556 eHalStatus status = eHAL_STATUS_SUCCESS;
18557 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
18558
18559 if (!pSession)
18560 {
18561 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
18562 return eHAL_STATUS_FAILURE;
18563 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053018564 vos_mem_copy(pSession->suppCckmIeInfo.cckmIe, pCckmIe, ccKmIeLen);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070018565 pSession->suppCckmIeInfo.cckmIeLen = ccKmIeLen;
18566 return status;
18567}
18568
18569/* ---------------------------------------------------------------------------
18570 \fn csrRoamReadTSF
18571 \brief This function reads the TSF; and also add the time elapsed since last beacon or
18572 probe response reception from the hand off AP to arrive at the latest TSF value.
18573 \param pMac - pMac global structure
18574 \param pTimestamp - output TSF timestamp
18575 \- return Success or failure
18576 -------------------------------------------------------------------------*/
18577VOS_STATUS csrRoamReadTSF(tpAniSirGlobal pMac, tANI_U8 *pTimestamp)
18578{
18579 eHalStatus status = eHAL_STATUS_SUCCESS;
18580 tCsrNeighborRoamBSSInfo handoffNode;
18581 tANI_U32 timer_diff = 0;
18582 tANI_U32 timeStamp[2];
18583 tpSirBssDescription pBssDescription = NULL;
18584
18585 csrNeighborRoamGetHandoffAPInfo(pMac, &handoffNode);
18586 pBssDescription = handoffNode.pBssDescription;
18587
18588 // Get the time diff in milli seconds
18589 timer_diff = vos_timer_get_system_time() - pBssDescription->scanSysTimeMsec;
18590 // Convert msec to micro sec timer
18591 timer_diff = (tANI_U32)(timer_diff * SYSTEM_TIME_MSEC_TO_USEC);
18592
18593 timeStamp[0] = pBssDescription->timeStamp[0];
18594 timeStamp[1] = pBssDescription->timeStamp[1];
18595
18596 UpdateCCKMTSF(&(timeStamp[0]), &(timeStamp[1]), &timer_diff);
18597
Kiet Lamf2f201e2013-11-16 21:24:16 +053018598 vos_mem_copy(pTimestamp, (void *) &timeStamp[0],
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070018599 sizeof (tANI_U32) * 2);
18600 return status;
18601}
18602
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080018603#endif /*FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070018604
Agarwal Ashish738843c2014-09-25 12:27:56 +053018605/* ---------------------------------------------------------------------------
18606 \fn csrDisableDfsChannel
18607 \brief This function will call csrApplyChannelPowerCountryInfo to
18608 \ to trim the list on basis of NO_DFS flag.
18609 \param pMac - pMac global structure
18610 \- return void
18611 -------------------------------------------------------------------------*/
18612void csrDisableDfsChannel(tpAniSirGlobal pMac)
18613{
18614 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels,
18615 pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE);
18616}
Kanchanapally, Vidyullatha2ed7bde2014-12-29 12:18:36 +053018617
18618/* ---------------------------------------------------------------------------
18619 \fn csrGetStaticUapsdMask
18620 \brief This function will get the static uapsd settings for an existing
18621 \ Infra session.
18622 \param pMac - pMac global structure
18623 \- return void
18624 -------------------------------------------------------------------------*/
18625void csrGetStaticUapsdMask(tpAniSirGlobal pMac, tANI_U8 *staticUapsdMask)
18626{
18627 tANI_S8 sessionId;
18628 tCsrRoamSession *pSession = NULL;
18629
18630 *staticUapsdMask = 0;
18631 sessionId = csrGetInfraSessionId(pMac);
18632 if(sessionId == -1)
18633 smsLog(pMac, LOGE, FL("Valid session not present."));
18634 else
18635 pSession = CSR_GET_SESSION(pMac, sessionId);
18636
18637 if(!pSession || !pSession->pCurRoamProfile)
18638 smsLog(pMac, LOGE, FL("Either pSession or Roam profile is NULL,"
18639 " pSession:%p"), pSession);
18640 else
18641 *staticUapsdMask = pSession->pCurRoamProfile->uapsd_mask;
18642}
18643