blob: 5082359fa6b7b1376960a4fac4d36b0feaf1fe9a [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lam0fb93dd2014-02-19 00:32:59 -08002 * Copyright (c) 2012-2014 The Linux Foundation. All rights reserved.
3 *
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/*
23 * Copyright (c) 2012-2014 Qualcomm Atheros, Inc.
24 * All Rights Reserved.
25 * Qualcomm Atheros Confidential and Proprietary.
26 *
27 */
28
29
Jeff Johnson295189b2012-06-20 16:38:30 -070030/** ------------------------------------------------------------------------- *
31 ------------------------------------------------------------------------- *
Jeff Johnsone7245742012-09-05 17:12:55 -070032
Jeff Johnson295189b2012-06-20 16:38:30 -070033
34 \file csrApiRoam.c
35
36 Implementation for the Common Roaming interfaces.
37
Kiet Lamaa8e15a2014-02-11 23:30:06 -080038 Copyright (C) 2008 Qualcomm, Incorporated
39
Jeff Johnson295189b2012-06-20 16:38:30 -070040
41 ========================================================================== */
Jeff Johnson295189b2012-06-20 16:38:30 -070042/*===========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -070043 EDIT HISTORY FOR FILE
44
Jeff Johnson295189b2012-06-20 16:38:30 -070045 This section contains comments describing changes made to the module.
46 Notice that changes are listed in reverse chronological order.
47
Jeff Johnson295189b2012-06-20 16:38:30 -070048 when who what, where, why
49---------- --- --------------------------------------------------------
5006/03/10 js Added support to hostapd driven
51 * deauth/disassoc/mic failure
Jeff Johnson295189b2012-06-20 16:38:30 -070052===========================================================================*/
Jeff Johnson295189b2012-06-20 16:38:30 -070053#include "aniGlobal.h" //for tpAniSirGlobal
54#include "wlan_qct_wda.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070055#include "halMsgApi.h" //for HAL_STA_INVALID_IDX.
Jeff Johnsone7245742012-09-05 17:12:55 -070056#include "limUtils.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070057#include "palApi.h"
58#include "csrInsideApi.h"
59#include "smsDebug.h"
60#include "logDump.h"
61#include "smeQosInternal.h"
62#include "wlan_qct_tl.h"
63#include "smeInside.h"
64#include "vos_diag_core_event.h"
65#include "vos_diag_core_log.h"
66#include "csrApi.h"
67#include "pmc.h"
68#include "vos_nvitem.h"
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053069#include "macTrace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070070#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
71#include "csrNeighborRoam.h"
72#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080073#if defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD)
74#include "csrEse.h"
75#endif /* FEATURE_WLAN_ESE && !FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -070076#define CSR_NUM_IBSS_START_CHANNELS_50 4
77#define CSR_NUM_IBSS_START_CHANNELS_24 3
78#define CSR_DEF_IBSS_START_CHANNEL_50 36
79#define CSR_DEF_IBSS_START_CHANNEL_24 1
Srikant Kuppa2062aaf2012-12-27 17:36:41 -080080#define CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD ( 5 * PAL_TIMER_TO_SEC_UNIT ) // 5 seconds, for WPA, WPA2, CCKM
Jeff Johnson295189b2012-06-20 16:38:30 -070081#define CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD ( 120 * PAL_TIMER_TO_SEC_UNIT ) // 120 seconds, for WPS
82/*---------------------------------------------------------------------------
83 OBIWAN recommends [8 10]% : pick 9%
84---------------------------------------------------------------------------*/
85#define CSR_VCC_UL_MAC_LOSS_THRESHOLD 9
Jeff Johnson295189b2012-06-20 16:38:30 -070086/*---------------------------------------------------------------------------
87 OBIWAN recommends -85dBm
88---------------------------------------------------------------------------*/
89#define CSR_VCC_RSSI_THRESHOLD 80
90#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD 500 //ms
91#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS 2000 //ms
92#define CSR_MIN_TL_STAT_QUERY_PERIOD 500 //ms
93#define CSR_DIAG_LOG_STAT_PERIOD 3000 //ms
Jeff Johnson295189b2012-06-20 16:38:30 -070094//We use constatnt 4 here
95//This macro returns true when higher AC parameter is bigger than lower AC for a difference
96//The bigger the number, the less chance of TX
97//It must put lower AC as the first parameter.
98#define SME_DETECT_AC_WEIGHT_DIFF(loAC, hiAC) (v_BOOL_t)(((hiAC) > (loAC)) ? (((hiAC)-(loAC)) > 4) : 0)
Jeff Johnson295189b2012-06-20 16:38:30 -070099//Flag to send/do not send disassoc frame over the air
100#define CSR_DONT_SEND_DISASSOC_OVER_THE_AIR 1
Jeff Johnson295189b2012-06-20 16:38:30 -0700101#define RSSI_HACK_BMPS (-40)
Jeff Johnsone7245742012-09-05 17:12:55 -0700102#define MAX_CB_VALUE_IN_INI (2)
103
Srinivas Girigowda577ed652013-08-14 11:38:29 -0700104#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
105static tANI_BOOLEAN bRoamScanOffloadStarted = VOS_FALSE;
106#endif
107
Jeff Johnson295189b2012-06-20 16:38:30 -0700108/*--------------------------------------------------------------------------
109 Static Type declarations
110 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800111static tCsrRoamSession csrRoamRoamSession[CSR_ROAM_SESSION_MAX];
Srinivas Girigowdade697412013-02-14 16:31:48 -0800112
Jeff Johnson295189b2012-06-20 16:38:30 -0700113/*--------------------------------------------------------------------------
114 Type declarations
115 ------------------------------------------------------------------------*/
116#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700117int diagAuthTypeFromCSRType(eCsrAuthType authType)
118{
119 int n = AUTH_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700120 switch(authType)
121 {
122 case eCSR_AUTH_TYPE_SHARED_KEY:
123 n = AUTH_SHARED;
124 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700125 case eCSR_AUTH_TYPE_WPA:
126 n = AUTH_WPA_EAP;
127 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700128 case eCSR_AUTH_TYPE_WPA_PSK:
129 n = AUTH_WPA_PSK;
130 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700131 case eCSR_AUTH_TYPE_RSN:
132 n = AUTH_WPA2_EAP;
133 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700134 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700135#ifdef WLAN_FEATURE_11W
136 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
137#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700138 n = AUTH_WPA2_PSK;
139 break;
140#ifdef FEATURE_WLAN_WAPI
141 case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE:
142 n = AUTH_WAPI_CERT;
143 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700144 case eCSR_AUTH_TYPE_WAPI_WAI_PSK:
145 n = AUTH_WAPI_PSK;
146 break;
147#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -0700148 default:
149 break;
150 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700151 return (n);
152}
Jeff Johnson295189b2012-06-20 16:38:30 -0700153int diagEncTypeFromCSRType(eCsrEncryptionType encType)
154{
155 int n = ENC_MODE_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700156 switch(encType)
157 {
158 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
159 case eCSR_ENCRYPT_TYPE_WEP40:
160 n = ENC_MODE_WEP40;
161 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700162 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
163 case eCSR_ENCRYPT_TYPE_WEP104:
164 n = ENC_MODE_WEP104;
165 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700166 case eCSR_ENCRYPT_TYPE_TKIP:
167 n = ENC_MODE_TKIP;
168 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700169 case eCSR_ENCRYPT_TYPE_AES:
170 n = ENC_MODE_AES;
171 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700172#ifdef FEATURE_WLAN_WAPI
173 case eCSR_ENCRYPT_TYPE_WPI:
174 n = ENC_MODE_SMS4;
175 break;
176#endif /* FEATURE_WLAN_WAPI */
177 default:
178 break;
179 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700180 return (n);
181}
Jeff Johnson295189b2012-06-20 16:38:30 -0700182#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700183static const tANI_U8 csrStartIbssChannels50[ CSR_NUM_IBSS_START_CHANNELS_50 ] = { 36, 40, 44, 48};
184static const tANI_U8 csrStartIbssChannels24[ CSR_NUM_IBSS_START_CHANNELS_24 ] = { 1, 6, 11 };
Jeff Johnson295189b2012-06-20 16:38:30 -0700185static void initConfigParam(tpAniSirGlobal pMac);
186static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
187 eCsrRoamCompleteResult Result, void *Context );
188static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId,
189 tCsrRoamProfile *pProfile,
190 tANI_BOOLEAN *pfSameIbss );
191static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirSmeNewBssInfo *pNewBss );
192static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -0700193 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes);
194static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700195eHalStatus csrInitGetChannels(tpAniSirGlobal pMac);
196static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result );
197eHalStatus csrRoamOpen(tpAniSirGlobal pMac);
198eHalStatus csrRoamClose(tpAniSirGlobal pMac);
199void csrRoamMICErrorTimerHandler(void *pv);
200void csrRoamTKIPCounterMeasureTimerHandler(void *pv);
201tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2);
202
203static eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval);
204static eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId);
205static void csrRoamRoamingTimerHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700206eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval);
207eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac);
208static void csrRoamWaitForKeyTimeOutHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700209static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnsone7245742012-09-05 17:12:55 -0700210static eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700211static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo );
212eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
213 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
214 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
215 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
216 tANI_U8 *pKeyRsc );
217static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
218 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes,
219 tCsrRoamProfile *pProfile );
220void csrRoamStatisticsTimerHandler(void *pv);
221void csrRoamStatsGlobalClassDTimerHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700222static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid);
223VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
224 v_U8_t rssiNotification,
225 void * context);
226static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId);
227void csrRoamVccTrigger(tpAniSirGlobal pMac);
228eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId);
229/*
230 pStaEntry is no longer invalid upon the return of this function.
231*/
232static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700233static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,tANI_U8 operationChn, eCsrBand *pBand );
Jeff Johnson295189b2012-06-20 16:38:30 -0700234static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700235tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
236 tDblLinkList *pStaList,
237 tCsrStatsClientReqInfo *pStaEntry);
238void csrRoamStatsClientTimerHandler(void *pv);
239tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
240 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId);
241void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
242 tCsrStatsCallback callback, tANI_U8 staId, void *pContext);
Jeff Johnsone7245742012-09-05 17:12:55 -0700243void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats);
Jeff Johnson295189b2012-06-20 16:38:30 -0700244void csrRoamTlStatsTimerHandler(void *pv);
245void csrRoamPeStatsTimerHandler(void *pv);
246tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
247void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry);
248tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
249eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac);
250static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac );
251static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc );
252static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId );
253static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
254 tCsrRoamSetKey *pSetKey, tANI_U32 roamId );
255//static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand );
256static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
257void csrRoamReissueRoamCommand(tpAniSirGlobal pMac);
258#ifdef FEATURE_WLAN_BTAMP_UT_RF
259void csrRoamJoinRetryTimerHandler(void *pv);
260#endif
261extern void SysProcessMmhMsg(tpAniSirGlobal pMac, tSirMsgQ* pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700262extern void btampEstablishLogLinkHdlr(void* pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700263static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700264void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand);
Jeff Johnson295189b2012-06-20 16:38:30 -0700265
266//Initialize global variables
267static void csrRoamInitGlobals(tpAniSirGlobal pMac)
268{
269 if(pMac)
270 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800271 vos_mem_zero(&csrRoamRoamSession, sizeof(csrRoamRoamSession));
272 pMac->roam.roamSession = csrRoamRoamSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700273 }
274 return;
275}
276
Jeff Johnson295189b2012-06-20 16:38:30 -0700277static void csrRoamDeInitGlobals(tpAniSirGlobal pMac)
278{
279 if(pMac)
280 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800281 pMac->roam.roamSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700282 }
283 return;
284}
Jeff Johnson295189b2012-06-20 16:38:30 -0700285eHalStatus csrOpen(tpAniSirGlobal pMac)
286{
287 eHalStatus status = eHAL_STATUS_SUCCESS;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530288#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700289 static uNvTables nvTables;
290 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700291 v_REGDOMAIN_t regId;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530292#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700293 tANI_U32 i;
294
295 do
296 {
297 /* Initialize CSR Roam Globals */
298 csrRoamInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700299 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
300 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i);
301
302 initConfigParam(pMac);
303 if(!HAL_STATUS_SUCCESS((status = csrScanOpen(pMac))))
304 break;
305 if(!HAL_STATUS_SUCCESS((status = csrRoamOpen(pMac))))
306 break;
307 pMac->roam.nextRoamId = 1; //Must not be 0
308 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.statsClientReqList)))
309 break;
310 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.peStatsReqList)))
311 break;
312 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.roamCmdPendingList)))
313 break;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530314
315#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700316 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
317 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
318 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530319 vos_mem_copy(pMac->scan.countryCodeDefault, nvTables.defaultCountryTable.countryCode,
320 WNI_CFG_COUNTRY_CODE_LEN);
321 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700322 }
323 else
324 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800325 smsLog( pMac, LOGE, FL(" fail to get NV_FIELD_IMAGE") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700326 //hardcoded for now
327 pMac->scan.countryCodeDefault[0] = 'U';
328 pMac->scan.countryCodeDefault[1] = 'S';
329 pMac->scan.countryCodeDefault[2] = 'I';
330 //status = eHAL_STATUS_SUCCESS;
331 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700332 smsLog( pMac, LOG1, FL(" country Code from nvRam %.2s"), pMac->scan.countryCodeDefault );
Kiet Lam6c583332013-10-14 05:37:09 +0530333
334 if (!('0' == pMac->scan.countryCodeDefault[0] &&
335 '0' == pMac->scan.countryCodeDefault[1]))
336 {
337 csrGetRegulatoryDomainForCountry(pMac, pMac->scan.countryCodeDefault,
338 &regId, COUNTRY_NV);
339 }
340 else
341 {
342 regId = REGDOMAIN_WORLD;
343 }
Abhishek Singha306a442013-11-07 18:39:01 +0530344 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700345 pMac->scan.domainIdDefault = regId;
346 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Kiet Lam64c1b492013-07-12 13:56:44 +0530347 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
348 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700349 status = csrInitGetChannels( pMac );
Mihir Shetee1093ba2014-01-21 20:13:32 +0530350#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700351 }while(0);
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530352
Jeff Johnson295189b2012-06-20 16:38:30 -0700353 return (status);
354}
355
Mihir Shetee1093ba2014-01-21 20:13:32 +0530356/* --------------------------------------------------------------------------
357 \fn csrInitChannels
358 \brief This function must be called to initialize CSR channel lists
359 \return eHalStatus
360 ----------------------------------------------------------------------------*/
361eHalStatus csrInitChannels(tpAniSirGlobal pMac)
362{
363 eHalStatus status = eHAL_STATUS_SUCCESS;
364 static uNvTables nvTables;
365 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530366 v_REGDOMAIN_t regId = REGDOMAIN_WORLD;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530367
368 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
369 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
370 {
371 vos_mem_copy(pMac->scan.countryCodeDefault,
372 nvTables.defaultCountryTable.countryCode,
373 WNI_CFG_COUNTRY_CODE_LEN);
374 }
375 else
376 {
377 smsLog( pMac, LOGE, FL(" fail to get NV_FIELD_IMAGE") );
378 //hardcoded for now
379 pMac->scan.countryCodeDefault[0] = 'U';
380 pMac->scan.countryCodeDefault[1] = 'S';
381 pMac->scan.countryCodeDefault[2] = 'I';
382 }
383 smsLog( pMac, LOG1, FL(" country Code from nvRam %.2s"), pMac->scan.countryCodeDefault );
384
Mihir Shetee1093ba2014-01-21 20:13:32 +0530385 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
386 pMac->scan.domainIdDefault = regId;
387 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
388 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
389 WNI_CFG_COUNTRY_CODE_LEN);
Agrawal Ashish0b6984f2014-04-05 18:35:45 +0530390 vos_mem_copy(pMac->scan.countryCodeElected, pMac->scan.countryCodeDefault,
391 WNI_CFG_COUNTRY_CODE_LEN);
Mihir Shetee1093ba2014-01-21 20:13:32 +0530392 status = csrInitGetChannels( pMac );
Agrawal Ashish0b6984f2014-04-05 18:35:45 +0530393 csrClearVotesForCountryInfo(pMac);
Mihir Shetee1093ba2014-01-21 20:13:32 +0530394
395 return status;
396}
397
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530398eHalStatus csrInitChannelsForCC(tpAniSirGlobal pMac)
399{
400 eHalStatus status = eHAL_STATUS_SUCCESS;
401 v_REGDOMAIN_t regId = REGDOMAIN_WORLD;
402
403 if (!('0' == pMac->scan.countryCodeDefault[0] &&
404 '0' == pMac->scan.countryCodeDefault[1]))
405 {
406 csrGetRegulatoryDomainForCountry(pMac, pMac->scan.countryCodeDefault,
407 &regId, COUNTRY_NV);
408
409 }
410 else
411 {
412 return status;
413 }
414 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
415 pMac->scan.domainIdDefault = regId;
416 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
417 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
418 WNI_CFG_COUNTRY_CODE_LEN);
419 status = csrInitGetChannels( pMac );
420 return status;
421}
422
Jeff Johnson295189b2012-06-20 16:38:30 -0700423eHalStatus csrSetRegInfo(tHalHandle hHal, tANI_U8 *apCntryCode)
424{
425 eHalStatus status = eHAL_STATUS_SUCCESS;
426 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
427 v_REGDOMAIN_t regId;
428 v_U8_t cntryCodeLength;
Jeff Johnson295189b2012-06-20 16:38:30 -0700429 if(NULL == apCntryCode)
430 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +0530431 smsLog( pMac, LOGE, FL(" Invalid country Code Pointer") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700432 return eHAL_STATUS_FAILURE;
433 }
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +0530434 smsLog( pMac, LOG1, FL(" country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700435 /* To get correct Regulatory domain from NV table
436 * 2 character Country code should be used
437 * 3rd charater is optional for indoor/outdoor setting */
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700438 cntryCodeLength = WNI_CFG_COUNTRY_CODE_LEN;
439/*
Jeff Johnson295189b2012-06-20 16:38:30 -0700440 cntryCodeLength = strlen(apCntryCode);
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700441
442 if (cntryCodeLength > WNI_CFG_COUNTRY_CODE_LEN)
443 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800444 smsLog( pMac, LOGW, FL(" Invalid Country Code Length") );
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700445 return eHAL_STATUS_FAILURE;
446 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700447*/
Kiet Lam6c583332013-10-14 05:37:09 +0530448 status = csrGetRegulatoryDomainForCountry(pMac, apCntryCode, &regId,
449 COUNTRY_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -0700450 if (status != eHAL_STATUS_SUCCESS)
451 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700452 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700453 return status;
454 }
Abhishek Singha306a442013-11-07 18:39:01 +0530455 status = WDA_SetRegDomain(hHal, regId, eSIR_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700456 if (status != eHAL_STATUS_SUCCESS)
457 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700458 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700459 return status;
460 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700461 pMac->scan.domainIdDefault = regId;
462 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Jeff Johnson295189b2012-06-20 16:38:30 -0700463 /* Clear CC field */
Kiet Lam64c1b492013-07-12 13:56:44 +0530464 vos_mem_set(pMac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN, 0);
465
Jeff Johnson295189b2012-06-20 16:38:30 -0700466 /* Copy 2 or 3 bytes country code */
Kiet Lam64c1b492013-07-12 13:56:44 +0530467 vos_mem_copy(pMac->scan.countryCodeDefault, apCntryCode, cntryCodeLength);
468
Jeff Johnson295189b2012-06-20 16:38:30 -0700469 /* If 2 bytes country code, 3rd byte must be filled with space */
470 if((WNI_CFG_COUNTRY_CODE_LEN - 1) == cntryCodeLength)
471 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530472 vos_mem_set(pMac->scan.countryCodeDefault + 2, 1, 0x20);
Jeff Johnson295189b2012-06-20 16:38:30 -0700473 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530474 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
475 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700476 status = csrInitGetChannels( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -0700477 return status;
478}
Jeff Johnson295189b2012-06-20 16:38:30 -0700479eHalStatus csrSetChannels(tHalHandle hHal, tCsrConfigParam *pParam )
480{
481 eHalStatus status = eHAL_STATUS_SUCCESS;
482 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
483 tANI_U8 index = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +0530484 vos_mem_copy(pParam->Csr11dinfo.countryCode, pMac->scan.countryCodeCurrent,
485 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700486 for ( index = 0; index < pMac->scan.base20MHzChannels.numChannels ; index++)
487 {
488 pParam->Csr11dinfo.Channels.channelList[index] = pMac->scan.base20MHzChannels.channelList[ index ];
489 pParam->Csr11dinfo.ChnPower[index].firstChannel = pMac->scan.base20MHzChannels.channelList[ index ];
490 pParam->Csr11dinfo.ChnPower[index].numChannels = 1;
491 pParam->Csr11dinfo.ChnPower[index].maxtxPower = pMac->scan.defaultPowerTable[index].pwr;
492 }
493 pParam->Csr11dinfo.Channels.numChannels = pMac->scan.base20MHzChannels.numChannels;
494
495 return status;
496}
Jeff Johnson295189b2012-06-20 16:38:30 -0700497eHalStatus csrClose(tpAniSirGlobal pMac)
498{
499 eHalStatus status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800500
Jeff Johnson295189b2012-06-20 16:38:30 -0700501 csrRoamClose(pMac);
502 csrScanClose(pMac);
503 csrLLClose(&pMac->roam.statsClientReqList);
504 csrLLClose(&pMac->roam.peStatsReqList);
505 csrLLClose(&pMac->roam.roamCmdPendingList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700506 /* DeInit Globals */
507 csrRoamDeInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700508 return (status);
509}
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530510
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800511eHalStatus csrUpdateChannelList(tpAniSirGlobal pMac)
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530512{
513 tSirUpdateChanList *pChanList;
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800514 tCsrScanStruct *pScan = &pMac->scan;
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530515 tANI_U8 numChan = pScan->base20MHzChannels.numChannels;
516 tANI_U32 bufLen = sizeof(tSirUpdateChanList) +
517 (sizeof(tSirUpdateChanParam) * (numChan - 1));
518 vos_msg_t msg;
519 tANI_U8 i;
520
521 pChanList = (tSirUpdateChanList *) vos_mem_malloc(bufLen);
522 if (!pChanList)
523 {
524 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
525 "Failed to allocate memory for tSirUpdateChanList");
526 return eHAL_STATUS_FAILED_ALLOC;
527 }
528
529 msg.type = WDA_UPDATE_CHAN_LIST_REQ;
530 msg.reserved = 0;
531 msg.bodyptr = pChanList;
532 pChanList->numChan = numChan;
533 for (i = 0; i < pChanList->numChan; i++)
534 {
535 pChanList->chanParam[i].chanId = pScan->defaultPowerTable[i].chanId;
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800536 pChanList->chanParam[i].pwr = cfgGetRegulatoryMaxTransmitPower(pMac,
537 pScan->defaultPowerTable[i].chanId);
538 if (vos_nv_getChannelEnabledState(pChanList->chanParam[i].chanId) ==
539 NV_CHANNEL_DFS)
540 pChanList->chanParam[i].dfsSet = VOS_TRUE;
541 else
542 pChanList->chanParam[i].dfsSet = VOS_FALSE;
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530543 }
544
545 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
546 {
547 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
548 "%s: Failed to post msg to WDA", __func__);
549 vos_mem_free(pChanList);
550 return eHAL_STATUS_FAILURE;
551 }
552
553 return eHAL_STATUS_SUCCESS;
554}
555
Jeff Johnson295189b2012-06-20 16:38:30 -0700556eHalStatus csrStart(tpAniSirGlobal pMac)
557{
558 eHalStatus status = eHAL_STATUS_SUCCESS;
559 tANI_U32 i;
560
561 do
562 {
563 //save the global vos context
564 pMac->roam.gVosContext = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
565 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
566 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, i );
567
568 status = csrRoamStart(pMac);
569 if(!HAL_STATUS_SUCCESS(status)) break;
570 pMac->scan.f11dInfoApplied = eANI_BOOLEAN_FALSE;
571 status = pmcRegisterPowerSaveCheck(pMac, csrCheckPSReady, pMac);
572 if(!HAL_STATUS_SUCCESS(status)) break;
573 pMac->roam.sPendingCommands = 0;
574 csrScanEnable(pMac);
575#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
576 status = csrNeighborRoamInit(pMac);
577#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
578 pMac->roam.tlStatsReqInfo.numClient = 0;
579 pMac->roam.tlStatsReqInfo.periodicity = 0;
580 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
581 //init the link quality indication also
582 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_MIN_IND;
583 if(!HAL_STATUS_SUCCESS(status))
584 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800585 smsLog(pMac, LOGW, " csrStart: Couldn't Init HO control blk ");
Jeff Johnson295189b2012-06-20 16:38:30 -0700586 break;
587 }
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800588#ifdef QCA_WIFI_2_0
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530589 if (pMac->fScanOffload)
590 {
591 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
592 "Scan offload is enabled, update default chan list");
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800593 status = csrUpdateChannelList(pMac);
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530594 }
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800595#else
596 status = csrUpdateChannelList(pMac);
597#endif
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530598
Jeff Johnson295189b2012-06-20 16:38:30 -0700599 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700600#if defined(ANI_LOGDUMP)
601 csrDumpInit(pMac);
602#endif //#if defined(ANI_LOGDUMP)
Jeff Johnson295189b2012-06-20 16:38:30 -0700603 return (status);
604}
605
Kiet Lama72a2322013-11-15 11:18:11 +0530606eHalStatus csrStop(tpAniSirGlobal pMac, tHalStopType stopType)
Jeff Johnson295189b2012-06-20 16:38:30 -0700607{
608 tANI_U32 sessionId;
609 tANI_U32 i;
610
611 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
612 {
613 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
614 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700615 csrScanDisable(pMac);
616 pMac->scan.fCancelIdleScan = eANI_BOOLEAN_FALSE;
617 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700618 csrLLPurge( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_TRUE );
619
620#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
621 csrNeighborRoamClose(pMac);
622#endif
623 csrScanFlushResult(pMac); //Do we want to do this?
Jeff Johnson295189b2012-06-20 16:38:30 -0700624 // deregister from PMC since we register during csrStart()
625 // (ignore status since there is nothing we can do if it fails)
626 (void) pmcDeregisterPowerSaveCheck(pMac, csrCheckPSReady);
Jeff Johnson295189b2012-06-20 16:38:30 -0700627 //Reset the domain back to the deault
628 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800629 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700630
631 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
632 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530633 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i );
Jeff Johnson295189b2012-06-20 16:38:30 -0700634 pMac->roam.curSubState[i] = eCSR_ROAM_SUBSTATE_NONE;
635 }
636
Kiet Lama72a2322013-11-15 11:18:11 +0530637#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
638 /* When HAL resets all the context information
639 * in HAL is lost, so we might need to send the
640 * scan offload request again when it comes
641 * out of reset for scan offload to be functional
642 */
643 if (HAL_STOP_TYPE_SYS_RESET == stopType)
644 {
645 bRoamScanOffloadStarted = VOS_FALSE;
646 }
647#endif
648
Jeff Johnson295189b2012-06-20 16:38:30 -0700649 return (eHAL_STATUS_SUCCESS);
650}
651
Jeff Johnson295189b2012-06-20 16:38:30 -0700652eHalStatus csrReady(tpAniSirGlobal pMac)
653{
654 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700655 csrScanGetSupportedChannels( pMac );
656 //WNI_CFG_VALID_CHANNEL_LIST should be set by this time
657 //use it to init the background scan list
658 csrInitBGScanChannelList(pMac);
659 /* HDD issues the init scan */
660 csrScanStartResultAgingTimer(pMac);
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -0800661 /* If the gScanAgingTime is set to '0' then scan results aging timeout
662 based on timer feature is not enabled*/
663 if(0 != pMac->scan.scanResultCfgAgingTime )
664 {
665 csrScanStartResultCfgAgingTimer(pMac);
666 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700667 //Store the AC weights in TL for later use
668 WLANTL_GetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
Jeff Johnson295189b2012-06-20 16:38:30 -0700669 status = csrInitChannelList( pMac );
670 if ( ! HAL_STATUS_SUCCESS( status ) )
671 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800672 smsLog( pMac, LOGE, "csrInitChannelList failed during csrReady with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700673 status );
674 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700675 return (status);
676}
Jeff Johnson295189b2012-06-20 16:38:30 -0700677void csrSetDefaultDot11Mode( tpAniSirGlobal pMac )
678{
679 v_U32_t wniDot11mode = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700680 wniDot11mode = csrTranslateToWNICfgDot11Mode(pMac,pMac->roam.configParam.uCfgDot11Mode);
681 ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, wniDot11mode, NULL, eANI_BOOLEAN_FALSE);
682}
Jeff Johnson295189b2012-06-20 16:38:30 -0700683void csrSetGlobalCfgs( tpAniSirGlobal pMac )
684{
Jeff Johnsone7245742012-09-05 17:12:55 -0700685
Jeff Johnson295189b2012-06-20 16:38:30 -0700686 ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
687 ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
688 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
689 ((pMac->roam.configParam.Is11hSupportEnabled) ? pMac->roam.configParam.Is11dSupportEnabled : pMac->roam.configParam.Is11dSupportEnabled),
690 NULL, eANI_BOOLEAN_FALSE);
691 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnsone7245742012-09-05 17:12:55 -0700692 /* 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
693 * Once session is established we will use the session related params stored in PE session for CB mode
694 */
695 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, !!(pMac->roam.configParam.channelBondingMode5GHz), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700696 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, pMac->roam.configParam.HeartbeatThresh24, NULL, eANI_BOOLEAN_FALSE);
697
698 //Update the operating mode to configured value during initialization,
699 //So that client can advertise full capabilities in Probe request frame.
700 csrSetDefaultDot11Mode( pMac );
701}
702
Jeff Johnson295189b2012-06-20 16:38:30 -0700703eHalStatus csrRoamOpen(tpAniSirGlobal pMac)
704{
705 eHalStatus status = eHAL_STATUS_SUCCESS;
706 tANI_U32 i;
707 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700708 do
709 {
710 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
711 {
712 pSession = CSR_GET_SESSION( pMac, i );
713 pSession->roamingTimerInfo.pMac = pMac;
714 pSession->roamingTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
715 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700716 pMac->roam.WaitForKeyTimerInfo.pMac = pMac;
717 pMac->roam.WaitForKeyTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530718 status = vos_timer_init(&pMac->roam.hTimerWaitForKey, VOS_TIMER_TYPE_SW,
719 csrRoamWaitForKeyTimeOutHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -0700720 &pMac->roam.WaitForKeyTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530721 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700722 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800723 smsLog(pMac, LOGE, FL("cannot allocate memory for WaitForKey time out timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700724 break;
725 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530726 status = vos_timer_init(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
727 VOS_TIMER_TYPE_SW, csrRoamTlStatsTimerHandler, pMac);
728 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700729 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800730 smsLog(pMac, LOGE, FL("cannot allocate memory for summary Statistics timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700731 return eHAL_STATUS_FAILURE;
732 }
733 }while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700734 return (status);
735}
736
Jeff Johnson295189b2012-06-20 16:38:30 -0700737eHalStatus csrRoamClose(tpAniSirGlobal pMac)
738{
739 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700740 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
741 {
742 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
743 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530744 vos_timer_stop(&pMac->roam.hTimerWaitForKey);
745 vos_timer_destroy(&pMac->roam.hTimerWaitForKey);
746 vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
747 vos_timer_destroy(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -0700748 return (eHAL_STATUS_SUCCESS);
749}
750
Jeff Johnson295189b2012-06-20 16:38:30 -0700751eHalStatus csrRoamStart(tpAniSirGlobal pMac)
752{
753 (void)pMac;
Jeff Johnson295189b2012-06-20 16:38:30 -0700754 return (eHAL_STATUS_SUCCESS);
755}
756
Jeff Johnson295189b2012-06-20 16:38:30 -0700757void csrRoamStop(tpAniSirGlobal pMac, tANI_U32 sessionId)
758{
759 csrRoamStopRoamingTimer(pMac, sessionId);
760 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
761 csrRoamDeregStatisticsReq(pMac);
762}
Jeff Johnson295189b2012-06-20 16:38:30 -0700763eHalStatus csrRoamGetConnectState(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrConnectState *pState)
764{
765 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Srinivas Girigowdac84c57c2013-02-19 17:41:56 -0800766 if ( CSR_IS_SESSION_VALID(pMac, sessionId) && (NULL != pState) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700767 {
768 status = eHAL_STATUS_SUCCESS;
769 *pState = pMac->roam.roamSession[sessionId].connectState;
770 }
771 return (status);
772}
773
Jeff Johnson295189b2012-06-20 16:38:30 -0700774eHalStatus csrRoamCopyConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
775{
776 eHalStatus status = eHAL_STATUS_FAILURE;
777 tANI_U32 size = 0;
778 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -0700779
780 if(!pSession)
781 {
782 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
783 return eHAL_STATUS_FAILURE;
784 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700785
786 if(pProfile)
787 {
788 if(pSession->pConnectBssDesc)
789 {
790 do
791 {
792 size = pSession->pConnectBssDesc->length + sizeof(pSession->pConnectBssDesc->length);
793 if(size)
794 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530795 pProfile->pBssDesc = vos_mem_malloc(size);
796 if ( NULL != pProfile->pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -0700797 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530798 vos_mem_copy(pProfile->pBssDesc,
799 pSession->pConnectBssDesc, size);
800 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700801 }
802 else
803 break;
804 }
805 else
806 {
807 pProfile->pBssDesc = NULL;
808 }
809 pProfile->AuthType = pSession->connectedProfile.AuthType;
810 pProfile->EncryptionType = pSession->connectedProfile.EncryptionType;
811 pProfile->mcEncryptionType = pSession->connectedProfile.mcEncryptionType;
812 pProfile->BSSType = pSession->connectedProfile.BSSType;
813 pProfile->operationChannel = pSession->connectedProfile.operationChannel;
814 pProfile->CBMode = pSession->connectedProfile.CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +0530815 vos_mem_copy(&pProfile->bssid, &pSession->connectedProfile.bssid,
816 sizeof(tCsrBssid));
817 vos_mem_copy(&pProfile->SSID, &pSession->connectedProfile.SSID,
818 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -0700819#ifdef WLAN_FEATURE_VOWIFI_11R
820 if (pSession->connectedProfile.MDID.mdiePresent)
821 {
822 pProfile->MDID.mdiePresent = 1;
823 pProfile->MDID.mobilityDomain = pSession->connectedProfile.MDID.mobilityDomain;
824 }
825 else
826 {
827 pProfile->MDID.mdiePresent = 0;
828 pProfile->MDID.mobilityDomain = 0;
829 }
830#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800831#ifdef FEATURE_WLAN_ESE
832 pProfile->isESEAssoc = pSession->connectedProfile.isESEAssoc;
833 if (csrIsAuthTypeESE(pSession->connectedProfile.AuthType))
Jeff Johnson295189b2012-06-20 16:38:30 -0700834 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800835 vos_mem_copy (pProfile->eseCckmInfo.krk,
836 pSession->connectedProfile.eseCckmInfo.krk,
Kiet Lam64c1b492013-07-12 13:56:44 +0530837 CSR_KRK_KEY_LEN);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800838 pProfile->eseCckmInfo.reassoc_req_num=
839 pSession->connectedProfile.eseCckmInfo.reassoc_req_num;
840 pProfile->eseCckmInfo.krk_plumbed =
841 pSession->connectedProfile.eseCckmInfo.krk_plumbed;
Jeff Johnson295189b2012-06-20 16:38:30 -0700842 }
843#endif
844 }while(0);
845 }
846 }
847
848 return (status);
849}
850
Jeff Johnson295189b2012-06-20 16:38:30 -0700851eHalStatus csrRoamGetConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
852{
853 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700854
855 if((csrIsConnStateConnected(pMac, sessionId)) ||
856 (csrIsConnStateIbss(pMac, sessionId)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700857 {
858 if(pProfile)
859 {
860 status = csrRoamCopyConnectProfile(pMac, sessionId, pProfile);
861 }
862 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700863 return (status);
864}
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700865
Jeff Johnson295189b2012-06-20 16:38:30 -0700866eHalStatus csrRoamFreeConnectProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile)
867{
868 eHalStatus status = eHAL_STATUS_SUCCESS;
869
Kiet Lam64c1b492013-07-12 13:56:44 +0530870 if (pProfile->pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -0700871 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530872 vos_mem_free(pProfile->pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700873 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530874 if (pProfile->pAddIEAssoc)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700875 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530876 vos_mem_free(pProfile->pAddIEAssoc);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700877 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530878 vos_mem_set(pProfile, sizeof(tCsrRoamConnectedProfile), 0);
879
Jeff Johnson295189b2012-06-20 16:38:30 -0700880 pProfile->AuthType = eCSR_AUTH_TYPE_UNKNOWN;
881 return (status);
882}
883
Jeff Johnson295189b2012-06-20 16:38:30 -0700884static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo )
885{
886 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700887 if( pConnectedInfo->pbFrames )
888 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530889 vos_mem_free(pConnectedInfo->pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -0700890 pConnectedInfo->pbFrames = NULL;
891 }
892 pConnectedInfo->nBeaconLength = 0;
893 pConnectedInfo->nAssocReqLength = 0;
894 pConnectedInfo->nAssocRspLength = 0;
895 pConnectedInfo->staId = 0;
896#ifdef WLAN_FEATURE_VOWIFI_11R
897 pConnectedInfo->nRICRspLength = 0;
898#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800899#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700900 pConnectedInfo->nTspecIeLength = 0;
901#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700902 return ( status );
903}
904
Jeff Johnson295189b2012-06-20 16:38:30 -0700905
906
Jeff Johnsone7245742012-09-05 17:12:55 -0700907
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700908void csrReleaseCommandPreauth(tpAniSirGlobal pMac, tSmeCmd *pCommand)
909{
910 csrReinitPreauthCmd(pMac, pCommand);
911 csrReleaseCommand( pMac, pCommand );
912}
913
Jeff Johnson295189b2012-06-20 16:38:30 -0700914void csrReleaseCommandRoam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
915{
916 csrReinitRoamCmd(pMac, pCommand);
917 csrReleaseCommand( pMac, pCommand );
918}
919
Jeff Johnson295189b2012-06-20 16:38:30 -0700920void csrReleaseCommandScan(tpAniSirGlobal pMac, tSmeCmd *pCommand)
921{
922 csrReinitScanCmd(pMac, pCommand);
923 csrReleaseCommand( pMac, pCommand );
924}
925
Jeff Johnson295189b2012-06-20 16:38:30 -0700926void csrReleaseCommandWmStatusChange(tpAniSirGlobal pMac, tSmeCmd *pCommand)
927{
928 csrReinitWmStatusChangeCmd(pMac, pCommand);
929 csrReleaseCommand( pMac, pCommand );
930}
931
Jeff Johnson295189b2012-06-20 16:38:30 -0700932void csrReinitSetKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
933{
Kiet Lam64c1b492013-07-12 13:56:44 +0530934 vos_mem_set(&pCommand->u.setKeyCmd, sizeof(tSetKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700935}
936
Jeff Johnson295189b2012-06-20 16:38:30 -0700937void csrReinitRemoveKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
938{
Kiet Lam64c1b492013-07-12 13:56:44 +0530939 vos_mem_set(&pCommand->u.removeKeyCmd, sizeof(tRemoveKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700940}
941
Jeff Johnson295189b2012-06-20 16:38:30 -0700942void csrReleaseCommandSetKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
943{
944 csrReinitSetKeyCmd(pMac, pCommand);
945 csrReleaseCommand( pMac, pCommand );
946}
Jeff Johnson295189b2012-06-20 16:38:30 -0700947void csrReleaseCommandRemoveKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
948{
949 csrReinitRemoveKeyCmd(pMac, pCommand);
950 csrReleaseCommand( pMac, pCommand );
951}
Jeff Johnson295189b2012-06-20 16:38:30 -0700952void csrAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping )
953{
954
955 if( eSmeCsrCommandMask & pCommand->command )
956 {
957 switch (pCommand->command)
958 {
959 case eSmeCommandScan:
Jeff Johnson1250df42012-12-10 14:31:52 -0800960 // We need to inform the requester before dropping the scan command
Jeff Johnsonc7c54b12013-11-17 11:49:03 -0800961 smsLog( pMac, LOGW, "%s: Drop scan reason %d callback %p",
962 __func__, pCommand->u.scanCmd.reason,
963 pCommand->u.scanCmd.callback);
Jeff Johnson295189b2012-06-20 16:38:30 -0700964 if (NULL != pCommand->u.scanCmd.callback)
965 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800966 smsLog( pMac, LOGW, "%s callback scan requester", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700967 csrScanCallCallback(pMac, pCommand, eCSR_SCAN_ABORT);
968 }
969 csrReleaseCommandScan( pMac, pCommand );
970 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700971 case eSmeCommandRoam:
972 csrReleaseCommandRoam( pMac, pCommand );
973 break;
974
975 case eSmeCommandWmStatusChange:
976 csrReleaseCommandWmStatusChange( pMac, pCommand );
977 break;
978
979 case eSmeCommandSetKey:
980 csrReleaseCommandSetKey( pMac, pCommand );
981 break;
982
983 case eSmeCommandRemoveKey:
984 csrReleaseCommandRemoveKey( pMac, pCommand );
985 break;
986
987 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800988 smsLog( pMac, LOGW, " CSR abort standard command %d", pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -0700989 csrReleaseCommand( pMac, pCommand );
990 break;
991 }
992 }
993}
994
Jeff Johnson295189b2012-06-20 16:38:30 -0700995void csrRoamSubstateChange( tpAniSirGlobal pMac, eCsrRoamSubState NewSubstate, tANI_U32 sessionId)
996{
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +0530997 smsLog(pMac, LOG1, FL("CSR RoamSubstate: [ %s <== %s ]"),
998 macTraceGetcsrRoamSubState(NewSubstate),
999 macTraceGetcsrRoamSubState(pMac->roam.curSubState[sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07001000
Jeff Johnson295189b2012-06-20 16:38:30 -07001001 if(pMac->roam.curSubState[sessionId] == NewSubstate)
1002 {
1003 return;
Jeff Johnsone7245742012-09-05 17:12:55 -07001004 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001005 pMac->roam.curSubState[sessionId] = NewSubstate;
1006}
1007
Jeff Johnson295189b2012-06-20 16:38:30 -07001008eCsrRoamState csrRoamStateChange( tpAniSirGlobal pMac, eCsrRoamState NewRoamState, tANI_U8 sessionId)
1009{
1010 eCsrRoamState PreviousState;
1011
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05301012 smsLog(pMac, LOG1, FL("CSR RoamState[%hu]: [ %s <== %s ]"), sessionId,
1013 macTraceGetcsrRoamState(NewRoamState),
1014 macTraceGetcsrRoamState(pMac->roam.curState[sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07001015
1016 PreviousState = pMac->roam.curState[sessionId];
1017
1018 if ( NewRoamState != pMac->roam.curState[sessionId] )
1019 {
1020 // Whenever we transition OUT of the Roaming state, clear the Roaming substate...
1021 if ( CSR_IS_ROAM_JOINING(pMac, sessionId) )
1022 {
1023 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
1024 }
1025
1026 pMac->roam.curState[sessionId] = NewRoamState;
1027 }
1028 return( PreviousState );
1029}
1030
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001031void csrAssignRssiForCategory(tpAniSirGlobal pMac, tANI_S8 bestApRssi, tANI_U8 catOffset)
Jeff Johnson295189b2012-06-20 16:38:30 -07001032{
1033 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001034 if(catOffset)
1035 {
1036 pMac->roam.configParam.bCatRssiOffset = catOffset;
1037 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
1038 {
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001039 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 -07001040 }
1041 }
1042}
1043
Jeff Johnson295189b2012-06-20 16:38:30 -07001044static void initConfigParam(tpAniSirGlobal pMac)
1045{
1046 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001047 pMac->roam.configParam.agingCount = CSR_AGING_COUNT;
Sandeep Puligilla60342762014-01-30 21:05:37 +05301048 pMac->roam.configParam.channelBondingMode24GHz =
1049 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
1050 pMac->roam.configParam.channelBondingMode5GHz =
1051 WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001052 pMac->roam.configParam.phyMode = eCSR_DOT11_MODE_TAURUS;
1053 pMac->roam.configParam.eBand = eCSR_BAND_ALL;
1054 pMac->roam.configParam.uCfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
1055 pMac->roam.configParam.FragmentationThreshold = eCSR_DOT11_FRAG_THRESH_DEFAULT;
1056 pMac->roam.configParam.HeartbeatThresh24 = 40;
1057 pMac->roam.configParam.HeartbeatThresh50 = 40;
1058 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
1059 pMac->roam.configParam.Is11dSupportEnabledOriginal = eANI_BOOLEAN_FALSE;
1060 pMac->roam.configParam.Is11eSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001061 pMac->roam.configParam.Is11hSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001062 pMac->roam.configParam.RTSThreshold = 2346;
1063 pMac->roam.configParam.shortSlotTime = eANI_BOOLEAN_TRUE;
1064 pMac->roam.configParam.WMMSupportMode = eCsrRoamWmmAuto;
1065 pMac->roam.configParam.ProprietaryRatesEnabled = eANI_BOOLEAN_TRUE;
1066 pMac->roam.configParam.TxRate = eCSR_TX_RATE_AUTO;
1067 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1068 pMac->roam.configParam.scanAgeTimeNCNPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_NO_PS;
1069 pMac->roam.configParam.scanAgeTimeNCPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_W_PS;
1070 pMac->roam.configParam.scanAgeTimeCNPS = CSR_SCAN_AGING_TIME_CONNECT_NO_PS;
1071 pMac->roam.configParam.scanAgeTimeCPS = CSR_SCAN_AGING_TIME_CONNECT_W_PS;
1072 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
1073 {
1074 pMac->roam.configParam.BssPreferValue[i] = i;
1075 }
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001076 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, CSR_DEFAULT_RSSI_DB_GAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07001077 pMac->roam.configParam.nRoamingTime = CSR_DEFAULT_ROAMING_TIME;
1078 pMac->roam.configParam.fEnforce11dChannels = eANI_BOOLEAN_FALSE;
1079 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001080 pMac->roam.configParam.fEnforceCountryCodeMatch = eANI_BOOLEAN_FALSE;
1081 pMac->roam.configParam.fEnforceDefaultDomain = eANI_BOOLEAN_FALSE;
1082 pMac->roam.configParam.nActiveMaxChnTime = CSR_ACTIVE_MAX_CHANNEL_TIME;
1083 pMac->roam.configParam.nActiveMinChnTime = CSR_ACTIVE_MIN_CHANNEL_TIME;
1084 pMac->roam.configParam.nPassiveMaxChnTime = CSR_PASSIVE_MAX_CHANNEL_TIME;
1085 pMac->roam.configParam.nPassiveMinChnTime = CSR_PASSIVE_MIN_CHANNEL_TIME;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001086 pMac->roam.configParam.nActiveMaxChnTimeBtc = CSR_ACTIVE_MAX_CHANNEL_TIME_BTC;
1087 pMac->roam.configParam.nActiveMinChnTimeBtc = CSR_ACTIVE_MIN_CHANNEL_TIME_BTC;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001088 pMac->roam.configParam.disableAggWithBtc = eANI_BOOLEAN_TRUE;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001089#ifdef WLAN_AP_STA_CONCURRENCY
1090 pMac->roam.configParam.nActiveMaxChnTimeConc = CSR_ACTIVE_MAX_CHANNEL_TIME_CONC;
1091 pMac->roam.configParam.nActiveMinChnTimeConc = CSR_ACTIVE_MIN_CHANNEL_TIME_CONC;
1092 pMac->roam.configParam.nPassiveMaxChnTimeConc = CSR_PASSIVE_MAX_CHANNEL_TIME_CONC;
1093 pMac->roam.configParam.nPassiveMinChnTimeConc = CSR_PASSIVE_MIN_CHANNEL_TIME_CONC;
1094 pMac->roam.configParam.nRestTimeConc = CSR_REST_TIME_CONC;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001095 pMac->roam.configParam.nNumStaChanCombinedConc = CSR_NUM_STA_CHAN_COMBINED_CONC;
1096 pMac->roam.configParam.nNumP2PChanCombinedConc = CSR_NUM_P2P_CHAN_COMBINED_CONC;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001097#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001098 pMac->roam.configParam.IsIdleScanEnabled = TRUE; //enable the idle scan by default
1099 pMac->roam.configParam.nTxPowerCap = CSR_MAX_TX_POWER;
1100 pMac->roam.configParam.statsReqPeriodicity = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD;
1101 pMac->roam.configParam.statsReqPeriodicityInPS = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001102#ifdef WLAN_FEATURE_VOWIFI_11R
1103 pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported = 0;
1104#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001105#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1106 pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries = 3;
1107 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold = 120;
1108 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold = 125;
1109 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = 20;
1110 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = 40;
1111 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod = 200;
1112 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels = 3;
1113 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[0] = 1;
1114 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[1] = 6;
1115 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[2] = 11;
1116 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod = 20000; //20 seconds
Srinivas Girigowdade697412013-02-14 16:31:48 -08001117 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001118#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001119#ifdef WLAN_FEATURE_11AC
1120 pMac->roam.configParam.nVhtChannelWidth = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ + 1;
1121#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001122
1123 pMac->roam.configParam.addTSWhenACMIsOff = 0;
1124 pMac->roam.configParam.fScanTwice = eANI_BOOLEAN_FALSE;
Mohit Khanna349bc392012-09-11 17:24:52 -07001125
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001126 //Remove this code once SLM_Sessionization is supported
1127 //BMPS_WORKAROUND_NOT_NEEDED
Jeff Johnsone7245742012-09-05 17:12:55 -07001128 pMac->roam.configParam.doBMPSWorkaround = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001129
Jeff Johnsone7245742012-09-05 17:12:55 -07001130}
Jeff Johnson295189b2012-06-20 16:38:30 -07001131eCsrBand csrGetCurrentBand(tHalHandle hHal)
1132{
1133 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1134 return pMac->roam.configParam.bandCapability;
1135}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001136
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001137
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001138#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001139/*
1140 This function flushes the roam scan cache
1141*/
1142eHalStatus csrFlushRoamScanRoamChannelList(tpAniSirGlobal pMac)
1143{
1144 eHalStatus status = eHAL_STATUS_SUCCESS;
1145 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1146
1147 /* Free up the memory first (if required) */
1148 if (NULL != pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
1149 {
1150 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1151 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
1152 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
1153 }
1154 return status;
1155}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001156#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001157
1158
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001159#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001160/*
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001161 This function flushes the roam scan cache
Srinivas Girigowdade697412013-02-14 16:31:48 -08001162*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001163eHalStatus csrFlushCfgBgScanRoamChannelList(tpAniSirGlobal pMac)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001164{
1165 eHalStatus status = eHAL_STATUS_SUCCESS;
1166 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1167
1168 /* Free up the memory first (if required) */
1169 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1170 {
1171 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
1172 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001173 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001174 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001175 return status;
1176}
1177
1178
1179
1180/*
1181 This function flushes the roam scan cache and creates fresh cache
1182 based on the input channel list
1183*/
1184eHalStatus csrCreateBgScanRoamChannelList(tpAniSirGlobal pMac,
1185 const tANI_U8 *pChannelList,
1186 const tANI_U8 numChannels)
1187{
1188 eHalStatus status = eHAL_STATUS_SUCCESS;
1189 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1190
Srinivas Girigowdade697412013-02-14 16:31:48 -08001191 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = numChannels;
1192
1193 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
1194 vos_mem_malloc(pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1195
1196 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1197 {
1198 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
1199 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
1200 return eHAL_STATUS_RESOURCES;
1201 }
1202
1203 /* Update the roam global structure */
Kiet Lam64c1b492013-07-12 13:56:44 +05301204 vos_mem_copy(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
1205 pChannelList,
1206 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001207 return status;
1208}
1209
1210/* This function modifies the bgscan channel list set via config ini or
1211 runtime, whenever the band changes.
1212 if the band is auto, then no operation is performed on the channel list
1213 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1214 if the band is 5G, then make sure channel list contains only 5G valid channels
1215*/
1216eHalStatus csrUpdateBgScanConfigIniChannelList(tpAniSirGlobal pMac,
1217 eCsrBand eBand)
1218{
1219 eHalStatus status = eHAL_STATUS_SUCCESS;
1220 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1221 tANI_U8 outNumChannels = 0;
1222 tANI_U8 inNumChannels = 0;
1223 tANI_U8 *inPtr = NULL;
1224 tANI_U8 i = 0;
1225 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1226
1227 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1228
1229 {
1230 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1231 "No update required for channel list "
1232 "either cfg.ini channel list is not set up or "
1233 "auto band (Band %d)", eBand);
1234 return status;
1235 }
1236
1237 inNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
1238 inPtr = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
1239 if (eCSR_BAND_24 == eBand)
1240 {
1241 for (i = 0; i < inNumChannels; i++)
1242 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001243 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
Srinivas Girigowdade697412013-02-14 16:31:48 -08001244 {
1245 ChannelList[outNumChannels++] = inPtr[i];
1246 }
1247 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001248 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001249 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001250 }
1251 else if (eCSR_BAND_5G == eBand)
1252 {
1253 for (i = 0; i < inNumChannels; i++)
1254 {
1255 /* Add 5G Non-DFS channel */
1256 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
Srinivas Girigowda56076852013-08-20 14:00:50 -07001257 csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001258 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1259 {
1260 ChannelList[outNumChannels++] = inPtr[i];
1261 }
1262 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001263 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001264 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001265 }
1266 else if (eCSR_BAND_ALL == eBand)
1267 {
1268 for (i = 0; i < inNumChannels; i++)
1269 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001270 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001271 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1272 {
1273 ChannelList[outNumChannels++] = inPtr[i];
1274 }
1275 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001276 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001277 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001278 }
1279 else
1280 {
1281 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1282 "Invalid band, No operation carried out (Band %d)", eBand);
1283 status = eHAL_STATUS_INVALID_PARAMETER;
1284 }
1285
1286 return status;
1287}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001288#endif
1289
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001290#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001291/* This function modifies the roam scan channel list as per AP neighbor
1292 report; AP neighbor report may be empty or may include only other AP
1293 channels; in any case, we merge the channel list with the learned occupied
1294 channels list.
1295 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1296 if the band is 5G, then make sure channel list contains only 5G valid channels
1297*/
1298eHalStatus csrCreateRoamScanChannelList(tpAniSirGlobal pMac,
1299 tANI_U8 *pChannelList,
1300 tANI_U8 numChannels,
1301 const eCsrBand eBand)
1302{
1303 eHalStatus status = eHAL_STATUS_SUCCESS;
1304 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1305 tANI_U8 outNumChannels = 0;
1306 tANI_U8 inNumChannels = numChannels;
1307 tANI_U8 *inPtr = pChannelList;
1308 tANI_U8 i = 0;
1309 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1310 tANI_U8 tmpChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1311 tANI_U8 mergedOutputNumOfChannels = 0;
1312 tpCsrChannelInfo currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
1313
1314 /* Create a Union of occupied channel list learnt by the DUT along with the Neighbor
1315 * report Channels. This increases the chances of the DUT to get a candidate AP while
1316 * roaming even if the Neighbor Report is not able to provide sufficient information. */
1317 if (pMac->scan.occupiedChannels.numChannels)
1318 {
1319 csrNeighborRoamMergeChannelLists(pMac,
1320 &pMac->scan.occupiedChannels.channelList[0],
1321 pMac->scan.occupiedChannels.numChannels,
1322 inPtr,
1323 inNumChannels,
1324 &mergedOutputNumOfChannels);
1325 inNumChannels = mergedOutputNumOfChannels;
1326 }
1327
1328 if (eCSR_BAND_24 == eBand)
1329 {
1330 for (i = 0; i < inNumChannels; i++)
1331 {
1332 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
1333 {
1334 ChannelList[outNumChannels++] = inPtr[i];
1335 }
1336 }
1337 }
1338 else if (eCSR_BAND_5G == eBand)
1339 {
1340 for (i = 0; i < inNumChannels; i++)
1341 {
1342 /* Add 5G Non-DFS channel */
1343 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
1344 csrRoamIsChannelValid(pMac, inPtr[i]) &&
1345 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1346 {
1347 ChannelList[outNumChannels++] = inPtr[i];
1348 }
1349 }
1350 }
1351 else if (eCSR_BAND_ALL == eBand)
1352 {
1353 for (i = 0; i < inNumChannels; i++)
1354 {
1355 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
1356 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1357 {
1358 ChannelList[outNumChannels++] = inPtr[i];
1359 }
1360 }
1361 }
1362 else
1363 {
1364 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1365 "Invalid band, No operation carried out (Band %d)", eBand);
1366 return eHAL_STATUS_INVALID_PARAMETER;
1367 }
1368
1369 /* if roaming within band is enabled, then select only the
1370 in band channels .
1371 This is required only if the band capability is set to ALL,
1372 E.g., if band capability is only 2.4G then all the channels in the
1373 list are already filtered for 2.4G channels, hence ignore this check*/
1374
1375 if ((eCSR_BAND_ALL == eBand) && CSR_IS_ROAM_INTRA_BAND_ENABLED(pMac))
1376 {
1377 csrNeighborRoamChannelsFilterByCurrentBand(
1378 pMac,
1379 ChannelList,
1380 outNumChannels,
1381 tmpChannelList,
1382 &outNumChannels);
Kiet Lamf2f201e2013-11-16 21:24:16 +05301383 vos_mem_copy(ChannelList,
1384 tmpChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001385 }
1386
1387 /* Prepare final roam scan channel list */
1388 if(outNumChannels)
1389 {
1390 /* Clear the channel list first */
1391 if (NULL != currChannelListInfo->ChannelList)
1392 {
1393 vos_mem_free(currChannelListInfo->ChannelList);
1394 currChannelListInfo->ChannelList = NULL;
1395 currChannelListInfo->numOfChannels = 0;
1396 }
1397
1398 currChannelListInfo->ChannelList = vos_mem_malloc(outNumChannels * sizeof(tANI_U8));
1399 if (NULL == currChannelListInfo->ChannelList)
1400 {
1401 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
1402 "Failed to allocate memory for roam scan channel list");
1403 currChannelListInfo->numOfChannels = 0;
1404 return VOS_STATUS_E_RESOURCES;
1405 }
Kiet Lamf2f201e2013-11-16 21:24:16 +05301406 vos_mem_copy(currChannelListInfo->ChannelList,
1407 ChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001408 }
1409 return status;
1410}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001411#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001412
Jeff Johnson295189b2012-06-20 16:38:30 -07001413eHalStatus csrSetBand(tHalHandle hHal, eCsrBand eBand)
1414{
1415 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1416 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001417 if (CSR_IS_PHY_MODE_A_ONLY(pMac) &&
1418 (eBand == eCSR_BAND_24))
1419 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001420 /* DOT11 mode configured to 11a only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001421 request to change the band to 2.4 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001422 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001423 "failed to set band cfg80211 = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001424 pMac->roam.configParam.uCfgDot11Mode, eBand);
1425 return eHAL_STATUS_INVALID_PARAMETER;
1426 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001427 if ((CSR_IS_PHY_MODE_B_ONLY(pMac) ||
1428 CSR_IS_PHY_MODE_G_ONLY(pMac)) &&
1429 (eBand == eCSR_BAND_5G))
1430 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001431 /* DOT11 mode configured to 11b/11g only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001432 request to change the band to 5 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001433 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001434 "failed to set band dot11mode = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001435 pMac->roam.configParam.uCfgDot11Mode, eBand);
1436 return eHAL_STATUS_INVALID_PARAMETER;
1437 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001438 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001439 "Band changed to %u (0 - ALL, 1 - 2.4 GHZ, 2 - 5GHZ)", eBand);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001440 pMac->roam.configParam.eBand = eBand;
1441 pMac->roam.configParam.bandCapability = eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001442 csrScanGetSupportedChannels( pMac );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001443#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -08001444 if (!csrRoamIsRoamOffloadScanEnabled(pMac))
1445 csrUpdateBgScanConfigIniChannelList( pMac, eBand );
Srinivas Girigowdade697412013-02-14 16:31:48 -08001446#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001447 status = csrInitGetChannels( pMac );
1448 if (eHAL_STATUS_SUCCESS == status)
1449 csrInitChannelList( hHal );
1450 return status;
1451}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001452
1453
Jeff Johnsone7245742012-09-05 17:12:55 -07001454/* The funcns csrConvertCBIniValueToPhyCBState and csrConvertPhyCBStateToIniValue have been
1455 * introduced to convert the ini value to the ENUM used in csr and MAC for CB state
1456 * Ideally we should have kept the ini value and enum value same and representing the same
1457 * cb values as in 11n standard i.e.
1458 * Set to 1 (SCA) if the secondary channel is above the primary channel
1459 * Set to 3 (SCB) if the secondary channel is below the primary channel
1460 * Set to 0 (SCN) if no secondary channel is present
1461 * However, since our driver is already distributed we will keep the ini definition as it is which is:
1462 * 0 - secondary none
1463 * 1 - secondary LOW
1464 * 2 - secondary HIGH
1465 * and convert to enum value used within the driver in csrChangeDefaultConfigParam using this funcn
1466 * The enum values are as follows:
1467 * PHY_SINGLE_CHANNEL_CENTERED = 0
1468 * PHY_DOUBLE_CHANNEL_LOW_PRIMARY = 1
1469 * PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
1470 */
1471ePhyChanBondState csrConvertCBIniValueToPhyCBState(v_U32_t cbIniValue)
1472{
1473
1474 ePhyChanBondState phyCbState;
1475 switch (cbIniValue) {
1476 // secondary none
1477 case 0:
1478 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1479 break;
1480 // secondary LOW
1481 case 1:
1482 phyCbState = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1483 break;
1484 // secondary HIGH
1485 case 2:
1486 phyCbState = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1487 break;
1488#ifdef WLAN_FEATURE_11AC
1489 case 3:
1490 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
1491 break;
1492 case 4:
1493 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1494 break;
1495 case 5:
1496 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1497 break;
1498 case 6:
1499 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
1500 break;
1501 case 7:
1502 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
1503 break;
1504 case 8:
1505 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
1506 break;
1507 case 9:
1508 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
1509 break;
1510#endif
1511 default:
1512 // If an invalid value is passed, disable CHANNEL BONDING
1513 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1514 break;
1515 }
1516 return phyCbState;
1517}
1518
1519v_U32_t csrConvertPhyCBStateToIniValue(ePhyChanBondState phyCbState)
1520{
1521
1522 v_U32_t cbIniValue;
1523 switch (phyCbState) {
1524 // secondary none
1525 case PHY_SINGLE_CHANNEL_CENTERED:
1526 cbIniValue = 0;
1527 break;
1528 // secondary LOW
1529 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
1530 cbIniValue = 1;
1531 break;
1532 // secondary HIGH
1533 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
1534 cbIniValue = 2;
1535 break;
1536#ifdef WLAN_FEATURE_11AC
1537 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1538 cbIniValue = 3;
1539 break;
1540 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
1541 cbIniValue = 4;
1542 break;
1543 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1544 cbIniValue = 5;
1545 break;
1546 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
1547 cbIniValue = 6;
1548 break;
1549 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
1550 cbIniValue = 7;
1551 break;
1552 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
1553 cbIniValue = 8;
1554 break;
1555 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
1556 cbIniValue = 9;
1557 break;
1558#endif
1559 default:
1560 // return some invalid value
1561 cbIniValue = 10;
1562 break;
1563 }
1564 return cbIniValue;
1565}
Jeff Johnson295189b2012-06-20 16:38:30 -07001566
1567eHalStatus csrChangeDefaultConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1568{
1569 eHalStatus status = eHAL_STATUS_SUCCESS;
1570
1571 if(pParam)
1572 {
1573 pMac->roam.configParam.WMMSupportMode = pParam->WMMSupportMode;
1574 pMac->roam.configParam.Is11eSupportEnabled = pParam->Is11eSupportEnabled;
1575 pMac->roam.configParam.FragmentationThreshold = pParam->FragmentationThreshold;
1576 pMac->roam.configParam.Is11dSupportEnabled = pParam->Is11dSupportEnabled;
1577 pMac->roam.configParam.Is11dSupportEnabledOriginal = pParam->Is11dSupportEnabled;
1578 pMac->roam.configParam.Is11hSupportEnabled = pParam->Is11hSupportEnabled;
1579
1580 pMac->roam.configParam.fenableMCCMode = pParam->fEnableMCCMode;
Mohit Khanna7ed53f02012-09-11 17:52:10 -07001581 pMac->roam.configParam.fAllowMCCGODiffBI = pParam->fAllowMCCGODiffBI;
1582
Jeff Johnsone7245742012-09-05 17:12:55 -07001583 /* channelBondingMode5GHz plays a dual role right now
1584 * 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
1585 * This is how channelBondingMode5GHz works now and this is kept intact to avoid any cfg.ini change
1586 */
1587 if (pParam->channelBondingMode24GHz > MAX_CB_VALUE_IN_INI)
1588 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001589 smsLog( pMac, LOGW, "Invalid CB value from ini in 2.4GHz band %d, CB DISABLED", pParam->channelBondingMode24GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001590 }
1591 pMac->roam.configParam.channelBondingMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode24GHz);
1592 if (pParam->channelBondingMode5GHz > MAX_CB_VALUE_IN_INI)
1593 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001594 smsLog( pMac, LOGW, "Invalid CB value from ini in 5GHz band %d, CB DISABLED", pParam->channelBondingMode5GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001595 }
1596 pMac->roam.configParam.channelBondingMode5GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001597 pMac->roam.configParam.RTSThreshold = pParam->RTSThreshold;
1598 pMac->roam.configParam.phyMode = pParam->phyMode;
1599 pMac->roam.configParam.shortSlotTime = pParam->shortSlotTime;
1600 pMac->roam.configParam.HeartbeatThresh24 = pParam->HeartbeatThresh24;
1601 pMac->roam.configParam.HeartbeatThresh50 = pParam->HeartbeatThresh50;
1602 pMac->roam.configParam.ProprietaryRatesEnabled = pParam->ProprietaryRatesEnabled;
1603 pMac->roam.configParam.TxRate = pParam->TxRate;
1604 pMac->roam.configParam.AdHocChannel24 = pParam->AdHocChannel24;
1605 pMac->roam.configParam.AdHocChannel5G = pParam->AdHocChannel5G;
1606 pMac->roam.configParam.bandCapability = pParam->bandCapability;
1607 pMac->roam.configParam.cbChoice = pParam->cbChoice;
1608 pMac->roam.configParam.bgScanInterval = pParam->bgScanInterval;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001609 pMac->roam.configParam.disableAggWithBtc = pParam->disableAggWithBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001610 //if HDD passed down non zero values then only update,
1611 //otherwise keep using the defaults
c_hpothu059edb02014-03-12 21:44:28 +05301612 if (pParam->nInitialDwellTime)
1613 {
1614 pMac->roam.configParam.nInitialDwellTime =
1615 pParam->nInitialDwellTime;
1616 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001617 if (pParam->nActiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001618 {
1619 pMac->roam.configParam.nActiveMaxChnTime = pParam->nActiveMaxChnTime;
1620 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001621 if (pParam->nActiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001622 {
1623 pMac->roam.configParam.nActiveMinChnTime = pParam->nActiveMinChnTime;
1624 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001625 if (pParam->nPassiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001626 {
1627 pMac->roam.configParam.nPassiveMaxChnTime = pParam->nPassiveMaxChnTime;
1628 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001629 if (pParam->nPassiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001630 {
1631 pMac->roam.configParam.nPassiveMinChnTime = pParam->nPassiveMinChnTime;
1632 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001633 if (pParam->nActiveMaxChnTimeBtc)
1634 {
1635 pMac->roam.configParam.nActiveMaxChnTimeBtc = pParam->nActiveMaxChnTimeBtc;
1636 }
1637 if (pParam->nActiveMinChnTimeBtc)
1638 {
1639 pMac->roam.configParam.nActiveMinChnTimeBtc = pParam->nActiveMinChnTimeBtc;
1640 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001641#ifdef WLAN_AP_STA_CONCURRENCY
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001642 if (pParam->nActiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001643 {
1644 pMac->roam.configParam.nActiveMaxChnTimeConc = pParam->nActiveMaxChnTimeConc;
1645 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001646 if (pParam->nActiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001647 {
1648 pMac->roam.configParam.nActiveMinChnTimeConc = pParam->nActiveMinChnTimeConc;
1649 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001650 if (pParam->nPassiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001651 {
1652 pMac->roam.configParam.nPassiveMaxChnTimeConc = pParam->nPassiveMaxChnTimeConc;
1653 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001654 if (pParam->nPassiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001655 {
1656 pMac->roam.configParam.nPassiveMinChnTimeConc = pParam->nPassiveMinChnTimeConc;
1657 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001658 if (pParam->nRestTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001659 {
1660 pMac->roam.configParam.nRestTimeConc = pParam->nRestTimeConc;
1661 }
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001662 if (pParam->nNumStaChanCombinedConc)
Vinay Malekal05fdc812012-12-17 13:04:30 -08001663 {
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001664 pMac->roam.configParam.nNumStaChanCombinedConc = pParam->nNumStaChanCombinedConc;
1665 }
1666 if (pParam->nNumP2PChanCombinedConc)
1667 {
1668 pMac->roam.configParam.nNumP2PChanCombinedConc = pParam->nNumP2PChanCombinedConc;
Vinay Malekal05fdc812012-12-17 13:04:30 -08001669 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001670#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001671 //if upper layer wants to disable idle scan altogether set it to 0
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001672 if (pParam->impsSleepTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001673 {
1674 //Change the unit from second to microsecond
1675 tANI_U32 impsSleepTime = pParam->impsSleepTime * PAL_TIMER_TO_SEC_UNIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07001676 if(CSR_IDLE_SCAN_NO_PS_INTERVAL_MIN <= impsSleepTime)
1677 {
1678 pMac->roam.configParam.impsSleepTime = impsSleepTime;
1679 }
1680 else
1681 {
1682 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1683 }
1684 }
1685 else
1686 {
1687 pMac->roam.configParam.impsSleepTime = 0;
1688 }
1689 pMac->roam.configParam.eBand = pParam->eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001690 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(NULL, pMac->roam.configParam.phyMode,
1691 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07001692 //if HDD passed down non zero values for age params, then only update,
1693 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001694 if (pParam->nScanResultAgeCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07001695 {
1696 pMac->roam.configParam.agingCount = pParam->nScanResultAgeCount;
1697 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001698 if(pParam->scanAgeTimeNCNPS)
1699 {
1700 pMac->roam.configParam.scanAgeTimeNCNPS = pParam->scanAgeTimeNCNPS;
1701 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001702 if(pParam->scanAgeTimeNCPS)
1703 {
1704 pMac->roam.configParam.scanAgeTimeNCPS = pParam->scanAgeTimeNCPS;
1705 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001706 if(pParam->scanAgeTimeCNPS)
1707 {
1708 pMac->roam.configParam.scanAgeTimeCNPS = pParam->scanAgeTimeCNPS;
1709 }
1710 if(pParam->scanAgeTimeCPS)
1711 {
1712 pMac->roam.configParam.scanAgeTimeCPS = pParam->scanAgeTimeCPS;
1713 }
c_hpothu0d5a7352014-03-22 12:30:25 +05301714 if (pParam->initialScanSkipDFSCh)
1715 {
1716 pMac->roam.configParam.initialScanSkipDFSCh =
1717 pParam->initialScanSkipDFSCh;
1718 }
1719
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001720 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, pParam->bCatRssiOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07001721 pMac->roam.configParam.nRoamingTime = pParam->nRoamingTime;
1722 pMac->roam.configParam.fEnforce11dChannels = pParam->fEnforce11dChannels;
1723 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = pParam->fSupplicantCountryCodeHasPriority;
1724 pMac->roam.configParam.fEnforceCountryCodeMatch = pParam->fEnforceCountryCodeMatch;
1725 pMac->roam.configParam.fEnforceDefaultDomain = pParam->fEnforceDefaultDomain;
Jeff Johnson295189b2012-06-20 16:38:30 -07001726 pMac->roam.configParam.vccRssiThreshold = pParam->vccRssiThreshold;
1727 pMac->roam.configParam.vccUlMacLossThreshold = pParam->vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001728 pMac->roam.configParam.IsIdleScanEnabled = pParam->IsIdleScanEnabled;
1729 pMac->roam.configParam.statsReqPeriodicity = pParam->statsReqPeriodicity;
1730 pMac->roam.configParam.statsReqPeriodicityInPS = pParam->statsReqPeriodicityInPS;
1731 //Assign this before calling CsrInit11dInfo
1732 pMac->roam.configParam.nTxPowerCap = pParam->nTxPowerCap;
Jeff Johnson295189b2012-06-20 16:38:30 -07001733 if( csrIs11dSupported( pMac ) )
1734 {
1735 status = CsrInit11dInfo(pMac, &pParam->Csr11dinfo);
1736 }
1737 else
1738 {
1739 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
1740 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001741
1742 /* Initialize the power + channel information if 11h is enabled.
1743 If 11d is enabled this information has already been initialized */
1744 if( csrIs11hSupported( pMac ) && !csrIs11dSupported( pMac ) )
1745 {
1746 csrInitChannelPowerList(pMac, &pParam->Csr11dinfo);
1747 }
1748
1749
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05301750#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05301751 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
1752 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001753 smsLog( pMac, LOG1, "IsFTResourceReqSupp = %d", pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07001754#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001755#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001756 pMac->roam.configParam.isFastTransitionEnabled = pParam->isFastTransitionEnabled;
Jeff Johnson43971f52012-07-17 12:26:56 -07001757 pMac->roam.configParam.RoamRssiDiff = pParam->RoamRssiDiff;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001758 pMac->roam.configParam.nImmediateRoamRssiDiff = pParam->nImmediateRoamRssiDiff;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001759 smsLog( pMac, LOG1, "nImmediateRoamRssiDiff = %d",
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001760 pMac->roam.configParam.nImmediateRoamRssiDiff );
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08001761 pMac->roam.configParam.nRoamPrefer5GHz = pParam->nRoamPrefer5GHz;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07001762 pMac->roam.configParam.nRoamIntraBand = pParam->nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07001763 pMac->roam.configParam.isWESModeEnabled = pParam->isWESModeEnabled;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001764 pMac->roam.configParam.nProbes = pParam->nProbes;
1765 pMac->roam.configParam.nRoamScanHomeAwayTime = pParam->nRoamScanHomeAwayTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001766#endif
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001767#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1768 pMac->roam.configParam.isRoamOffloadScanEnabled = pParam->isRoamOffloadScanEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001769 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled = pParam->bFastRoamInConIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001770#endif
1771#ifdef FEATURE_WLAN_LFR
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001772 pMac->roam.configParam.isFastRoamIniFeatureEnabled = pParam->isFastRoamIniFeatureEnabled;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -08001773 pMac->roam.configParam.MAWCEnabled = pParam->MAWCEnabled;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001774#endif
1775
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001776#ifdef FEATURE_WLAN_ESE
1777 pMac->roam.configParam.isEseIniFeatureEnabled = pParam->isEseIniFeatureEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001778#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001779#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301780 vos_mem_copy(&pMac->roam.configParam.neighborRoamConfig,
1781 &pParam->neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001782 smsLog( pMac, LOG1, "nNeighborScanTimerPerioid = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod);
1783 smsLog( pMac, LOG1, "nNeighborReassocRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold);
1784 smsLog( pMac, LOG1, "nNeighborLookupRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold);
1785 smsLog( pMac, LOG1, "nNeighborScanMinChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime);
1786 smsLog( pMac, LOG1, "nNeighborScanMaxChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime);
1787 smsLog( pMac, LOG1, "nMaxNeighborRetries = %d", pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries);
1788 smsLog( pMac, LOG1, "nNeighborResultsRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod);
1789 smsLog( pMac, LOG1, "nEmptyScanRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07001790 {
1791 int i;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001792 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 -07001793 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1794 {
1795 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1796 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001797 }
1798#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001799 pMac->roam.configParam.addTSWhenACMIsOff = pParam->addTSWhenACMIsOff;
1800 pMac->scan.fValidateList = pParam->fValidateList;
1801 pMac->scan.fEnableBypass11d = pParam->fEnableBypass11d;
1802 pMac->scan.fEnableDFSChnlScan = pParam->fEnableDFSChnlScan;
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08001803 pMac->scan.scanResultCfgAgingTime = pParam->scanCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001804 pMac->roam.configParam.fScanTwice = pParam->fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001805 pMac->scan.fFirstScanOnly2GChnl = pParam->fFirstScanOnly2GChnl;
1806 /* This parameter is not available in cfg and not passed from upper layers. Instead it is initialized here
1807 * This paramtere is used in concurrency to determine if there are concurrent active sessions.
1808 * Is used as a temporary fix to disconnect all active sessions when BMPS enabled so the active session if Infra STA
1809 * will automatically connect back and resume BMPS since resume BMPS is not working when moving from concurrent to
1810 * single session
1811 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001812 //Remove this code once SLM_Sessionization is supported
1813 //BMPS_WORKAROUND_NOT_NEEDED
Mohit Khanna349bc392012-09-11 17:24:52 -07001814 pMac->roam.configParam.doBMPSWorkaround = 0;
1815
Jeff Johnsone7245742012-09-05 17:12:55 -07001816#ifdef WLAN_FEATURE_11AC
1817 pMac->roam.configParam.nVhtChannelWidth = pParam->nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001818 pMac->roam.configParam.txBFEnable= pParam->enableTxBF;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001819 pMac->roam.configParam.txBFCsnValue = pParam->txBFCsnValue;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07001820 pMac->roam.configParam.enableVhtFor24GHz = pParam->enableVhtFor24GHz;
Jeff Johnsone7245742012-09-05 17:12:55 -07001821#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08001822 pMac->roam.configParam.txLdpcEnable = pParam->enableTxLdpc;
krunal soni5afa96c2013-09-06 22:19:02 -07001823
1824 pMac->roam.configParam.isAmsduSupportInAMPDU = pParam->isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001825 pMac->roam.configParam.nSelect5GHzMargin = pParam->nSelect5GHzMargin;
krunal sonie9002db2013-11-25 14:24:17 -08001826 pMac->roam.configParam.isCoalesingInIBSSAllowed =
1827 pParam->isCoalesingInIBSSAllowed;
Sandeep Puligillac80f26e2014-03-11 18:36:10 +05301828 pMac->roam.configParam.allowDFSChannelRoam = pParam->allowDFSChannelRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -07001829 }
1830
1831 return status;
1832}
1833
Jeff Johnson295189b2012-06-20 16:38:30 -07001834eHalStatus csrGetConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1835{
1836 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07001837 if(pParam)
1838 {
1839 pParam->WMMSupportMode = pMac->roam.configParam.WMMSupportMode;
1840 pParam->Is11eSupportEnabled = pMac->roam.configParam.Is11eSupportEnabled;
1841 pParam->FragmentationThreshold = pMac->roam.configParam.FragmentationThreshold;
1842 pParam->Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabled;
1843 pParam->Is11dSupportEnabledOriginal = pMac->roam.configParam.Is11dSupportEnabledOriginal;
1844 pParam->Is11hSupportEnabled = pMac->roam.configParam.Is11hSupportEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07001845 pParam->channelBondingMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode24GHz);
1846 pParam->channelBondingMode5GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001847 pParam->RTSThreshold = pMac->roam.configParam.RTSThreshold;
1848 pParam->phyMode = pMac->roam.configParam.phyMode;
1849 pParam->shortSlotTime = pMac->roam.configParam.shortSlotTime;
1850 pParam->HeartbeatThresh24 = pMac->roam.configParam.HeartbeatThresh24;
1851 pParam->HeartbeatThresh50 = pMac->roam.configParam.HeartbeatThresh50;
1852 pParam->ProprietaryRatesEnabled = pMac->roam.configParam.ProprietaryRatesEnabled;
1853 pParam->TxRate = pMac->roam.configParam.TxRate;
1854 pParam->AdHocChannel24 = pMac->roam.configParam.AdHocChannel24;
1855 pParam->AdHocChannel5G = pMac->roam.configParam.AdHocChannel5G;
1856 pParam->bandCapability = pMac->roam.configParam.bandCapability;
1857 pParam->cbChoice = pMac->roam.configParam.cbChoice;
1858 pParam->bgScanInterval = pMac->roam.configParam.bgScanInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07001859 pParam->nActiveMaxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
1860 pParam->nActiveMinChnTime = pMac->roam.configParam.nActiveMinChnTime;
1861 pParam->nPassiveMaxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
1862 pParam->nPassiveMinChnTime = pMac->roam.configParam.nPassiveMinChnTime;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001863 pParam->nActiveMaxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
1864 pParam->nActiveMinChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
1865 pParam->disableAggWithBtc = pMac->roam.configParam.disableAggWithBtc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001866#ifdef WLAN_AP_STA_CONCURRENCY
1867 pParam->nActiveMaxChnTimeConc = pMac->roam.configParam.nActiveMaxChnTimeConc;
1868 pParam->nActiveMinChnTimeConc = pMac->roam.configParam.nActiveMinChnTimeConc;
1869 pParam->nPassiveMaxChnTimeConc = pMac->roam.configParam.nPassiveMaxChnTimeConc;
1870 pParam->nPassiveMinChnTimeConc = pMac->roam.configParam.nPassiveMinChnTimeConc;
1871 pParam->nRestTimeConc = pMac->roam.configParam.nRestTimeConc;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001872 pParam->nNumStaChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc;
1873 pParam->nNumP2PChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001874#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001875 //Change the unit from microsecond to second
1876 pParam->impsSleepTime = pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_SEC_UNIT;
1877 pParam->eBand = pMac->roam.configParam.eBand;
1878 pParam->nScanResultAgeCount = pMac->roam.configParam.agingCount;
1879 pParam->scanAgeTimeNCNPS = pMac->roam.configParam.scanAgeTimeNCNPS;
1880 pParam->scanAgeTimeNCPS = pMac->roam.configParam.scanAgeTimeNCPS;
1881 pParam->scanAgeTimeCNPS = pMac->roam.configParam.scanAgeTimeCNPS;
1882 pParam->scanAgeTimeCPS = pMac->roam.configParam.scanAgeTimeCPS;
1883 pParam->bCatRssiOffset = pMac->roam.configParam.bCatRssiOffset;
1884 pParam->nRoamingTime = pMac->roam.configParam.nRoamingTime;
1885 pParam->fEnforce11dChannels = pMac->roam.configParam.fEnforce11dChannels;
1886 pParam->fSupplicantCountryCodeHasPriority = pMac->roam.configParam.fSupplicantCountryCodeHasPriority;
1887 pParam->fEnforceCountryCodeMatch = pMac->roam.configParam.fEnforceCountryCodeMatch;
1888 pParam->fEnforceDefaultDomain = pMac->roam.configParam.fEnforceDefaultDomain;
1889 pParam->vccRssiThreshold = pMac->roam.configParam.vccRssiThreshold;
1890 pParam->vccUlMacLossThreshold = pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001891 pParam->IsIdleScanEnabled = pMac->roam.configParam.IsIdleScanEnabled;
1892 pParam->nTxPowerCap = pMac->roam.configParam.nTxPowerCap;
1893 pParam->statsReqPeriodicity = pMac->roam.configParam.statsReqPeriodicity;
1894 pParam->statsReqPeriodicityInPS = pMac->roam.configParam.statsReqPeriodicityInPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001895 pParam->addTSWhenACMIsOff = pMac->roam.configParam.addTSWhenACMIsOff;
1896 pParam->fValidateList = pMac->roam.configParam.fValidateList;
1897 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
1898 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
1899 pParam->fScanTwice = pMac->roam.configParam.fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001900 pParam->fFirstScanOnly2GChnl = pMac->scan.fFirstScanOnly2GChnl;
Madan Mohan Koyyalamudied419512012-11-29 15:53:46 -08001901 pParam->fEnableMCCMode = pMac->roam.configParam.fenableMCCMode;
Madan Mohan Koyyalamudi057bd802012-11-29 16:02:39 -08001902 pParam->fAllowMCCGODiffBI = pMac->roam.configParam.fAllowMCCGODiffBI;
Sunil Ravi39b2e532013-01-20 23:45:53 -08001903 pParam->scanCfgAgingTime = pMac->scan.scanResultCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001904
1905#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301906 vos_mem_copy(&pParam->neighborRoamConfig,
1907 &pMac->roam.configParam.neighborRoamConfig,
1908 sizeof(tCsrNeighborRoamConfigParams));
Jeff Johnson295189b2012-06-20 16:38:30 -07001909#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001910#ifdef WLAN_FEATURE_11AC
1911 pParam->nVhtChannelWidth = pMac->roam.configParam.nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001912 pParam->enableTxBF = pMac->roam.configParam.txBFEnable;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001913 pParam->txBFCsnValue = pMac->roam.configParam.txBFCsnValue;
Ravi Joshiacc81822013-10-10 15:30:41 -07001914 pParam->enableVhtFor24GHz = pMac->roam.configParam.enableVhtFor24GHz;
Jeff Johnsone7245742012-09-05 17:12:55 -07001915#endif
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001916#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05301917 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
1918 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001919#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001920#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001921 pParam->isFastTransitionEnabled = pMac->roam.configParam.isFastTransitionEnabled;
1922 pParam->RoamRssiDiff = pMac->roam.configParam.RoamRssiDiff;
1923 pParam->nImmediateRoamRssiDiff = pMac->roam.configParam.nImmediateRoamRssiDiff;
1924 pParam->nRoamPrefer5GHz = pMac->roam.configParam.nRoamPrefer5GHz;
1925 pParam->nRoamIntraBand = pMac->roam.configParam.nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07001926 pParam->isWESModeEnabled = pMac->roam.configParam.isWESModeEnabled;
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -07001927 pParam->nProbes = pMac->roam.configParam.nProbes;
1928 pParam->nRoamScanHomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001929#endif
1930#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1931 pParam->isRoamOffloadScanEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
1932 pParam->bFastRoamInConIniFeatureEnabled = pMac->roam.configParam.bFastRoamInConIniFeatureEnabled;
1933#endif
1934#ifdef FEATURE_WLAN_LFR
1935 pParam->isFastRoamIniFeatureEnabled = pMac->roam.configParam.isFastRoamIniFeatureEnabled;
1936#endif
1937
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001938#ifdef FEATURE_WLAN_ESE
1939 pParam->isEseIniFeatureEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001940#endif
1941#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301942 vos_mem_copy(&pParam->neighborRoamConfig,
1943 &pMac->roam.configParam.neighborRoamConfig,
1944 sizeof(tCsrNeighborRoamConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001945 {
1946 int i;
1947 smsLog( pMac, LOG1, FL("Num of Channels in CFG Channel List: %d"), pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
1948 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1949 {
1950 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1951 }
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001952 }
1953#endif
1954
Venkata Prathyusha Kuntupallif2695c12013-04-17 15:41:23 -07001955 pParam->enableTxLdpc = pMac->roam.configParam.txLdpcEnable;
krunal soni4f087d22013-07-29 16:32:26 -07001956
krunal soni5afa96c2013-09-06 22:19:02 -07001957 pParam->isAmsduSupportInAMPDU = pMac->roam.configParam.isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001958 pParam->nSelect5GHzMargin = pMac->roam.configParam.nSelect5GHzMargin;
krunal soni5afa96c2013-09-06 22:19:02 -07001959
krunal sonie9002db2013-11-25 14:24:17 -08001960 pParam->isCoalesingInIBSSAllowed =
1961 pMac->roam.configParam.isCoalesingInIBSSAllowed;
Sandeep Puligillac80f26e2014-03-11 18:36:10 +05301962 pParam->allowDFSChannelRoam =
1963 pMac->roam.configParam.allowDFSChannelRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -07001964 csrSetChannels(pMac, pParam);
1965
1966 status = eHAL_STATUS_SUCCESS;
1967 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001968 return (status);
1969}
1970
Jeff Johnson295189b2012-06-20 16:38:30 -07001971eHalStatus csrSetPhyMode(tHalHandle hHal, tANI_U32 phyMode, eCsrBand eBand, tANI_BOOLEAN *pfRestartNeeded)
1972{
1973 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
1974 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1975 tANI_BOOLEAN fRestartNeeded = eANI_BOOLEAN_FALSE;
1976 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001977 do
1978 {
1979 if(eCSR_BAND_24 == eBand)
1980 {
1981 if(CSR_IS_RADIO_A_ONLY(pMac)) break;
1982 if((eCSR_DOT11_MODE_11a & phyMode) || (eCSR_DOT11_MODE_11a_ONLY & phyMode)) break;
1983 }
1984 if(eCSR_BAND_5G == eBand)
1985 {
1986 if(CSR_IS_RADIO_BG_ONLY(pMac)) break;
1987 if((eCSR_DOT11_MODE_11b & phyMode) || (eCSR_DOT11_MODE_11b_ONLY & phyMode) ||
1988 (eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11g_ONLY & phyMode)
1989 )
1990 {
1991 break;
1992 }
1993 }
1994 if((0 == phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
1995 {
1996 newPhyMode = eCSR_DOT11_MODE_TAURUS;
1997 }
1998 else if(eCSR_DOT11_MODE_AUTO & phyMode)
1999 {
2000 newPhyMode = eCSR_DOT11_MODE_AUTO;
2001 }
2002 else
2003 {
2004 //Check for dual band and higher capability first
2005 if(eCSR_DOT11_MODE_11n_ONLY & phyMode)
2006 {
2007 if(eCSR_DOT11_MODE_11n_ONLY != phyMode) break;
2008 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
2009 }
2010 else if(eCSR_DOT11_MODE_11a_ONLY & phyMode)
2011 {
2012 if(eCSR_DOT11_MODE_11a_ONLY != phyMode) break;
2013 if(eCSR_BAND_24 == eBand) break;
2014 newPhyMode = eCSR_DOT11_MODE_11a_ONLY;
2015 eBand = eCSR_BAND_5G;
2016 }
2017 else if(eCSR_DOT11_MODE_11g_ONLY & phyMode)
2018 {
2019 if(eCSR_DOT11_MODE_11g_ONLY != phyMode) break;
2020 if(eCSR_BAND_5G == eBand) break;
2021 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
2022 eBand = eCSR_BAND_24;
2023 }
2024 else if(eCSR_DOT11_MODE_11b_ONLY & phyMode)
2025 {
2026 if(eCSR_DOT11_MODE_11b_ONLY != phyMode) break;
2027 if(eCSR_BAND_5G == eBand) break;
2028 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
2029 eBand = eCSR_BAND_24;
2030 }
2031 else if(eCSR_DOT11_MODE_11n & phyMode)
2032 {
2033 newPhyMode = eCSR_DOT11_MODE_11n;
2034 }
2035 else if(eCSR_DOT11_MODE_abg & phyMode)
2036 {
2037 newPhyMode = eCSR_DOT11_MODE_abg;
2038 }
2039 else if(eCSR_DOT11_MODE_11a & phyMode)
2040 {
2041 if((eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11b & phyMode))
2042 {
2043 if(eCSR_BAND_ALL == eBand)
2044 {
2045 newPhyMode = eCSR_DOT11_MODE_abg;
2046 }
2047 else
2048 {
2049 //bad setting
2050 break;
2051 }
2052 }
2053 else
2054 {
2055 newPhyMode = eCSR_DOT11_MODE_11a;
2056 eBand = eCSR_BAND_5G;
2057 }
2058 }
2059 else if(eCSR_DOT11_MODE_11g & phyMode)
2060 {
2061 newPhyMode = eCSR_DOT11_MODE_11g;
2062 eBand = eCSR_BAND_24;
2063 }
2064 else if(eCSR_DOT11_MODE_11b & phyMode)
2065 {
2066 newPhyMode = eCSR_DOT11_MODE_11b;
2067 eBand = eCSR_BAND_24;
2068 }
2069 else
2070 {
2071 //We will never be here
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002072 smsLog( pMac, LOGE, FL(" cannot recognize the phy mode 0x%08X"), phyMode );
Jeff Johnson295189b2012-06-20 16:38:30 -07002073 newPhyMode = eCSR_DOT11_MODE_AUTO;
2074 }
2075 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002076 //Done validating
2077 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002078 //Now we need to check whether a restart is needed.
2079 if(eBand != pMac->roam.configParam.eBand)
2080 {
2081 fRestartNeeded = eANI_BOOLEAN_TRUE;
2082 break;
2083 }
2084 if(newPhyMode != pMac->roam.configParam.phyMode)
2085 {
2086 fRestartNeeded = eANI_BOOLEAN_TRUE;
2087 break;
2088 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002089 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002090 if(HAL_STATUS_SUCCESS(status))
2091 {
2092 pMac->roam.configParam.eBand = eBand;
2093 pMac->roam.configParam.phyMode = newPhyMode;
2094 if(pfRestartNeeded)
2095 {
2096 *pfRestartNeeded = fRestartNeeded;
2097 }
2098 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002099 return (status);
2100}
2101
Jeff Johnson295189b2012-06-20 16:38:30 -07002102void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList )
2103{
2104 tANI_U8 Index;
2105 tANI_U8 cChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07002106 // for dual band NICs, don't need to trim the channel list....
2107 if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) )
2108 {
2109 // 2.4 GHz band operation requires the channel list to be trimmed to
2110 // the 2.4 GHz channels only...
2111 if ( CSR_IS_24_BAND_ONLY( pMac ) )
2112 {
2113 for( Index = 0, cChannels = 0; Index < pChannelList->numChannels;
2114 Index++ )
2115 {
2116 if ( CSR_IS_CHANNEL_24GHZ(pChannelList->channelList[ Index ]) )
2117 {
2118 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2119 cChannels++;
2120 }
2121 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002122 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2123 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2124 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2125 // only if we need to.
2126 //
2127 // The amount of memory to clear is the number of channesl that we trimmed
2128 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2129
2130 if ( pChannelList->numChannels > cChannels )
2131 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302132 vos_mem_set(&pChannelList->channelList[ cChannels ],
2133 sizeof( pChannelList->channelList[ 0 ] ) *
2134 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002135 }
2136
2137 pChannelList->numChannels = cChannels;
2138 }
2139 else if ( CSR_IS_5G_BAND_ONLY( pMac ) )
2140 {
2141 for ( Index = 0, cChannels = 0; Index < pChannelList->numChannels; Index++ )
2142 {
2143 if ( CSR_IS_CHANNEL_5GHZ(pChannelList->channelList[ Index ]) )
2144 {
2145 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2146 cChannels++;
2147 }
2148 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002149 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2150 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2151 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2152 // only if we need to.
2153 //
2154 // The amount of memory to clear is the number of channesl that we trimmed
2155 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2156 if ( pChannelList->numChannels > cChannels )
2157 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302158 vos_mem_set(&pChannelList->channelList[ cChannels ],
2159 sizeof( pChannelList->channelList[ 0 ] ) *
2160 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002161 }
2162
2163 pChannelList->numChannels = cChannels;
2164 }
2165 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002166}
Jeff Johnson295189b2012-06-20 16:38:30 -07002167#define INFRA_AP_DEFAULT_CHANNEL 6
2168eHalStatus csrIsValidChannel(tpAniSirGlobal pMac, tANI_U8 chnNum)
2169{
2170 tANI_U8 index= 0;
2171 eHalStatus status = eHAL_STATUS_FAILURE;
2172 for (index=0; index < pMac->scan.base20MHzChannels.numChannels ;index++)
2173 {
2174 if(pMac->scan.base20MHzChannels.channelList[ index ] == chnNum){
2175 status = eHAL_STATUS_SUCCESS;
2176 break;
2177 }
2178 }
2179 return status;
2180}
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002181
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002182
Jeff Johnson295189b2012-06-20 16:38:30 -07002183eHalStatus csrInitGetChannels(tpAniSirGlobal pMac)
2184{
2185 eHalStatus status = eHAL_STATUS_SUCCESS;
2186 tANI_U8 num20MHzChannelsFound = 0;
2187 VOS_STATUS vosStatus;
2188 tANI_U8 Index = 0;
2189 tANI_U8 num40MHzChannelsFound = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002190
Jeff Johnson295189b2012-06-20 16:38:30 -07002191
2192 //TODO: this interface changed to include the 40MHz channel list
2193 // this needs to be tied into the adapter structure somehow and referenced appropriately for CB operation
2194 // Read the scan channel list (including the power limit) from EEPROM
2195 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
2196 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
2197 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
2198 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002199 smsLog( pMac, LOGE, FL("failed to get channels "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002200 status = eHAL_STATUS_FAILURE;
2201 }
2202 else
2203 {
2204 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
2205 {
2206 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2207 }
2208 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
2209 // Move the channel list to the global data
2210 // structure -- this will be used as the scan list
2211 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
2212 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002213 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[ Index ].chanId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002214 }
2215 pMac->scan.base20MHzChannels.numChannels = num20MHzChannelsFound;
2216 if(num40MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN)
2217 {
2218 num40MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2219 }
2220 for ( Index = 0; Index < num40MHzChannelsFound; Index++)
2221 {
2222 pMac->scan.base40MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable40MHz[ Index ].chanId;
2223 }
2224 pMac->scan.base40MHzChannels.numChannels = num40MHzChannelsFound;
2225 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002226 return (status);
2227}
2228
Jeff Johnson295189b2012-06-20 16:38:30 -07002229eHalStatus csrInitChannelList( tHalHandle hHal )
2230{
2231 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2232 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002233 csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels);
2234 csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels);
Kiran4a17ebe2013-01-31 10:43:43 -08002235 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE);
2236 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002237 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002238 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnson295189b2012-06-20 16:38:30 -07002239
2240 return (status);
2241}
Jeff Johnson295189b2012-06-20 16:38:30 -07002242eHalStatus csrChangeConfigParams(tpAniSirGlobal pMac,
2243 tCsrUpdateConfigParam *pUpdateConfigParam)
2244{
2245 eHalStatus status = eHAL_STATUS_FAILURE;
2246 tCsr11dinfo *ps11dinfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002247 ps11dinfo = &pUpdateConfigParam->Csr11dinfo;
2248 status = CsrInit11dInfo(pMac, ps11dinfo);
2249 return status;
2250}
2251
Jeff Johnson295189b2012-06-20 16:38:30 -07002252static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2253{
2254 eHalStatus status = eHAL_STATUS_FAILURE;
2255 tANI_U8 index;
2256 tANI_U32 count=0;
2257 tSirMacChanInfo *pChanInfo;
2258 tSirMacChanInfo *pChanInfoStart;
2259 tANI_BOOLEAN applyConfig = TRUE;
2260
Mihir Shetebc866f62014-02-13 16:08:53 +05302261 pMac->scan.currentCountryRSSI = -128;
2262
Jeff Johnson295189b2012-06-20 16:38:30 -07002263 if(!ps11dinfo)
2264 {
2265 return (status);
2266 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002267 if ( ps11dinfo->Channels.numChannels && ( WNI_CFG_VALID_CHANNEL_LIST_LEN >= ps11dinfo->Channels.numChannels ) )
2268 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302269 pMac->scan.base20MHzChannels.numChannels = ps11dinfo->Channels.numChannels;
2270 vos_mem_copy(pMac->scan.base20MHzChannels.channelList,
2271 ps11dinfo->Channels.channelList,
2272 ps11dinfo->Channels.numChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07002273 }
2274 else
2275 {
2276 //No change
2277 return (eHAL_STATUS_SUCCESS);
2278 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002279 //legacy maintenance
Kiet Lam64c1b492013-07-12 13:56:44 +05302280
2281 vos_mem_copy(pMac->scan.countryCodeDefault, ps11dinfo->countryCode,
2282 WNI_CFG_COUNTRY_CODE_LEN);
2283
2284
Jeff Johnson295189b2012-06-20 16:38:30 -07002285 //Tush: at csropen get this initialized with default, during csr reset if this
2286 // already set with some value no need initilaize with default again
2287 if(0 == pMac->scan.countryCodeCurrent[0])
2288 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302289 vos_mem_copy(pMac->scan.countryCodeCurrent, ps11dinfo->countryCode,
2290 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002291 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002292 // need to add the max power channel list
Kiet Lam64c1b492013-07-12 13:56:44 +05302293 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2294 if (pChanInfo != NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002295 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302296 vos_mem_set(pChanInfo,
2297 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN ,
2298 0);
2299
Jeff Johnson295189b2012-06-20 16:38:30 -07002300 pChanInfoStart = pChanInfo;
Jeff Johnsone7245742012-09-05 17:12:55 -07002301 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2302 {
2303 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2304 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2305 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2306 pChanInfo++;
2307 count++;
2308 }
2309 if(count)
2310 {
2311 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2312 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302313 vos_mem_free(pChanInfoStart);
Jeff Johnsone7245742012-09-05 17:12:55 -07002314 }
2315 //Only apply them to CFG when not in STOP state. Otherwise they will be applied later
2316 if( HAL_STATUS_SUCCESS(status) )
2317 {
2318 for( index = 0; index < CSR_ROAM_SESSION_MAX; index++ )
2319 {
2320 if((CSR_IS_SESSION_VALID(pMac, index)) && CSR_IS_ROAM_STOP(pMac, index))
2321 {
2322 applyConfig = FALSE;
2323 }
2324 }
2325
2326 if(TRUE == applyConfig)
2327 {
2328 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002329 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnsone7245742012-09-05 17:12:55 -07002330 }
2331
2332 }
2333 return (status);
2334}
2335/* Initialize the Channel + Power List in the local cache and in the CFG */
2336eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2337{
2338 tANI_U8 index;
2339 tANI_U32 count=0;
2340 tSirMacChanInfo *pChanInfo;
2341 tSirMacChanInfo *pChanInfoStart;
2342
2343 if(!ps11dinfo || !pMac)
2344 {
2345 return eHAL_STATUS_FAILURE;
2346 }
2347
Kiet Lam64c1b492013-07-12 13:56:44 +05302348 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2349 if (pChanInfo != NULL)
Jeff Johnsone7245742012-09-05 17:12:55 -07002350 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302351 vos_mem_set(pChanInfo,
2352 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN,
2353 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07002354 pChanInfoStart = pChanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002355
2356 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2357 {
2358 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2359 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2360 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2361 pChanInfo++;
2362 count++;
2363 }
2364 if(count)
2365 {
2366 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2367 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302368 vos_mem_free(pChanInfoStart);
Jeff Johnson295189b2012-06-20 16:38:30 -07002369 }
2370
Jeff Johnsone7245742012-09-05 17:12:55 -07002371 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002372}
2373
2374//pCommand may be NULL
2375//Pass in sessionId in case pCommand is NULL. sessionId is not used in case pCommand is not NULL.
2376void csrRoamRemoveDuplicateCommand(tpAniSirGlobal pMac, tANI_U32 sessionId, tSmeCmd *pCommand, eCsrRoamReason eRoamReason)
2377{
2378 tListElem *pEntry, *pNextEntry;
2379 tSmeCmd *pDupCommand;
2380 tDblLinkList localList;
2381
2382 vos_mem_zero(&localList, sizeof(tDblLinkList));
2383 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
2384 {
2385 smsLog(pMac, LOGE, FL(" failed to open list"));
2386 return;
2387 }
2388 csrLLLock( &pMac->sme.smeCmdPendingList );
2389 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK );
2390 while( pEntry )
2391 {
2392 pNextEntry = csrLLNext( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
2393 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07002394 // Remove the previous command if..
2395 // - the new roam command is for the same RoamReason...
2396 // - the new roam command is a NewProfileList.
2397 // - the new roam command is a Forced Dissoc
2398 // - the new roam command is from an 802.11 OID (OID_SSID or OID_BSSID).
2399 if (
2400 (pCommand && ( pCommand->sessionId == pDupCommand->sessionId ) &&
2401 ((pCommand->command == pDupCommand->command) &&
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08002402 /* This peermac check is requried for Softap/GO scenarios
2403 * For STA scenario below OR check will suffice as pCommand will
2404 * always be NULL for STA scenarios
2405 */
2406 (vos_mem_compare(pDupCommand->u.roamCmd.peerMac, pCommand->u.roamCmd.peerMac, sizeof(v_MACADDR_t))) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002407 (pCommand->u.roamCmd.roamReason == pDupCommand->u.roamCmd.roamReason ||
2408 eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason ||
2409 eCsrHddIssued == pCommand->u.roamCmd.roamReason)))
2410 ||
2411 //below the pCommand is NULL
Jeff Johnson43971f52012-07-17 12:26:56 -07002412 ( (sessionId == pDupCommand->sessionId) &&
2413 (eSmeCommandRoam == pDupCommand->command) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002414 ((eCsrForcedDisassoc == eRoamReason) ||
2415 (eCsrHddIssued == eRoamReason))
2416 )
2417 )
2418 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002419 smsLog(pMac, LOGW, FL(" roamReason = %d"), pDupCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07002420 // Remove the 'stale' roam command from the pending list...
2421 if(csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK ))
2422 {
2423 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
2424 }
2425 }
2426 pEntry = pNextEntry;
2427 }
2428 csrLLUnlock( &pMac->sme.smeCmdPendingList );
2429
2430 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
2431 {
2432 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
2433 //Tell caller that the command is cancelled
2434 csrRoamCallCallback(pMac, pDupCommand->sessionId, NULL, pDupCommand->u.roamCmd.roamId,
2435 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
2436 csrReleaseCommandRoam(pMac, pDupCommand);
2437 }
2438 csrLLClose(&localList);
2439}
Jeff Johnson295189b2012-06-20 16:38:30 -07002440eHalStatus csrRoamCallCallback(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo,
2441 tANI_U32 roamId, eRoamCmdStatus u1, eCsrRoamResult u2)
2442{
2443 eHalStatus status = eHAL_STATUS_SUCCESS;
2444#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2445 WLAN_VOS_DIAG_EVENT_DEF(connectionStatus, vos_event_wlan_status_payload_type);
2446#endif
2447 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07002448 if( CSR_IS_SESSION_VALID( pMac, sessionId) )
2449 {
2450 pSession = CSR_GET_SESSION( pMac, sessionId );
2451 }
2452 else
2453 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002454 smsLog(pMac, LOGE, "Session ID:%d is not valid", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002455 VOS_ASSERT(0);
2456 return eHAL_STATUS_FAILURE;
2457 }
krunal soni587bf012014-02-04 12:35:11 -08002458
2459 if (eANI_BOOLEAN_FALSE == pSession->sessionActive)
2460 {
2461 smsLog(pMac, LOG1, "%s Session is not Active", __func__);
2462 return eHAL_STATUS_FAILURE;
2463 }
krunal soni7f7d2c92014-02-06 15:08:43 -08002464
krunal soni587bf012014-02-04 12:35:11 -08002465 smsLog(pMac, LOG4, "Recieved RoamCmdStatus %d with Roam Result %d", u1, u2);
2466
krunal soni7f7d2c92014-02-06 15:08:43 -08002467 if(eCSR_ROAM_ASSOCIATION_COMPLETION == u1 && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002468 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002469 smsLog(pMac, LOGW, " Assoc complete result = %d statusCode = %d reasonCode = %d", u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002470 }
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07002471 if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED) && (pSession->bRefAssocStartCnt)) {
2472 /*
2473 * Decrement bRefAssocStartCnt for FT reassoc failure.
2474 * Reason: For FT reassoc failures, we first call
2475 * csrRoamCallCallback before notifying a failed roam
2476 * completion through csrRoamComplete. The latter in
2477 * turn calls csrRoamProcessResults which tries to
2478 * once again call csrRoamCallCallback if bRefAssocStartCnt
2479 * is non-zero. Since this is redundant for FT reassoc
2480 * failure, decrement bRefAssocStartCnt.
2481 */
2482 pSession->bRefAssocStartCnt--;
2483 }
2484
Jeff Johnson295189b2012-06-20 16:38:30 -07002485 if(NULL != pSession->callback)
2486 {
2487 if( pRoamInfo )
2488 {
2489 pRoamInfo->sessionId = (tANI_U8)sessionId;
2490 }
2491
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302492 /* avoid holding the global lock when making the roaming callback, original change came
2493 from a raised CR (CR304874). Since this callback is in HDD a potential deadlock
2494 is possible on other OS ports where the callback may need to take locks to protect
2495 HDD state
Jeff Johnson295189b2012-06-20 16:38:30 -07002496 UPDATE : revert this change but keep the comments here. Need to revisit as there are callbacks
2497 that may actually depend on the lock being held */
2498 // TODO: revisit: sme_ReleaseGlobalLock( &pMac->sme );
2499 status = pSession->callback(pSession->pContext, pRoamInfo, roamId, u1, u2);
2500 // TODO: revisit: sme_AcquireGlobalLock( &pMac->sme );
2501 }
2502 //EVENT_WLAN_STATUS: eCSR_ROAM_ASSOCIATION_COMPLETION,
2503 // eCSR_ROAM_LOSTLINK, eCSR_ROAM_DISASSOCIATED,
2504#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiet Lam64c1b492013-07-12 13:56:44 +05302505 vos_mem_set(&connectionStatus,
2506 sizeof(vos_event_wlan_status_payload_type), 0);
2507
krunal soni7f7d2c92014-02-06 15:08:43 -08002508 if((eCSR_ROAM_ASSOCIATION_COMPLETION == u1) && (eCSR_ROAM_RESULT_ASSOCIATED == u2) && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002509 {
2510 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
2511 connectionStatus.bssType = pRoamInfo->u.pConnectedProfile->BSSType;
2512 if(NULL != pRoamInfo->pBssDesc)
2513 {
2514 connectionStatus.rssi = pRoamInfo->pBssDesc->rssi * (-1);
2515 connectionStatus.channel = pRoamInfo->pBssDesc->channelId;
2516 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002517 connectionStatus.qosCapability = pRoamInfo->u.pConnectedProfile->qosConnection;
2518 connectionStatus.authType = (v_U8_t)diagAuthTypeFromCSRType(pRoamInfo->u.pConnectedProfile->AuthType);
2519 connectionStatus.encryptionType = (v_U8_t)diagEncTypeFromCSRType(pRoamInfo->u.pConnectedProfile->EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05302520 vos_mem_copy(connectionStatus.ssid,
2521 pRoamInfo->u.pConnectedProfile->SSID.ssId, 6);
2522
Jeff Johnson295189b2012-06-20 16:38:30 -07002523 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
2524 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2525 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002526 if((eCSR_ROAM_MIC_ERROR_IND == u1) || (eCSR_ROAM_RESULT_MIC_FAILURE == u2))
2527 {
2528 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2529 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
2530 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2531 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002532 if(eCSR_ROAM_RESULT_FORCED == u2)
2533 {
2534 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2535 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
2536 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2537 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002538 if(eCSR_ROAM_RESULT_DISASSOC_IND == u2)
2539 {
2540 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2541 connectionStatus.reason = eCSR_REASON_DISASSOC;
2542 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2543 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002544 if(eCSR_ROAM_RESULT_DEAUTH_IND == u2)
2545 {
2546 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2547 connectionStatus.reason = eCSR_REASON_DEAUTH;
2548 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2549 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002550#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
2551
2552 return (status);
2553}
Jeff Johnson295189b2012-06-20 16:38:30 -07002554// Returns whether handoff is currently in progress or not
2555tANI_BOOLEAN csrRoamIsHandoffInProgress(tpAniSirGlobal pMac)
2556{
2557#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2558 return csrNeighborRoamIsHandoffInProgress(pMac);
2559#else
2560 return eANI_BOOLEAN_FALSE;
2561#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002562}
Jeff Johnson295189b2012-06-20 16:38:30 -07002563eHalStatus csrRoamIssueDisassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
2564 eCsrRoamSubState NewSubstate, tANI_BOOLEAN fMICFailure )
2565{
2566 eHalStatus status = eHAL_STATUS_SUCCESS;
2567 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2568 tANI_U16 reasonCode;
2569 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002570
2571 if(!pSession)
2572 {
2573 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2574 return eHAL_STATUS_FAILURE;
2575 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002576
2577 //Restore AC weight in case we change it
2578 if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
2579 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07002580 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 -07002581 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
2582 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
2583 }
2584
2585 if ( fMICFailure )
2586 {
2587 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
2588 }
2589 else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)
2590 {
2591 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002592 }
2593 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002594 {
2595 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
2596 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002597#ifdef WLAN_FEATURE_VOWIFI_11R
2598 if ( (csrRoamIsHandoffInProgress(pMac)) &&
2599 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF))
2600 {
2601 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05302602 vos_mem_copy(&bssId,
2603 pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid,
2604 sizeof(tSirMacAddr));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002605 }
2606 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002607#endif
2608 if(pSession->pConnectBssDesc)
2609 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302610 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002611 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002612
Jeff Johnson295189b2012-06-20 16:38:30 -07002613
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05302614 smsLog(pMac, LOG2, FL("CSR Attempting to Disassociate Bssid="MAC_ADDRESS_STR
2615 " subState = %s reason=%d"),
2616 MAC_ADDR_ARRAY(bssId), macTraceGetcsrRoamSubState(NewSubstate),
2617 reasonCode);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08002618
Jeff Johnson295189b2012-06-20 16:38:30 -07002619 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2620
2621 status = csrSendMBDisassocReqMsg( pMac, sessionId, bssId, reasonCode );
2622
2623 if(HAL_STATUS_SUCCESS(status))
2624 {
2625 csrRoamLinkDown(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002626#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2627 //no need to tell QoS that we are disassociating, it will be taken care off in assoc req for HO
2628 if(eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate)
2629 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002630 //notify QoS module that disassoc happening
Jeff Johnson295189b2012-06-20 16:38:30 -07002631 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
2632 }
2633#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002634 }
2635 else
2636 {
2637 smsLog(pMac, LOGW, FL("csrSendMBDisassocReqMsg failed with status %d"), status);
2638 }
2639
Jeff Johnson295189b2012-06-20 16:38:30 -07002640 return (status);
2641}
Jeff Johnson295189b2012-06-20 16:38:30 -07002642
Jeff Johnson295189b2012-06-20 16:38:30 -07002643/* ---------------------------------------------------------------------------
2644 \fn csrRoamIssueDisassociateStaCmd
2645 \brief csr function that HDD calls to disassociate a associated station
2646 \param sessionId - session Id for Soft AP
2647 \param pPeerMacAddr - MAC of associated station to delete
2648 \param reason - reason code, be one of the tSirMacReasonCodes
2649 \return eHalStatus
2650 ---------------------------------------------------------------------------*/
2651eHalStatus csrRoamIssueDisassociateStaCmd( tpAniSirGlobal pMac,
2652 tANI_U32 sessionId,
2653 tANI_U8 *pPeerMacAddr,
2654 tANI_U32 reason)
2655{
2656 eHalStatus status = eHAL_STATUS_SUCCESS;
2657 tSmeCmd *pCommand;
2658
2659 do
2660 {
2661 pCommand = csrGetCommandBuffer( pMac );
2662 if ( !pCommand )
2663 {
2664 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2665 status = eHAL_STATUS_RESOURCES;
2666 break;
2667 }
2668 pCommand->command = eSmeCommandRoam;
2669 pCommand->sessionId = (tANI_U8)sessionId;
2670 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
2671 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2672 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2673 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2674 if( !HAL_STATUS_SUCCESS( status ) )
2675 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002676 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002677 csrReleaseCommandRoam( pMac, pCommand );
2678 }
2679 }while(0);
2680
2681 return status;
2682}
2683
2684
Jeff Johnson295189b2012-06-20 16:38:30 -07002685/* ---------------------------------------------------------------------------
2686 \fn csrRoamIssueDeauthSta
2687 \brief csr function that HDD calls to delete a associated station
2688 \param sessionId - session Id for Soft AP
2689 \param pPeerMacAddr - MAC of associated station to delete
2690 \param reason - reason code, be one of the tSirMacReasonCodes
2691 \return eHalStatus
2692 ---------------------------------------------------------------------------*/
2693eHalStatus csrRoamIssueDeauthStaCmd( tpAniSirGlobal pMac,
2694 tANI_U32 sessionId,
2695 tANI_U8 *pPeerMacAddr,
2696 tANI_U32 reason)
2697{
2698 eHalStatus status = eHAL_STATUS_SUCCESS;
2699 tSmeCmd *pCommand;
2700
2701 do
2702 {
2703 pCommand = csrGetCommandBuffer( pMac );
2704 if ( !pCommand )
2705 {
2706 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2707 status = eHAL_STATUS_RESOURCES;
2708 break;
2709 }
2710 pCommand->command = eSmeCommandRoam;
2711 pCommand->sessionId = (tANI_U8)sessionId;
2712 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
2713 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2714 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2715 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2716 if( !HAL_STATUS_SUCCESS( status ) )
2717 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002718 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002719 csrReleaseCommandRoam( pMac, pCommand );
2720 }
2721 }while(0);
2722
2723 return status;
2724}
Jeff Johnson295189b2012-06-20 16:38:30 -07002725eHalStatus
2726csrRoamIssueTkipCounterMeasures( tpAniSirGlobal pMac, tANI_U32 sessionId,
2727 tANI_BOOLEAN bEnable )
2728{
2729 eHalStatus status = eHAL_STATUS_FAILURE;
2730 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2731 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002732 if (!pSession)
2733 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002734 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002735 return (status);
2736 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002737 if (pSession->pConnectBssDesc)
2738 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302739 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002740 }
2741 else
2742 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002743 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002744 return (status);
2745 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002746 smsLog( pMac, LOG2, "CSR issuing tkip counter measures for Bssid = "MAC_ADDRESS_STR", Enable = %d",
2747 MAC_ADDR_ARRAY(bssId), bEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002748 status = csrSendMBTkipCounterMeasuresReqMsg( pMac, sessionId, bEnable, bssId );
2749 return (status);
2750}
Jeff Johnson295189b2012-06-20 16:38:30 -07002751eHalStatus
2752csrRoamGetAssociatedStas( tpAniSirGlobal pMac, tANI_U32 sessionId,
2753 VOS_MODULE_ID modId, void *pUsrContext,
2754 void *pfnSapEventCallback, v_U8_t *pAssocStasBuf )
2755{
2756 eHalStatus status = eHAL_STATUS_SUCCESS;
2757 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2758 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002759 if (!pSession)
2760 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002761 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002762 return (status);
2763 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002764 if(pSession->pConnectBssDesc)
2765 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302766 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002767 }
2768 else
2769 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002770 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002771 return (status);
2772 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002773 smsLog( pMac, LOG2, "CSR getting associated stations for Bssid = "MAC_ADDRESS_STR,
2774 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002775 status = csrSendMBGetAssociatedStasReqMsg( pMac, sessionId, modId, bssId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
2776 return (status);
2777}
Jeff Johnson295189b2012-06-20 16:38:30 -07002778eHalStatus
2779csrRoamGetWpsSessionOverlap( tpAniSirGlobal pMac, tANI_U32 sessionId,
2780 void *pUsrContext, void *pfnSapEventCallback, v_MACADDR_t pRemoveMac )
2781{
2782 eHalStatus status = eHAL_STATUS_SUCCESS;
2783 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2784 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2785
2786 if (!pSession)
2787 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002788 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002789 return (status);
2790 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002791 if(pSession->pConnectBssDesc)
2792 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302793 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002794 }
2795 else
2796 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002797 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002798 return (status);
2799 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002800 smsLog( pMac, LOG2, "CSR getting WPS Session Overlap for Bssid = "MAC_ADDRESS_STR,
2801 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002802
2803 status = csrSendMBGetWPSPBCSessions( pMac, sessionId, bssId, pUsrContext, pfnSapEventCallback, pRemoveMac);
2804
2805 return (status);
2806}
Jeff Johnson295189b2012-06-20 16:38:30 -07002807eHalStatus csrRoamIssueDeauth( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
2808{
2809 eHalStatus status = eHAL_STATUS_SUCCESS;
2810 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2811 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002812
2813 if (!pSession)
2814 {
2815 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2816 return eHAL_STATUS_FAILURE;
2817 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002818
2819 if(pSession->pConnectBssDesc)
2820 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302821 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002822 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002823 smsLog( pMac, LOG2, "CSR Attempting to Deauth Bssid= "MAC_ADDRESS_STR,
2824 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002825 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2826
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05302827 status = csrSendMBDeauthReqMsg( pMac, sessionId, bssId, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002828 if(!HAL_STATUS_SUCCESS(status))
2829 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05302830 smsLog(pMac, LOGE, FL("csrSendMBDeauthReqMsg failed with status %d Session ID: %d"
2831 MAC_ADDRESS_STR ), status, sessionId, MAC_ADDR_ARRAY(bssId));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002832 }
2833
Jeff Johnson295189b2012-06-20 16:38:30 -07002834 return (status);
2835}
2836
Jeff Johnson295189b2012-06-20 16:38:30 -07002837eHalStatus csrRoamSaveConnectedBssDesc( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDesc )
2838{
2839 eHalStatus status = eHAL_STATUS_SUCCESS;
2840 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2841 tANI_U32 size;
Jeff Johnson32d95a32012-09-10 13:15:23 -07002842
2843 if(!pSession)
2844 {
2845 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2846 return eHAL_STATUS_FAILURE;
2847 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002848
2849 // If no BSS description was found in this connection (happens with start IBSS), then
2850 // nix the BSS description that we keep around for the connected BSS) and get out...
2851 if(NULL == pBssDesc)
2852 {
2853 csrFreeConnectBssDesc(pMac, sessionId);
2854 }
2855 else
2856 {
2857 size = pBssDesc->length + sizeof( pBssDesc->length );
2858 if(NULL != pSession->pConnectBssDesc)
2859 {
2860 if(((pSession->pConnectBssDesc->length) + sizeof(pSession->pConnectBssDesc->length)) < size)
2861 {
2862 //not enough room for the new BSS, pMac->roam.pConnectBssDesc is freed inside
2863 csrFreeConnectBssDesc(pMac, sessionId);
2864 }
2865 }
2866 if(NULL == pSession->pConnectBssDesc)
2867 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302868 pSession->pConnectBssDesc = vos_mem_malloc(size);
Jeff Johnson295189b2012-06-20 16:38:30 -07002869 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302870 if (NULL == pSession->pConnectBssDesc)
2871 status = eHAL_STATUS_FAILURE;
2872 else
2873 vos_mem_copy(pSession->pConnectBssDesc, pBssDesc, size);
2874 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002875 return (status);
2876}
2877
Jeff Johnson295189b2012-06-20 16:38:30 -07002878eHalStatus csrRoamPrepareBssConfig(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2879 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
2880 tDot11fBeaconIEs *pIes)
2881{
2882 eHalStatus status = eHAL_STATUS_SUCCESS;
2883 eCsrCfgDot11Mode cfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002884 VOS_ASSERT( pIes != NULL );
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +05302885 if (pIes == NULL)
2886 return eHAL_STATUS_FAILURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002887
Jeff Johnson295189b2012-06-20 16:38:30 -07002888 do
2889 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302890 vos_mem_copy(&pBssConfig->BssCap, &pBssDesc->capabilityInfo,
2891 sizeof(tSirMacCapabilityInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07002892 //get qos
2893 pBssConfig->qosType = csrGetQoSFromBssDesc(pMac, pBssDesc, pIes);
2894 //get SSID
2895 if(pIes->SSID.present)
2896 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302897 vos_mem_copy(&pBssConfig->SSID.ssId, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07002898 pBssConfig->SSID.length = pIes->SSID.num_ssid;
2899 }
2900 else
2901 pBssConfig->SSID.length = 0;
2902 if(csrIsNULLSSID(pBssConfig->SSID.ssId, pBssConfig->SSID.length))
2903 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002904 smsLog(pMac, LOGW, " BSS desc SSID is a wildcard");
Jeff Johnson295189b2012-06-20 16:38:30 -07002905 //Return failed if profile doesn't have an SSID either.
2906 if(pProfile->SSIDs.numOfSSIDs == 0)
2907 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002908 smsLog(pMac, LOGW, " Both BSS desc and profile doesn't have SSID");
Jeff Johnson295189b2012-06-20 16:38:30 -07002909 status = eHAL_STATUS_FAILURE;
2910 break;
2911 }
2912 }
2913 if(CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
2914 {
2915 pBssConfig->eBand = eCSR_BAND_5G;
2916 }
2917 else
2918 {
2919 pBssConfig->eBand = eCSR_BAND_24;
2920 }
2921 //phymode
2922 if(csrIsPhyModeMatch( pMac, pProfile->phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes ))
2923 {
2924 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
2925 }
2926 else
2927 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002928 smsLog(pMac, LOGW, " Can not find match phy mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07002929 //force it
2930 if(eCSR_BAND_24 == pBssConfig->eBand)
2931 {
2932 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2933 }
2934 else
2935 {
2936 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2937 }
2938 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002939 //Qos
2940 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
2941 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos))
2942 {
2943 //Joining BSS is not 11n capable and WMM is disabled on client.
2944 //Disable QoS and WMM
2945 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2946 }
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302947
2948 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
Pratik Bhalgat8d461642012-11-22 16:55:42 +05302949 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC)) &&
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302950 ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP) ||
2951 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF) ||
2952 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF) ))
2953 {
2954 //Joining BSS is 11n capable and WMM is disabled on AP.
2955 //Assume all HT AP's are QOS AP's and enable WMM
2956 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2957 }
2958
Jeff Johnson295189b2012-06-20 16:38:30 -07002959 //auth type
2960 switch( pProfile->negotiatedAuthType )
2961 {
2962 default:
2963 case eCSR_AUTH_TYPE_WPA:
2964 case eCSR_AUTH_TYPE_WPA_PSK:
2965 case eCSR_AUTH_TYPE_WPA_NONE:
2966 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2967 pBssConfig->authType = eSIR_OPEN_SYSTEM;
2968 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002969 case eCSR_AUTH_TYPE_SHARED_KEY:
2970 pBssConfig->authType = eSIR_SHARED_KEY;
2971 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002972 case eCSR_AUTH_TYPE_AUTOSWITCH:
2973 pBssConfig->authType = eSIR_AUTO_SWITCH;
2974 break;
2975 }
2976 //short slot time
2977 if( eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode )
2978 {
2979 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
2980 }
2981 else
2982 {
2983 pBssConfig->uShortSlotTime = 0;
2984 }
2985 if(pBssConfig->BssCap.ibss)
2986 {
2987 //We don't support 11h on IBSS
2988 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
2989 }
2990 else
2991 {
2992 pBssConfig->f11hSupport = pMac->roam.configParam.Is11hSupportEnabled;
2993 }
2994 //power constraint
2995 pBssConfig->uPowerLimit = csrGet11hPowerConstraint(pMac, &pIes->PowerConstraints);
2996 //heartbeat
2997 if ( CSR_IS_11A_BSS( pBssDesc ) )
2998 {
2999 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3000 }
3001 else
3002 {
3003 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3004 }
3005 //Join timeout
3006 // if we find a BeaconInterval in the BssDescription, then set the Join Timeout to
Jeff Johnsone7245742012-09-05 17:12:55 -07003007 // be 10 x the BeaconInterval.
Jeff Johnson295189b2012-06-20 16:38:30 -07003008 if ( pBssDesc->beaconInterval )
3009 {
3010 //Make sure it is bigger than the minimal
Jeff Johnsone7245742012-09-05 17:12:55 -07003011 pBssConfig->uJoinTimeOut = CSR_ROAM_MAX(10 * pBssDesc->beaconInterval, CSR_JOIN_FAILURE_TIMEOUT_MIN);
Jeff Johnson295189b2012-06-20 16:38:30 -07003012 }
3013 else
3014 {
3015 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
3016 }
3017 //validate CB
3018 pBssConfig->cbMode = csrGetCBModeFromIes(pMac, pBssDesc->channelId, pIes);
Sandeep Puligilla60342762014-01-30 21:05:37 +05303019
Jeff Johnson295189b2012-06-20 16:38:30 -07003020 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003021 return (status);
3022}
3023
Jeff Johnson295189b2012-06-20 16:38:30 -07003024static eHalStatus csrRoamPrepareBssConfigFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
3025 tBssConfigParam *pBssConfig, tSirBssDescription *pBssDesc)
3026{
3027 eHalStatus status = eHAL_STATUS_SUCCESS;
3028 tANI_U8 operationChannel = 0;
3029 tANI_U8 qAPisEnabled = FALSE;
3030 //SSID
3031 pBssConfig->SSID.length = 0;
3032 if(pProfile->SSIDs.numOfSSIDs)
3033 {
3034 //only use the first one
Kiet Lam64c1b492013-07-12 13:56:44 +05303035 vos_mem_copy(&pBssConfig->SSID, &pProfile->SSIDs.SSIDList[0].SSID,
3036 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003037 }
3038 else
3039 {
3040 //SSID must present
3041 return eHAL_STATUS_FAILURE;
3042 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003043 //Settomg up the capabilities
3044 if( csrIsBssTypeIBSS(pProfile->BSSType) )
3045 {
3046 pBssConfig->BssCap.ibss = 1;
3047 }
3048 else
3049 {
3050 pBssConfig->BssCap.ess = 1;
3051 }
3052 if( eCSR_ENCRYPT_TYPE_NONE != pProfile->EncryptionType.encryptionType[0] )
3053 {
3054 pBssConfig->BssCap.privacy = 1;
3055 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003056 pBssConfig->eBand = pMac->roam.configParam.eBand;
3057 //phymode
3058 if(pProfile->ChannelInfo.ChannelList)
3059 {
3060 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3061 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003062 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, operationChannel,
3063 &pBssConfig->eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07003064 //QOS
3065 //Is this correct to always set to this //***
Jeff Johnson295189b2012-06-20 16:38:30 -07003066 if ( pBssConfig->BssCap.ess == 1 )
3067 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003068 /*For Softap case enable WMM*/
3069 if(CSR_IS_INFRA_AP(pProfile) && (eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode )){
3070 qAPisEnabled = TRUE;
3071 }
3072 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003073 if (csrRoamGetQosInfoFromBss(pMac, pBssDesc) == eHAL_STATUS_SUCCESS) {
3074 qAPisEnabled = TRUE;
3075 } else {
3076 qAPisEnabled = FALSE;
3077 }
3078 } else {
3079 qAPisEnabled = TRUE;
3080 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003081 if (( eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode && qAPisEnabled) ||
3082 (( eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode && qAPisEnabled) ||
3083 ( eCSR_CFG_DOT11_MODE_TAURUS == pBssConfig->uCfgDot11Mode ) ) //For 11n, need QoS
3084 )
3085 {
3086 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3087 } else {
3088 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3089 }
3090
3091 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08003092 switch( pProfile->AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07003093 {
3094 default:
3095 case eCSR_AUTH_TYPE_WPA:
3096 case eCSR_AUTH_TYPE_WPA_PSK:
3097 case eCSR_AUTH_TYPE_WPA_NONE:
3098 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3099 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3100 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003101 case eCSR_AUTH_TYPE_SHARED_KEY:
3102 pBssConfig->authType = eSIR_SHARED_KEY;
3103 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003104 case eCSR_AUTH_TYPE_AUTOSWITCH:
3105 pBssConfig->authType = eSIR_AUTO_SWITCH;
3106 break;
3107 }
3108 //short slot time
3109 if( WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode )
3110 {
3111 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3112 }
3113 else
3114 {
3115 pBssConfig->uShortSlotTime = 0;
3116 }
3117 //power constraint. We don't support 11h on IBSS
3118 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3119 pBssConfig->uPowerLimit = 0;
3120 //heartbeat
3121 if ( eCSR_BAND_5G == pBssConfig->eBand )
3122 {
3123 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3124 }
3125 else
3126 {
3127 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3128 }
3129 //Join timeout
3130 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07003131
Jeff Johnson295189b2012-06-20 16:38:30 -07003132 return (status);
3133}
Jeff Johnson295189b2012-06-20 16:38:30 -07003134static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc)
3135{
3136 eHalStatus status = eHAL_STATUS_FAILURE;
3137 tDot11fBeaconIEs *pIes = NULL;
3138
3139 do
3140 {
3141 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
3142 {
3143 //err msg
3144 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003145 "csrRoamGetQosInfoFromBss() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07003146 break;
3147 }
3148 //check if the AP is QAP & it supports APSD
3149 if( CSR_IS_QOS_BSS(pIes) )
3150 {
Kiet Lamb537cfb2013-11-07 12:56:49 +05303151 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07003152 }
3153 } while (0);
Kiet Lamb537cfb2013-11-07 12:56:49 +05303154
3155 if (NULL != pIes)
3156 {
3157 vos_mem_free(pIes);
3158 }
3159
Jeff Johnson295189b2012-06-20 16:38:30 -07003160 return status;
3161}
3162
Jeff Johnson295189b2012-06-20 16:38:30 -07003163void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
3164{
Jeff Johnson295189b2012-06-20 16:38:30 -07003165 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
3166 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
3167 // See !!Note: below in this function...
3168 tANI_U32 PrivacyEnabled = 0;
3169 tANI_U32 RsnEnabled = 0;
3170 tANI_U32 WepDefaultKeyId = 0;
3171 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
3172 tANI_U32 Key0Length = 0;
3173 tANI_U32 Key1Length = 0;
3174 tANI_U32 Key2Length = 0;
3175 tANI_U32 Key3Length = 0;
3176
3177 // Reserve for the biggest key
3178 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
3179 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
3180 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
3181 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
3182
3183 switch ( pProfile->negotiatedUCEncryptionType )
3184 {
3185 case eCSR_ENCRYPT_TYPE_NONE:
3186
3187 // for NO encryption, turn off Privacy and Rsn.
3188 PrivacyEnabled = 0;
3189 RsnEnabled = 0;
3190
3191 // WEP key length and Wep Default Key ID don't matter in this case....
3192
3193 // clear out the WEP keys that may be hanging around.
3194 Key0Length = 0;
3195 Key1Length = 0;
3196 Key2Length = 0;
3197 Key3Length = 0;
3198
3199 break;
3200
3201 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303202 case eCSR_ENCRYPT_TYPE_WEP40:
Jeff Johnson295189b2012-06-20 16:38:30 -07003203
3204 // Privacy is ON. NO RSN for Wep40 static key.
3205 PrivacyEnabled = 1;
3206 RsnEnabled = 0;
3207
3208 // Set the Wep default key ID.
3209 WepDefaultKeyId = pProfile->Keys.defaultIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07003210 // Wep key size if 5 bytes (40 bits).
3211 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
3212
3213 // set encryption keys in the CFG database or clear those that are not present in this profile.
3214 if ( pProfile->Keys.KeyLength[0] )
3215 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303216 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[0],
3217 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003218 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
3219 }
3220 else
3221 {
3222 Key0Length = 0;
3223 }
3224
3225 if ( pProfile->Keys.KeyLength[1] )
3226 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303227 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[1],
3228 WNI_CFG_WEP_KEY_LENGTH_5);
3229 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
Jeff Johnson295189b2012-06-20 16:38:30 -07003230 }
3231 else
3232 {
3233 Key1Length = 0;
3234 }
3235
3236 if ( pProfile->Keys.KeyLength[2] )
3237 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303238 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[2],
3239 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003240 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
3241 }
3242 else
3243 {
3244 Key2Length = 0;
3245 }
3246
3247 if ( pProfile->Keys.KeyLength[3] )
3248 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303249 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[3],
3250 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003251 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
3252 }
3253 else
3254 {
3255 Key3Length = 0;
3256 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003257 break;
3258
3259 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303260 case eCSR_ENCRYPT_TYPE_WEP104:
Jeff Johnson295189b2012-06-20 16:38:30 -07003261
3262 // Privacy is ON. NO RSN for Wep40 static key.
3263 PrivacyEnabled = 1;
3264 RsnEnabled = 0;
3265
3266 // Set the Wep default key ID.
3267 WepDefaultKeyId = pProfile->Keys.defaultIndex;
3268
3269 // Wep key size if 13 bytes (104 bits).
3270 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
3271
3272 // set encryption keys in the CFG database or clear those that are not present in this profile.
3273 if ( pProfile->Keys.KeyLength[0] )
3274 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303275 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[ 0 ],
3276 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003277 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
3278 }
3279 else
3280 {
3281 Key0Length = 0;
3282 }
3283
3284 if ( pProfile->Keys.KeyLength[1] )
3285 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303286 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[ 1 ],
3287 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003288 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
3289 }
3290 else
3291 {
3292 Key1Length = 0;
3293 }
3294
3295 if ( pProfile->Keys.KeyLength[2] )
3296 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303297 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[ 2 ],
3298 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003299 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
3300 }
3301 else
3302 {
3303 Key2Length = 0;
3304 }
3305
3306 if ( pProfile->Keys.KeyLength[3] )
3307 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303308 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[ 3 ],
3309 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003310 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
3311 }
3312 else
3313 {
3314 Key3Length = 0;
3315 }
3316
3317 break;
3318
Jeff Johnson295189b2012-06-20 16:38:30 -07003319 case eCSR_ENCRYPT_TYPE_TKIP:
3320 case eCSR_ENCRYPT_TYPE_AES:
3321#ifdef FEATURE_WLAN_WAPI
3322 case eCSR_ENCRYPT_TYPE_WPI:
3323#endif /* FEATURE_WLAN_WAPI */
3324 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
3325 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
3326 PrivacyEnabled = (0 != fPrivacy);
3327
3328 // turn on RSN enabled for WPA associations
3329 RsnEnabled = 1;
3330
3331 // WEP key length and Wep Default Key ID don't matter in this case....
3332
3333 // clear out the static WEP keys that may be hanging around.
3334 Key0Length = 0;
3335 Key1Length = 0;
3336 Key2Length = 0;
3337 Key3Length = 0;
3338
3339 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003340 default:
3341 PrivacyEnabled = 0;
3342 RsnEnabled = 0;
3343 break;
3344 }
3345
3346 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
3347 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
3348 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
3349 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
3350 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
3351 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
3352 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
3353 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
3354}
3355
Jeff Johnson295189b2012-06-20 16:38:30 -07003356static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
3357{
3358 tANI_U32 len = 0;
3359 if(pSSID->length <= WNI_CFG_SSID_LEN)
3360 {
3361 len = pSSID->length;
3362 }
3363 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
3364}
3365
Jeff Johnson295189b2012-06-20 16:38:30 -07003366eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
3367{
3368 eHalStatus status = eHAL_STATUS_SUCCESS;
3369 tANI_U32 QoSEnabled;
3370 tANI_U32 WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003371 // set the CFG enable/disable variables based on the qosType being configured...
3372 switch( qosType )
3373 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003374 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
3375 QoSEnabled = FALSE;
3376 WmeEnabled = TRUE;
3377 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003378 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
3379 QoSEnabled = FALSE;
3380 WmeEnabled = TRUE;
3381 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003382 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
3383 QoSEnabled = FALSE;
3384 WmeEnabled = TRUE;
3385 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003386 case eCSR_MEDIUM_ACCESS_11e_eDCF:
3387 QoSEnabled = TRUE;
3388 WmeEnabled = FALSE;
3389 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003390 case eCSR_MEDIUM_ACCESS_11e_HCF:
3391 QoSEnabled = TRUE;
3392 WmeEnabled = FALSE;
3393 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003394 default:
3395 case eCSR_MEDIUM_ACCESS_DCF:
3396 QoSEnabled = FALSE;
3397 WmeEnabled = FALSE;
3398 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003399 }
3400 //save the WMM setting for later use
3401 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
Sandeep Puligillaaea98a22013-12-04 13:36:32 +05303402 pMac->roam.roamSession[sessionId].fQOSConnection = (tANI_BOOLEAN)QoSEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003403 return (status);
3404}
Jeff Johnson295189b2012-06-20 16:38:30 -07003405static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
3406 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet)
3407{
3408 eHalStatus status = eHAL_STATUS_FAILURE;
3409 int i;
3410 eCsrCfgDot11Mode cfgDot11Mode;
3411 tANI_U8 *pDstRate;
Kiet Lam64c1b492013-07-12 13:56:44 +05303412 vos_mem_set(pOpRateSet, sizeof(tSirMacRateSet), 0);
3413 vos_mem_set(pExRateSet, sizeof(tSirMacRateSet), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003414 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003415
3416 if( NULL != pIes )
3417 {
3418 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003419 // Originally, we thought that for 11a networks, the 11a rates are always
3420 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3421 // appear in the Operational Rate set. Consequently, in either case, we
3422 // would blindly put the rates we support into our Operational Rate set
3423 // (including the basic rates, which we have already verified are
3424 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003425 // However, it turns out that this is not always the case. Some AP's
3426 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3427 // too. Now, we're a little more careful:
3428 pDstRate = pOpRateSet->rate;
3429 if(pIes->SuppRates.present)
3430 {
3431 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3432 {
3433 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
3434 {
3435 *pDstRate++ = pIes->SuppRates.rates[ i ];
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003436 pOpRateSet->numRates++;
Jeff Johnson295189b2012-06-20 16:38:30 -07003437 }
3438 }
3439 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003440 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3441 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3442 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3443 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3444 {
3445 // If there are Extended Rates in the beacon, we will reflect those
3446 // extended rates that we support in out Extended Operational Rate
3447 // set:
3448 pDstRate = pExRateSet->rate;
3449 if(pIes->ExtSuppRates.present)
3450 {
3451 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3452 {
3453 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) )
3454 {
3455 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3456 pExRateSet->numRates++;
3457 }
3458 }
3459 }
3460 }
3461 }//Parsing BSSDesc
3462 else
3463 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003464 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003465 }
3466 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
3467 return status;
3468}
3469
3470static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
3471 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3472{
3473 int i;
3474 tANI_U8 *pDstRate;
3475 eCsrCfgDot11Mode cfgDot11Mode;
3476 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3477 tANI_U32 OperationalRatesLength = 0;
3478 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3479 tANI_U32 ExtendedOperationalRatesLength = 0;
3480 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3481 tANI_U32 ProprietaryOperationalRatesLength = 0;
3482 tANI_U32 PropRatesEnable = 0;
3483 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
3484 tANI_U32 MCSRateLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003485 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003486 if( NULL != pIes )
3487 {
3488 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003489 // Originally, we thought that for 11a networks, the 11a rates are always
3490 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3491 // appear in the Operational Rate set. Consequently, in either case, we
3492 // would blindly put the rates we support into our Operational Rate set
3493 // (including the basic rates, which we have already verified are
3494 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003495 // However, it turns out that this is not always the case. Some AP's
3496 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3497 // too. Now, we're a little more careful:
3498 pDstRate = OperationalRates;
3499 if(pIes->SuppRates.present)
3500 {
3501 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3502 {
3503 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
3504 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
3505 {
3506 *pDstRate++ = pIes->SuppRates.rates[ i ];
3507 OperationalRatesLength++;
3508 }
3509 }
3510 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003511 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3512 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3513 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3514 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3515 {
3516 // If there are Extended Rates in the beacon, we will reflect those
3517 // extended rates that we support in out Extended Operational Rate
3518 // set:
3519 pDstRate = ExtendedOperationalRates;
3520 if(pIes->ExtSuppRates.present)
3521 {
3522 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3523 {
3524 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
3525 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
3526 {
3527 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3528 ExtendedOperationalRatesLength++;
3529 }
3530 }
3531 }
3532 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003533 // Enable proprietary MAC features if peer node is Airgo node and STA
3534 // user wants to use them
3535 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
3536 {
3537 PropRatesEnable = 1;
3538 }
3539 else
3540 {
3541 PropRatesEnable = 0;
3542 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003543 // For ANI network companions, we need to populate the proprietary rate
3544 // set with any proprietary rates we found in the beacon, only if user
3545 // allows them...
3546 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
3547 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
3548 {
3549 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
3550 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
3551 {
3552 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
3553 }
Kiet Lam64c1b492013-07-12 13:56:44 +05303554 vos_mem_copy(ProprietaryOperationalRates,
3555 pIes->Airgo.PropSuppRates.rates,
3556 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003557 }
3558 else {
3559 // No proprietary modes...
3560 ProprietaryOperationalRatesLength = 0;
3561 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003562 /* Get MCS Rate */
3563 pDstRate = MCSRateIdxSet;
3564 if ( pIes->HTCaps.present )
3565 {
3566 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
3567 {
3568 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
3569 {
3570 MCSRateLength++;
3571 *pDstRate++ = i;
3572 }
3573 }
3574 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003575 // Set the operational rate set CFG variables...
3576 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3577 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3578 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3579 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3580 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3581 ProprietaryOperationalRates,
3582 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3583 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
3584 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
3585 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
3586 }//Parsing BSSDesc
3587 else
3588 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003589 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003590 }
3591}
3592
Jeff Johnson295189b2012-06-20 16:38:30 -07003593static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
3594 tCsrRoamProfile *pProfile )
3595{
3596 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
3597 { 8,
3598 { SIR_MAC_RATE_6,
3599 SIR_MAC_RATE_9,
3600 SIR_MAC_RATE_12,
3601 SIR_MAC_RATE_18,
3602 SIR_MAC_RATE_24,
3603 SIR_MAC_RATE_36,
3604 SIR_MAC_RATE_48,
3605 SIR_MAC_RATE_54 } } };
Jeff Johnson295189b2012-06-20 16:38:30 -07003606 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
3607 { 4,
3608 { SIR_MAC_RATE_1,
3609 SIR_MAC_RATE_2,
3610 SIR_MAC_RATE_5_5,
3611 SIR_MAC_RATE_11 } } };
3612
3613
3614 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
3615 { SIR_MAC_RATE_72,
3616 SIR_MAC_RATE_96,
3617 SIR_MAC_RATE_108 } };
3618 eCsrCfgDot11Mode cfgDot11Mode;
3619 eCsrBand eBand;
3620 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3621 tANI_U32 OperationalRatesLength = 0;
3622 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3623 tANI_U32 ExtendedOperationalRatesLength = 0;
3624 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3625 tANI_U32 ProprietaryOperationalRatesLength = 0;
3626 tANI_U32 PropRatesEnable = 0;
3627 tANI_U8 operationChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003628 if(pProfile->ChannelInfo.ChannelList)
3629 {
3630 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3631 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003632 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -07003633 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
3634 // networks, the 11b rates appear in the Operational Rate set. In either case,
3635 // we can blindly put the rates we support into our Operational Rate set
3636 // (including the basic rates, which we have already verified are supported
3637 // earlier in the roaming decision).
3638 if ( eCSR_BAND_5G == eBand )
3639 {
3640 // 11a rates into the Operational Rate Set.
3641 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3642 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303643 vos_mem_copy(OperationalRates,
3644 DefaultSupportedRates11a.supportedRateSet.rate,
3645 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003646
3647 // Nothing in the Extended rate set.
3648 ExtendedOperationalRatesLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003649 // populate proprietary rates if user allows them
3650 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3651 {
3652 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3653 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303654 vos_mem_copy(ProprietaryOperationalRates,
3655 DefaultSupportedPropRates.propRate,
3656 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003657 }
3658 else
3659 {
3660 // No proprietary modes
3661 ProprietaryOperationalRatesLength = 0;
3662 }
3663 }
3664 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
3665 {
3666 // 11b rates into the Operational Rate Set.
3667 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3668 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303669 vos_mem_copy(OperationalRates,
3670 DefaultSupportedRates11b.supportedRateSet.rate,
3671 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003672 // Nothing in the Extended rate set.
3673 ExtendedOperationalRatesLength = 0;
3674 // No proprietary modes
3675 ProprietaryOperationalRatesLength = 0;
3676 }
3677 else
3678 {
3679 // 11G
3680
3681 // 11b rates into the Operational Rate Set.
3682 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3683 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303684 vos_mem_copy(OperationalRates,
3685 DefaultSupportedRates11b.supportedRateSet.rate,
3686 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003687
3688 // 11a rates go in the Extended rate set.
3689 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3690 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303691 vos_mem_copy(ExtendedOperationalRates,
3692 DefaultSupportedRates11a.supportedRateSet.rate,
3693 ExtendedOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003694
3695 // populate proprietary rates if user allows them
3696 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3697 {
3698 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3699 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303700 vos_mem_copy(ProprietaryOperationalRates,
3701 DefaultSupportedPropRates.propRate,
3702 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003703 }
3704 else
3705 {
3706 // No proprietary modes
3707 ProprietaryOperationalRatesLength = 0;
3708 }
3709 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003710 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
3711 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
3712 {
3713 PropRatesEnable = 1;
3714 }
3715 else
3716 {
3717 PropRatesEnable = 0;
3718 }
3719
3720 // Set the operational rate set CFG variables...
3721 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3722 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3723 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3724 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3725 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3726 ProprietaryOperationalRates,
3727 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3728 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003729}
Jeff Johnson295189b2012-06-20 16:38:30 -07003730void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
3731{
3732 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07003733
Jeff Johnson295189b2012-06-20 16:38:30 -07003734 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
3735 tANI_U32 sessionId;
3736 tSmeCmd *pCommand = NULL;
3737
3738 if(NULL == pEntry)
3739 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003740 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07003741 return;
3742 }
3743 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
3744 sessionId = pCommand->sessionId;
3745
3746 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
3747 {
3748 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
3749 }
3750}
3751
Jeff Johnson295189b2012-06-20 16:38:30 -07003752//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
3753tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
3754{
3755 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
3756 {
3757 return (WNI_CFG_PHY_MODE_11B);
3758 }
3759 else
3760 {
3761 if(eCSR_BAND_24 == band)
3762 return (WNI_CFG_PHY_MODE_11G);
3763 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003764 return (WNI_CFG_PHY_MODE_11A);
3765}
Jeff Johnson295189b2012-06-20 16:38:30 -07003766
Jeff Johnsone7245742012-09-05 17:12:55 -07003767
3768#ifdef WLAN_FEATURE_11AC
3769ePhyChanBondState csrGetHTCBStateFromVHTCBState(ePhyChanBondState aniCBMode)
3770{
3771 switch ( aniCBMode )
3772 {
3773 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
3774 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
3775 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
3776 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3777 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
3778 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
3779 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
3780 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3781 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003782 default :
Jeff Johnsone7245742012-09-05 17:12:55 -07003783 return PHY_SINGLE_CHANNEL_CENTERED;
3784 }
3785}
3786#endif
3787
Jeff Johnson295189b2012-06-20 16:38:30 -07003788//pIes may be NULL
3789eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3790 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303791 tDot11fBeaconIEs *pIes, tANI_BOOLEAN resetCountry)
Jeff Johnson295189b2012-06-20 16:38:30 -07003792{
3793 eHalStatus status = eHAL_STATUS_SUCCESS;
3794 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3795 tANI_U8 channel = 0;
3796 //Make sure we have the domain info for the BSS we try to connect to.
3797 //Do we need to worry about sequence for OSs that are not Windows??
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303798 if (pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -07003799 {
Agrawal Ashish0b6984f2014-04-05 18:35:45 +05303800 if (csrLearnCountryInformation(pMac, eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07003801 {
3802 //Make sure the 11d info from this BSSDesc can be applied
3803 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303804 if (VOS_TRUE == resetCountry)
3805 {
3806 csrApplyCountryInformation(pMac, FALSE);
3807 }
3808 else
3809 {
3810 csrApplyCountryInformation(pMac, TRUE);
3811 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003812 }
Kiran4a17ebe2013-01-31 10:43:43 -08003813 if ((csrIs11dSupported (pMac)) && pIes)
3814 {
3815 if (!pIes->Country.present)
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003816 {
Kiran4a17ebe2013-01-31 10:43:43 -08003817 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE );
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003818 }
3819 else
3820 {
3821 //Let's also update the below to make sure we don't update CC while
3822 //connected to an AP which is advertising some CC
Kiet Lamf2f201e2013-11-16 21:24:16 +05303823 vos_mem_copy(pMac->scan.currentCountryBssid,
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003824 pBssDesc->bssId, sizeof(tSirMacAddr));
3825 }
Kiran4a17ebe2013-01-31 10:43:43 -08003826 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003827 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003828 //Qos
3829 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
3830 //SSID
3831 csrSetCfgSsid(pMac, &pBssConfig->SSID );
3832 //fragment threshold
3833 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3834 //RTS threshold
3835 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3836
3837 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003838 //Auth type
3839 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
3840 //encryption type
3841 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
3842 //short slot time
3843 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003844 //11d
3845 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
3846 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
3847 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003848 /*//11h
3849 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
3850 */
3851 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
3852 //CB
Jeff Johnsone7245742012-09-05 17:12:55 -07003853
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003854 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile) || CSR_IS_IBSS(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07003855 {
3856 channel = pProfile->operationChannel;
3857 }
3858 else
3859 {
3860 if(pBssDesc)
3861 {
3862 channel = pBssDesc->channelId;
3863 }
3864 }
3865 if(0 != channel)
3866 {
Sandeep Puligilla60342762014-01-30 21:05:37 +05303867 if(CSR_IS_CHANNEL_24GHZ(channel) &&
3868 !pMac->roam.configParam.channelBondingMode24GHz &&
3869 !WDA_getFwWlanFeatCaps(HT40_OBSS_SCAN))
3870 {//On 2.4 Ghz, CB will be disabled if it is not configured through .ini
Jeff Johnson295189b2012-06-20 16:38:30 -07003871 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Sandeep Puligilla60342762014-01-30 21:05:37 +05303872 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
3873 " cbMode disabled cfgCb = %d channelBondingMode24GHz %d",
3874 __func__, cfgCb, pMac->roam.configParam.channelBondingMode24GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07003875 }
3876 else
3877 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003878 cfgCb = pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003879 }
3880 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003881#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudia0d88932012-11-13 10:51:26 -08003882 // cbMode = 1 in cfg.ini is mapped to PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
3883 // in function csrConvertCBIniValueToPhyCBState()
3884 // So, max value for cbMode in 40MHz mode is 3 (MAC\src\include\sirParams.h)
3885 if(cfgCb > PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
Jeff Johnsone7245742012-09-05 17:12:55 -07003886 {
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003887 if(!WDA_getFwWlanFeatCaps(DOT11AC)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07003888 cfgCb = csrGetHTCBStateFromVHTCBState(cfgCb);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003889 }
Sandeep Puligilla60342762014-01-30 21:05:37 +05303890 else
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003891 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003892 ccmCfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, pMac->roam.configParam.nVhtChannelWidth, NULL, eANI_BOOLEAN_FALSE);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003893 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003894 }
3895 else
3896#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003897 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
3898 //Rate
3899 //Fixed Rate
3900 if(pBssDesc)
3901 {
3902 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
3903 }
3904 else
3905 {
3906 csrSetCfgRateSetFromProfile(pMac, pProfile);
3907 }
3908 //Make this the last CFG to set. The callback will trigger a join_req
3909 //Join time out
3910 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
3911
3912 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003913 return (status);
3914}
3915
Jeff Johnson295189b2012-06-20 16:38:30 -07003916eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3917 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3918{
3919 eHalStatus status;
3920 tBssConfigParam *pBssConfig;
3921 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003922
3923 if(!pSession)
3924 {
3925 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3926 return eHAL_STATUS_FAILURE;
3927 }
3928
Kiet Lam64c1b492013-07-12 13:56:44 +05303929 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
3930 if ( NULL == pBssConfig )
3931 status = eHAL_STATUS_FAILURE;
3932 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003933 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303934 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003935 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
3936 if(HAL_STATUS_SUCCESS(status))
3937 {
3938 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003939 /* This will allow to pass cbMode during join req */
3940 pSession->bssParams.cbMode= pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003941 //For IBSS, we need to prepare some more information
3942 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003943 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003944 )
3945 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003946 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07003947 }
3948 // If we are in an IBSS, then stop the IBSS...
3949 ////Not worry about WDS connection for now
3950 if ( csrIsConnStateIbss( pMac, sessionId ) )
3951 {
3952 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
3953 }
3954 else
3955 {
3956 // if we are in an Infrastructure association....
3957 if ( csrIsConnStateInfra( pMac, sessionId ) )
3958 {
3959 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
3960 // across SSIDs (roaming to a new SSID)... //
3961 //Not worry about WDS connection for now
3962 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303963 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003964 {
3965 // then we need to disassociate from the Infrastructure network...
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303966 status = csrRoamIssueDisassociate( pMac, sessionId,
3967 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07003968 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303969 else
3970 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003971 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
3972 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303973 if ( pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -07003974 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303975 // Set parameters for this Bss.
3976 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
3977 pBssDesc, pBssConfig,
3978 pIes, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003979 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303980 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003981 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303982 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003983 {
3984 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
3985 // Nothing to stop.
3986 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003987 || CSR_IS_INFRA_AP(pProfile)
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303988 )
3989 {
3990 tANI_BOOLEAN is11rRoamingFlag = eANI_BOOLEAN_FALSE;
3991 is11rRoamingFlag = csrRoamIs11rAssoc(pMac);
3992 // Set parameters for this Bss.
3993 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
3994 pBssDesc, pBssConfig,
3995 pIes, is11rRoamingFlag);
3996 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003997 }
3998 }
3999 }//Success getting BSS config info
Kiet Lam64c1b492013-07-12 13:56:44 +05304000 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -07004001 }//Allocate memory
Jeff Johnson295189b2012-06-20 16:38:30 -07004002 return (status);
4003}
4004
Jeff Johnson295189b2012-06-20 16:38:30 -07004005eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
4006 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
4007{
4008 eCsrJoinState eRoamState = eCsrContinueRoaming;
4009 eHalStatus status;
4010 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
4011 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
4012 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004013
4014 if(!pSession)
4015 {
4016 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4017 return (eCsrStopRoaming);
4018 }
4019
Jeff Johnson295189b2012-06-20 16:38:30 -07004020 if( CSR_IS_WDS_STA( pProfile ) )
4021 {
4022 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
4023 if( !HAL_STATUS_SUCCESS( status ) )
4024 {
4025 eRoamState = eCsrStopRoaming;
4026 }
4027 }
4028 else
4029 {
4030 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
4031 {
4032 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
4033 return (eCsrStopRoaming);
4034 }
4035 if ( csrIsInfraBssDesc( pBssDesc ) )
4036 {
4037 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
4038 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
4039 // have changed and handle the changes (without disturbing the current association).
4040
4041 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
4042 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
4043 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
4044 )
4045 {
4046 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
4047 // with Authenticating first. To force this, stop the current association (Disassociate) and
4048 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
4049 // a new Association.
4050 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4051 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07004052 smsLog(pMac, LOGW, FL(" detect same profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004053 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
4054 {
4055 eRoamState = eCsrReassocToSelfNoCapChange;
4056 }
4057 else
4058 {
4059 tBssConfigParam bssConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004060 //The key changes
Kiet Lam64c1b492013-07-12 13:56:44 +05304061 vos_mem_set(&bssConfig, sizeof(bssConfig), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004062 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
4063 if(HAL_STATUS_SUCCESS(status))
4064 {
4065 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07004066 pSession->bssParams.cbMode = bssConfig.cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004067 //Reapply the config including Keys so reassoc is happening.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304068 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4069 pBssDesc, &bssConfig,
4070 pIesLocal, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004071 if(!HAL_STATUS_SUCCESS(status))
4072 {
4073 eRoamState = eCsrStopRoaming;
4074 }
4075 }
4076 else
4077 {
4078 eRoamState = eCsrStopRoaming;
4079 }
4080 }//same profile
4081 }
4082 else
4083 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304084 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004085 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
4086 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05304087 smsLog(pMac, LOGE, FL(" fail to issue disassociate with Session ID %d"),
4088 sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004089 eRoamState = eCsrStopRoaming;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304090 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004091 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304092 }
4093 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004094 {
4095 // note: we used to pre-auth here with open authentication networks but that was not working so well.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304096 // we had a lot of join timeouts when testing at Samsung. removing this step helped associations
Jeff Johnson295189b2012-06-20 16:38:30 -07004097 // work much better.
4098 //
4099 //
4100 // stop the existing network before attempting to join the new network...
4101 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4102 {
4103 eRoamState = eCsrStopRoaming;
4104 }
4105 }
4106 }//Infra
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304107 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004108 {
4109 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4110 {
4111 eRoamState = eCsrStopRoaming;
4112 }
4113 }
4114 if( pIesLocal && !pScanResult->pvIes )
4115 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304116 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004117 }
4118 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004119 return( eRoamState );
4120}
4121
Jeff Johnson295189b2012-06-20 16:38:30 -07004122eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
4123 tSirBssDescription *pBssDesc, tANI_U32 roamId)
4124{
4125 eHalStatus status = eHAL_STATUS_SUCCESS;
4126 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05304127 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004128 roamInfo.pBssDesc = pBssDesc;
4129 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
4130 return (status);
4131}
Jeff Johnson295189b2012-06-20 16:38:30 -07004132//In case no matching BSS is found, use whatever default we can find
4133static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4134{
4135 //Need to get all negotiated types in place first
4136 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08004137 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07004138 {
4139 default:
4140 case eCSR_AUTH_TYPE_WPA:
4141 case eCSR_AUTH_TYPE_WPA_PSK:
4142 case eCSR_AUTH_TYPE_WPA_NONE:
4143 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4144 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4145 break;
4146
4147 case eCSR_AUTH_TYPE_SHARED_KEY:
4148 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
4149 break;
4150
4151 case eCSR_AUTH_TYPE_AUTOSWITCH:
4152 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
4153 break;
4154 }
4155 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4156 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4157 //In this case, the multicast encryption needs to follow the uncast ones.
4158 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4159 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4160}
4161
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004162
4163static void csrSetAbortRoamingCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4164{
4165 switch(pCommand->u.roamCmd.roamReason)
4166 {
4167 case eCsrLostLink1:
4168 pCommand->u.roamCmd.roamReason = eCsrLostLink1Abort;
4169 break;
4170 case eCsrLostLink2:
4171 pCommand->u.roamCmd.roamReason = eCsrLostLink2Abort;
4172 break;
4173 case eCsrLostLink3:
4174 pCommand->u.roamCmd.roamReason = eCsrLostLink3Abort;
4175 break;
4176 default:
4177 smsLog(pMac, LOGE, FL(" aborting roaming reason %d not recognized"),
4178 pCommand->u.roamCmd.roamReason);
4179 break;
4180 }
4181}
4182
Jeff Johnson295189b2012-06-20 16:38:30 -07004183static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
4184{
4185 eHalStatus status;
4186 tCsrScanResult *pScanResult = NULL;
4187 eCsrJoinState eRoamState = eCsrStopRoaming;
4188 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
4189 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
4190 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
4191#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4192 v_U8_t acm_mask = 0;
4193#endif
4194 tANI_U32 sessionId = pCommand->sessionId;
4195 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4196 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4197 tANI_U8 concurrentChannel = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004198
4199 if(!pSession)
4200 {
4201 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4202 return (eCsrStopRoaming);
4203 }
4204
Jeff Johnson295189b2012-06-20 16:38:30 -07004205 do
4206 {
4207 // Check for Cardbus eject condition, before trying to Roam to any BSS
4208 //***if( !balIsCardPresent(pAdapter) ) break;
4209
Kiet Lam64c1b492013-07-12 13:56:44 +05304210 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004211 memcpy (&roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004212 if(NULL != pBSSList)
4213 {
4214 // When handling AP's capability change, continue to associate to
4215 // same BSS and make sure pRoamBssEntry is not Null.
4216 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
4217 {
4218 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
4219 {
4220 //Try the first BSS
4221 pCommand->u.roamCmd.pLastRoamBss = NULL;
4222 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
4223 }
4224 else
4225 {
4226 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4227 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4228 {
4229 //Done with all the BSSs
4230 //In this case, will tell HDD the completion
4231 break;
4232 }
4233 else
4234 {
4235 //We need to indicate to HDD that we are done with this one.
Kiet Lam64c1b492013-07-12 13:56:44 +05304236 //vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004237 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
4238 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4239 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4240 pRoamInfo = &roamInfo;
4241 }
4242 }
4243 while(pCommand->u.roamCmd.pRoamBssEntry)
4244 {
4245 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Jeff Johnson295189b2012-06-20 16:38:30 -07004246 /*If concurrency enabled take the concurrent connected channel first. */
4247 /* Valid multichannel concurrent sessions exempted */
Jeff Johnsone7245742012-09-05 17:12:55 -07004248 if (vos_concurrent_sessions_running() &&
4249 !csrIsValidMcConcurrentSession(pMac, sessionId, &pScanResult->Result.BssDescriptor))
Jeff Johnson295189b2012-06-20 16:38:30 -07004250 {
4251 concurrentChannel =
4252 csrGetConcurrentOperationChannel(pMac);
4253 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004254 " csr Concurrent Channel = %d", __func__, concurrentChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07004255 if ((concurrentChannel) &&
4256 (concurrentChannel ==
4257 pScanResult->Result.BssDescriptor.channelId))
4258 {
4259 //make this 0 because we do not want the
4260 //below check to pass as we don't want to
4261 //connect on other channel
4262 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4263 FL("Concurrent channel match =%d"),
4264 concurrentChannel);
4265 concurrentChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004266 }
4267 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004268
4269 if (!concurrentChannel)
4270 {
4271
4272 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
4273 sessionId, &pScanResult->Result.BssDescriptor,
4274 pCommand->u.roamCmd.roamId)))
4275 {
4276 //Ok to roam this
4277 break;
4278 }
4279 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004280 else
4281 {
4282 eRoamState = eCsrStopRoamingDueToConcurrency;
4283 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004284 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4285 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4286 {
4287 //Done with all the BSSs
4288 fDone = eANI_BOOLEAN_TRUE;
4289 break;
4290 }
4291 }
4292 if(fDone)
4293 {
4294 break;
4295 }
4296 }
4297 }
4298 //We have something to roam, tell HDD when it is infra.
4299 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
4300 //For WDS, the indication is eCSR_ROAM_WDS_IND
4301 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4302 {
4303 if(pRoamInfo)
4304 {
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004305 if(pSession->bRefAssocStartCnt)
4306 {
4307 pSession->bRefAssocStartCnt--;
4308 //Complete the last association attemp because a new one is about to be tried
4309 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4310 eCSR_ROAM_ASSOCIATION_COMPLETION,
Jeff Johnson295189b2012-06-20 16:38:30 -07004311 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004312 }
4313 }
4314 /* If the roaming has stopped, not to continue the roaming command*/
4315 if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
4316 {
4317 //No need to complete roaming here as it already completes
4318 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed"),
4319 pCommand->u.roamCmd.roamReason);
4320 eRoamState = eCsrStopRoaming;
4321 csrSetAbortRoamingCommand(pMac, pCommand);
4322 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004323 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304324 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004325 if(pScanResult)
4326 {
4327 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07004328 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
4329 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004330 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004331 fDone = eANI_BOOLEAN_TRUE;
4332 eRoamState = eCsrStopRoaming;
4333 break;
4334 }
4335 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
4336 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
4337 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
4338 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
4339 CSR_IS_QOS_BSS(pIesLocal) &&
4340 CSR_IS_UAPSD_BSS(pIesLocal) )
4341 {
4342#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Jeff Johnson295189b2012-06-20 16:38:30 -07004343 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
4344 pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004345#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004346 }
4347 else
4348 {
4349 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4350 }
4351 if( pIesLocal && !pScanResult->Result.pvIes)
4352 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304353 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004354 }
4355 }
4356 else
4357 {
4358 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4359 }
4360 roamInfo.pProfile = pProfile;
4361 pSession->bRefAssocStartCnt++;
4362 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4363 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4364 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004365 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
4366 {
4367 // If this is a start IBSS profile, then we need to start the IBSS.
4368 if ( CSR_IS_START_IBSS(pProfile) )
4369 {
4370 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004371 // Attempt to start this IBSS...
4372 csrRoamAssignDefaultParam( pMac, pCommand );
4373 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
4374 if(HAL_STATUS_SUCCESS(status))
4375 {
4376 if ( fSameIbss )
4377 {
4378 eRoamState = eCsrStartIbssSameIbss;
4379 }
4380 else
4381 {
4382 eRoamState = eCsrContinueRoaming;
4383 }
4384 }
4385 else
4386 {
4387 //it somehow fail need to stop
4388 eRoamState = eCsrStopRoaming;
4389 }
4390 break;
4391 }
4392 else if ( (CSR_IS_WDS_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004393 || (CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004394 )
4395 {
4396 // Attempt to start this WDS...
4397 csrRoamAssignDefaultParam( pMac, pCommand );
4398 /* For AP WDS, we dont have any BSSDescription */
4399 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
4400 if(HAL_STATUS_SUCCESS(status))
4401 {
4402 eRoamState = eCsrContinueRoaming;
4403 }
4404 else
4405 {
4406 //it somehow fail need to stop
4407 eRoamState = eCsrStopRoaming;
4408 }
4409 }
4410 else
4411 {
4412 //Nothing we can do
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004413 smsLog(pMac, LOGW, FL("cannot continue without BSS list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004414 eRoamState = eCsrStopRoaming;
4415 break;
4416 }
4417 }
4418 else //We have BSS
4419 {
4420 //Need to assign these value because they are used in csrIsSameProfile
4421 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Leela Venkata Kiran Kumar Reddy Chirala909b8812014-05-16 22:09:05 -07004422 /* The OSEN IE doesn't provide the cipher suite.
4423 * Therefore set to constant value of AES */
4424 if(pCommand->u.roamCmd.roamProfile.bOSENAssociation)
4425 {
4426 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4427 eCSR_ENCRYPT_TYPE_AES;
4428 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4429 eCSR_ENCRYPT_TYPE_AES;
4430 }
4431 else
4432 {
4433 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4434 pScanResult->ucEncryptionType; //Negotiated while building scan result.
4435 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4436 pScanResult->mcEncryptionType;
4437 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004438 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
4439 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
4440 {
4441 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4442 {
4443 eRoamState = eCsrStartIbssSameIbss;
4444 break;
4445 }
4446 }
4447 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
4448 {
4449 //trying to connect to the one already connected
4450 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
4451 eRoamState = eCsrReassocToSelfNoCapChange;
4452 break;
4453 }
4454 // Attempt to Join this Bss...
4455 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
4456 break;
4457 }
4458
4459 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004460 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
4461 {
4462 //Need to indicate association_completion if association_start has been done
4463 if(pSession->bRefAssocStartCnt > 0)
4464 {
4465 pSession->bRefAssocStartCnt--;
4466 //Complete the last association attemp because a new one is about to be tried
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004467 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07004468 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4469 eCSR_ROAM_ASSOCIATION_COMPLETION,
4470 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4471 }
4472 }
4473
4474 return( eRoamState );
4475}
4476
Jeff Johnson295189b2012-06-20 16:38:30 -07004477static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4478{
4479 eHalStatus status = eHAL_STATUS_SUCCESS;
4480 eCsrJoinState RoamState;
4481 tANI_U32 sessionId = pCommand->sessionId;
4482
Jeff Johnson295189b2012-06-20 16:38:30 -07004483 //***if( hddIsRadioStateOn( pAdapter ) )
4484 {
4485 // Attept to join a Bss...
4486 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07004487
Jeff Johnson295189b2012-06-20 16:38:30 -07004488 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07004489 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004490 {
4491 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004492 // and if connected in Infrastructure mode...
4493 if ( csrIsConnStateInfra(pMac, sessionId) )
4494 {
4495 //... then we need to issue a disassociation
4496 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
4497 if(!HAL_STATUS_SUCCESS(status))
4498 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004499 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004500 //roam command is completed by caller in the failed case
4501 fComplete = eANI_BOOLEAN_TRUE;
4502 }
4503 }
4504 else if( csrIsConnStateIbss(pMac, sessionId) )
4505 {
4506 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4507 if(!HAL_STATUS_SUCCESS(status))
4508 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004509 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004510 //roam command is completed by caller in the failed case
4511 fComplete = eANI_BOOLEAN_TRUE;
4512 }
4513 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004514 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
4515 {
4516 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4517 if(!HAL_STATUS_SUCCESS(status))
4518 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004519 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004520 //roam command is completed by caller in the failed case
4521 fComplete = eANI_BOOLEAN_TRUE;
4522 }
4523 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004524 else
4525 {
4526 fComplete = eANI_BOOLEAN_TRUE;
4527 }
4528 if(fComplete)
4529 {
4530 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07004531 if(eCsrStopRoamingDueToConcurrency == RoamState)
4532 {
4533 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
4534 }
4535 else
4536 {
4537 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
4538 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004539 }
4540 }
4541 else if ( eCsrReassocToSelfNoCapChange == RoamState )
4542 {
4543 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
4544 }
4545 else if ( eCsrStartIbssSameIbss == RoamState )
4546 {
4547 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
4548 }
4549 }//hddIsRadioStateOn
4550
4551 return status;
4552}
Jeff Johnson295189b2012-06-20 16:38:30 -07004553eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4554{
4555 tANI_U32 sessionId;
4556 tCsrRoamSession *pSession;
4557 tCsrScanResult *pScanResult = NULL;
4558 tSirBssDescription *pBssDesc = NULL;
4559 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004560 sessionId = pCommand->sessionId;
4561 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004562
4563 if(!pSession)
4564 {
4565 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4566 return eHAL_STATUS_FAILURE;
4567 }
4568
Jeff Johnson295189b2012-06-20 16:38:30 -07004569 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
4570 {
4571 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004572 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004573 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4574 return eHAL_STATUS_FAILURE;
4575 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004576 if (pCommand->u.roamCmd.pRoamBssEntry)
4577 {
4578 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4579 pBssDesc = &pScanResult->Result.BssDescriptor;
4580 }
4581 else
4582 {
4583 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004584 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004585 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4586 return eHAL_STATUS_FAILURE;
4587 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004588 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
4589 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
4590 return status;
4591}
4592
Jeff Johnson295189b2012-06-20 16:38:30 -07004593eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4594{
4595 eHalStatus status = eHAL_STATUS_SUCCESS;
4596 tCsrRoamInfo roamInfo;
4597 tANI_U32 sessionId = pCommand->sessionId;
4598 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004599
4600 if(!pSession)
4601 {
4602 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4603 return eHAL_STATUS_FAILURE;
4604 }
Abhishek Singhf4669da2014-05-26 15:07:49 +05304605
Jeff Johnson295189b2012-06-20 16:38:30 -07004606 switch ( pCommand->u.roamCmd.roamReason )
4607 {
4608 case eCsrForcedDisassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07004609 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004610 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004611 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004612 case eCsrSmeIssuedDisassocForHandoff:
4613 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
4614#if 0 // TODO : Confirm this change
4615 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
4616#else
4617 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4618#endif
4619
4620 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004621 case eCsrForcedDisassocMICFailure:
Jeff Johnson295189b2012-06-20 16:38:30 -07004622 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004623 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004624 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004625 case eCsrForcedDeauth:
Jeff Johnson295189b2012-06-20 16:38:30 -07004626 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004627 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004628 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004629 case eCsrHddIssuedReassocToSameAP:
4630 case eCsrSmeIssuedReassocToSameAP:
4631 {
4632 tDot11fBeaconIEs *pIes = NULL;
4633
Jeff Johnson295189b2012-06-20 16:38:30 -07004634 if( pSession->pConnectBssDesc )
4635 {
4636 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
4637 if(!HAL_STATUS_SUCCESS(status) )
4638 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004639 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004640 }
4641 else
4642 {
4643 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
4644 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
4645 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07004646 roamInfo.pBssDesc = pSession->pConnectBssDesc;
4647 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
4648 pSession->bRefAssocStartCnt++;
4649 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4650 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4651
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004652 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004653 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
4654 &pCommand->u.roamCmd.roamProfile );
4655 if(!HAL_STATUS_SUCCESS(status))
4656 {
4657 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08004658 csrReleaseCommandRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004659 }
4660
Kiet Lam64c1b492013-07-12 13:56:44 +05304661 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07004662 pIes = NULL;
4663 }
4664 }
4665 break;
4666 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004667 case eCsrCapsChange:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004668 smsLog(pMac, LOGE, FL("received eCsrCapsChange "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004669 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4670 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
4671 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004672 case eCsrSmeIssuedFTReassoc:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004673 smsLog(pMac, LOG1, FL("received FT Reassoc Req "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004674 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
4675 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07004676
Jeff Johnson295189b2012-06-20 16:38:30 -07004677 case eCsrStopBss:
4678 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4679 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4680 break;
4681
4682 case eCsrForcedDisassocSta:
4683 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4684 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
4685 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4686 pCommand->u.roamCmd.reason);
4687 break;
4688
4689 case eCsrForcedDeauthSta:
4690 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4691 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
4692 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4693 pCommand->u.roamCmd.reason);
4694 break;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004695
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004696 case eCsrPerformPreauth:
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08004697 smsLog(pMac, LOG1, FL("Attempting FT PreAuth Req"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004698 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
4699 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004700 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004701
4702 default:
4703 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4704
4705 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
4706 {
4707 //Remember the roaming profile
4708 csrFreeRoamProfile(pMac, sessionId);
Kiet Lam64c1b492013-07-12 13:56:44 +05304709 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
4710 if ( NULL != pSession->pCurRoamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004711 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304712 vos_mem_set(pSession->pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004713 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
4714 }
4715 }
4716
4717 //At this point, original uapsd_mask is saved in pCurRoamProfile
4718 //uapsd_mask in the pCommand may change from this point on.
4719
4720 // Attempt to roam with the new scan results (if we need to..)
4721 status = csrRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004722 if(!HAL_STATUS_SUCCESS(status))
4723 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004724 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X"), status);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004725 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004726 break;
4727 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004728 return (status);
4729}
4730
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004731void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4732{
4733 pCommand->u.roamCmd.pLastRoamBss = NULL;
4734 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4735 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05304736 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004737}
4738
Jeff Johnson295189b2012-06-20 16:38:30 -07004739void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4740{
4741 if(pCommand->u.roamCmd.fReleaseBssList)
4742 {
4743 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
4744 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
4745 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
4746 }
4747 if(pCommand->u.roamCmd.fReleaseProfile)
4748 {
4749 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
4750 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
4751 }
4752 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4753 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05304754 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004755}
4756
Jeff Johnson295189b2012-06-20 16:38:30 -07004757void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4758{
Kiet Lam64c1b492013-07-12 13:56:44 +05304759 vos_mem_set(&pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004760}
Jeff Johnson295189b2012-06-20 16:38:30 -07004761void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
4762{
4763 tListElem *pEntry;
4764 tSmeCmd *pCommand;
4765 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004766 smsLog( pMac, LOG2, "Roam Completion ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004767 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
4768 if ( pEntry )
4769 {
4770 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07004771 // If the head of the queue is Active and it is a ROAM command, remove
4772 // and put this on the Free queue.
4773 if ( eSmeCommandRoam == pCommand->command )
4774 {
4775 //we need to process the result first before removing it from active list because state changes
4776 //still happening insides roamQProcessRoamResults so no other roam command should be issued
4777 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
4778 if( fReleaseCommand )
4779 {
4780 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
4781 {
4782 csrReleaseCommandRoam( pMac, pCommand );
4783 }
4784 else
4785 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004786 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004787 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004788 }
4789 }
4790 else
4791 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004792 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004793 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004794 }
4795 }
4796 else
4797 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004798 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004799 }
4800 }
4801 else
4802 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004803 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004804 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004805 if( fReleaseCommand )
4806 {
4807 smeProcessPendingQueue( pMac );
4808 }
4809}
4810
Jeff Johnson295189b2012-06-20 16:38:30 -07004811void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4812{
4813 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004814 if(!pSession)
4815 {
4816 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4817 return;
4818 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304819 vos_mem_set(&(pSession->PmkidCandidateInfo[0]),
4820 sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004821 pSession->NumPmkidCandidate = 0;
4822}
Jeff Johnson295189b2012-06-20 16:38:30 -07004823#ifdef FEATURE_WLAN_WAPI
4824void csrResetBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4825{
4826 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004827 if(!pSession)
4828 {
4829 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4830 return;
4831 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304832 vos_mem_set(&(pSession->BkidCandidateInfo[0]),
4833 sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004834 pSession->NumBkidCandidate = 0;
4835}
4836#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004837extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
4838
Jeff Johnson295189b2012-06-20 16:38:30 -07004839static eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrAuthType authType,
4840 tSirBssDescription *pSirBssDesc,
4841 tDot11fBeaconIEs *pIes)
4842{
4843 eHalStatus status = eHAL_STATUS_SUCCESS;
4844 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4845 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004846
4847 if(!pSession)
4848 {
4849 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4850 return eHAL_STATUS_FAILURE;
4851 }
4852
Jeff Johnson295189b2012-06-20 16:38:30 -07004853 if((eCSR_AUTH_TYPE_WPA == authType) ||
4854 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
4855 (eCSR_AUTH_TYPE_RSN == authType) ||
4856 (eCSR_AUTH_TYPE_RSN_PSK == authType)
4857#if defined WLAN_FEATURE_VOWIFI_11R
4858 ||
4859 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4860 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
4861#endif /* FEATURE_WLAN_WAPI */
4862#ifdef FEATURE_WLAN_WAPI
4863 ||
4864 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4865 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
4866#endif /* FEATURE_WLAN_WAPI */
Chet Lanctot186b5732013-03-18 10:26:30 -07004867#ifdef WLAN_FEATURE_11W
4868 ||
4869 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType)
4870#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004871 )
4872 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004873 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4874 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004875 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004876 }
4877 if( pIesLocal )
4878 {
4879 tANI_U32 nIeLen;
4880 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07004881 if((eCSR_AUTH_TYPE_RSN == authType) ||
4882#if defined WLAN_FEATURE_VOWIFI_11R
4883 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4884 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
4885#endif /* WLAN_FEATURE_VOWIFI_11R */
Chet Lanctot186b5732013-03-18 10:26:30 -07004886#if defined WLAN_FEATURE_11W
4887 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
4888#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004889 (eCSR_AUTH_TYPE_RSN_PSK == authType))
4890 {
4891 if(pIesLocal->RSN.present)
4892 {
4893 //Calculate the actual length
4894 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
4895 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
4896 + 2 //akm_suite_count
4897 + pIesLocal->RSN.akm_suite_count * 4 //akm_suites
4898 + 2; //reserved
4899 if( pIesLocal->RSN.pmkid_count )
4900 {
4901 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
4902 }
4903 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304904 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
4905 if (NULL == pSession->pWpaRsnRspIE)
4906 status = eHAL_STATUS_FAILURE;
4907 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004908 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304909 vos_mem_set(pSession->pWpaRsnRspIE, nIeLen + 2, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004910 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
4911 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4912 //copy upto akm_suites
4913 pIeBuf = pSession->pWpaRsnRspIE + 2;
Kiet Lam64c1b492013-07-12 13:56:44 +05304914 vos_mem_copy(pIeBuf, &pIesLocal->RSN.version,
4915 sizeof(pIesLocal->RSN.version));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004916 pIeBuf += sizeof(pIesLocal->RSN.version);
Kiet Lam64c1b492013-07-12 13:56:44 +05304917 vos_mem_copy(pIeBuf, &pIesLocal->RSN.gp_cipher_suite,
4918 sizeof(pIesLocal->RSN.gp_cipher_suite));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004919 pIeBuf += sizeof(pIesLocal->RSN.gp_cipher_suite);
Kiet Lam64c1b492013-07-12 13:56:44 +05304920 vos_mem_copy(pIeBuf, &pIesLocal->RSN.pwise_cipher_suite_count,
4921 sizeof(pIesLocal->RSN.pwise_cipher_suite_count));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004922 pIeBuf += sizeof(pIesLocal->RSN.pwise_cipher_suite_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07004923 if( pIesLocal->RSN.pwise_cipher_suite_count )
4924 {
4925 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304926 vos_mem_copy(pIeBuf,
4927 pIesLocal->RSN.pwise_cipher_suites,
4928 pIesLocal->RSN.pwise_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004929 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
4930 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304931 vos_mem_copy(pIeBuf, &pIesLocal->RSN.akm_suite_count, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004932 pIeBuf += 2;
4933 if( pIesLocal->RSN.akm_suite_count )
4934 {
4935 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304936 vos_mem_copy(pIeBuf,
4937 pIesLocal->RSN.akm_suites,
4938 pIesLocal->RSN.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004939 pIeBuf += pIesLocal->RSN.akm_suite_count * 4;
4940 }
4941 //copy the rest
Kiet Lam64c1b492013-07-12 13:56:44 +05304942 vos_mem_copy(pIeBuf,
4943 pIesLocal->RSN.akm_suites + pIesLocal->RSN.akm_suite_count * 4,
4944 2 + pIesLocal->RSN.pmkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004945 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4946 }
4947 }
4948 }
4949 else if((eCSR_AUTH_TYPE_WPA == authType) ||
4950 (eCSR_AUTH_TYPE_WPA_PSK == authType))
4951 {
4952 if(pIesLocal->WPA.present)
4953 {
4954 //Calculate the actual length
4955 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
4956 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
4957 + 2 //auth_suite_count
4958 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
4959 // The WPA capabilities follows the Auth Suite (two octects)--
4960 // this field is optional, and we always "send" zero, so just
4961 // remove it. This is consistent with our assumptions in the
4962 // frames compiler; c.f. bug 15234:
4963 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304964
4965 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
4966 if ( NULL == pSession->pWpaRsnRspIE )
4967 status = eHAL_STATUS_FAILURE;
4968 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004969 {
4970 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
4971 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4972 pIeBuf = pSession->pWpaRsnRspIE + 2;
4973 //Copy WPA OUI
Kiet Lam64c1b492013-07-12 13:56:44 +05304974 vos_mem_copy(pIeBuf, &csrWpaOui[1], 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004975 pIeBuf += 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05304976 vos_mem_copy(pIeBuf, &pIesLocal->WPA.version,
4977 8 + pIesLocal->WPA.unicast_cipher_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004978 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05304979 vos_mem_copy(pIeBuf, &pIesLocal->WPA.auth_suite_count,
4980 2 + pIesLocal->WPA.auth_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004981 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
4982 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4983 }
4984 }
4985 }
4986#ifdef FEATURE_WLAN_WAPI
4987 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4988 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
4989 {
4990 if(pIesLocal->WAPI.present)
4991 {
4992 //Calculate the actual length
4993 nIeLen = 4 //version + akm_suite_count
4994 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
4995 + 2 //pwise_cipher_suite_count
4996 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
4997 + 6; //gp_cipher_suite + preauth + reserved
4998 if( pIesLocal->WAPI.bkid_count )
4999 {
5000 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
5001 }
5002
5003 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305004 pSession->pWapiRspIE = vos_mem_malloc(nIeLen + 2);
5005 if ( NULL == pSession->pWapiRspIE )
5006 status = eHAL_STATUS_FAILURE;
5007 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005008 {
5009 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
5010 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
5011 pIeBuf = pSession->pWapiRspIE + 2;
5012 //copy upto akm_suite_count
Kiet Lam64c1b492013-07-12 13:56:44 +05305013 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.version, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005014 pIeBuf += 4;
5015 if( pIesLocal->WAPI.akm_suite_count )
5016 {
5017 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305018 vos_mem_copy(pIeBuf, pIesLocal->WAPI.akm_suites,
5019 pIesLocal->WAPI.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005020 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305021 }
5022 vos_mem_copy(pIeBuf,
5023 &pIesLocal->WAPI.unicast_cipher_suite_count,
5024 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005025 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005026 if( pIesLocal->WAPI.unicast_cipher_suite_count )
5027 {
5028 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305029 vos_mem_copy( pIeBuf,
5030 pIesLocal->WAPI.unicast_cipher_suites,
5031 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005032 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
5033 }
lukez3c809222013-05-03 10:23:02 -07005034 //gp_cipher_suite
Kiet Lam64c1b492013-07-12 13:56:44 +05305035 vos_mem_copy(pIeBuf,
5036 pIesLocal->WAPI.multicast_cipher_suite,
5037 4);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005038 pIeBuf += 4;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305039 //preauth + reserved
Kiet Lam64c1b492013-07-12 13:56:44 +05305040 vos_mem_copy(pIeBuf,
5041 pIesLocal->WAPI.multicast_cipher_suite + 4,
5042 2);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005043 pIeBuf += 2;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305044 //bkid_count
Kiet Lam64c1b492013-07-12 13:56:44 +05305045 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.bkid_count, 2);
5046
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005047 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005048 if( pIesLocal->WAPI.bkid_count )
5049 {
5050 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305051 vos_mem_copy(pIeBuf, pIesLocal->WAPI.bkid,
5052 pIesLocal->WAPI.bkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005053 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
5054 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305055 pSession->nWapiRspIeLength = nIeLen + 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005056 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005057 }
5058 }
5059#endif /* FEATURE_WLAN_WAPI */
5060 if( !pIes )
5061 {
5062 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05305063 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07005064 }
5065 }
5066 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005067 return (status);
5068}
5069
Jeff Johnson295189b2012-06-20 16:38:30 -07005070static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
5071{
5072 v_U8_t bACWeights[WLANTL_MAX_AC];
5073 v_U8_t paramBk, paramBe, paramVi, paramVo;
5074 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005075 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
5076 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
5077 //of the higher AC one, make the higher AC has the same weight as the lower AC.
5078 //This doesn't address the case where the lower AC needs a real higher weight
5079 if( pIEs->WMMParams.present )
5080 {
5081 //no change to the lowest ones
5082 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
5083 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
5084 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
5085 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
5086 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
5087 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
5088 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
5089 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
5090 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
5091 {
5092 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
5093 fWeightChange = VOS_TRUE;
5094 }
5095 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
5096 {
5097 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
5098 fWeightChange = VOS_TRUE;
5099 }
5100 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
5101 {
5102 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
5103 fWeightChange = VOS_TRUE;
5104 }
5105 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
5106 {
5107 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
5108 fWeightChange = VOS_TRUE;
5109 }
5110 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
5111 {
5112 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
5113 fWeightChange = VOS_TRUE;
5114 }
5115 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
5116 {
5117 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
5118 fWeightChange = VOS_TRUE;
5119 }
5120 if(fWeightChange)
5121 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005122 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)"), bACWeights[0], bACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07005123 bACWeights[2], bACWeights[3]);
5124 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
5125 }
5126 }
5127}
Jeff Johnson295189b2012-06-20 16:38:30 -07005128#ifdef WLAN_FEATURE_VOWIFI_11R
5129//Returns whether the current association is a 11r assoc or not
5130tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
5131{
5132#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5133 return csrNeighborRoamIs11rAssoc(pMac);
5134#else
5135 return eANI_BOOLEAN_FALSE;
5136#endif
5137}
5138#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005139#ifdef FEATURE_WLAN_ESE
5140//Returns whether the current association is a ESE assoc or not
5141tANI_BOOLEAN csrRoamIsESEAssoc(tpAniSirGlobal pMac)
Jeff Johnson295189b2012-06-20 16:38:30 -07005142{
5143#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005144 return csrNeighborRoamIsESEAssoc(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07005145#else
5146 return eANI_BOOLEAN_FALSE;
5147#endif
5148}
5149#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005150#ifdef FEATURE_WLAN_LFR
5151//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305152tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005153{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305154 tCsrRoamSession *pSession = NULL;
5155
5156 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
5157 {
5158 pSession = CSR_GET_SESSION( pMac, sessionId );
5159 if (NULL != pSession->pCurRoamProfile)
5160 {
5161 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
5162 {
5163 return eANI_BOOLEAN_FALSE;
5164 }
5165 }
5166 }
5167
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005168#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5169 if (eANI_BOOLEAN_TRUE == CSR_IS_FASTROAM_IN_CONCURRENCY_INI_FEATURE_ENABLED(pMac))
5170 {
5171 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled);
5172 }
5173 else
5174#endif
5175 {
5176 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07005177 (!csrIsConcurrentSessionRunning(pMac)));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005178 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005179}
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005180
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005181#ifdef FEATURE_WLAN_ESE
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005182/* ---------------------------------------------------------------------------
5183
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005184 \fn csrNeighborRoamIsESEAssoc
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005185
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005186 \brief This function returns whether the current association is a ESE assoc or not
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005187
5188 \param pMac - The handle returned by macOpen.
5189
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005190 \return eANI_BOOLEAN_TRUE if current assoc is ESE, eANI_BOOLEAN_FALSE otherwise
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005191
5192---------------------------------------------------------------------------*/
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005193tANI_BOOLEAN csrNeighborRoamIsESEAssoc(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005194{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005195 return pMac->roam.neighborRoamInfo.isESEAssoc;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005196}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005197#endif /* FEATURE_WLAN_ESE */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005198
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005199#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5200//Returns whether "FW based BG scan" is currently enabled...or not
5201tANI_BOOLEAN csrRoamIsRoamOffloadScanEnabled(tpAniSirGlobal pMac)
5202{
5203 return (pMac->roam.configParam.isRoamOffloadScanEnabled);
5204}
5205#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005206#endif
5207
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005208#if defined(FEATURE_WLAN_ESE)
5209tANI_BOOLEAN csrRoamIsEseIniFeatureEnabled(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005210{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005211 return pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005212}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005213#endif /*FEATURE_WLAN_ESE*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005214
Jeff Johnson295189b2012-06-20 16:38:30 -07005215//Return true means the command can be release, else not
5216static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
5217 eCsrRoamCompleteResult Result, void *Context )
5218{
5219 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
5220 tSirBssDescription *pSirBssDesc = NULL;
5221 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
5222 tCsrScanResult *pScanResult = NULL;
5223 tCsrRoamInfo roamInfo;
5224 sme_QosAssocInfo assocInfo;
5225 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
5226 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
5227 tDot11fBeaconIEs *pIes = NULL;
5228 tANI_U32 sessionId = pCommand->sessionId;
5229 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5230 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
5231 eRoamCmdStatus roamStatus;
5232 eCsrRoamResult roamResult;
5233 eHalStatus status;
5234 tANI_U32 key_timeout_interval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005235 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005236
Jeff Johnson32d95a32012-09-10 13:15:23 -07005237 if(!pSession)
5238 {
5239 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5240 return eANI_BOOLEAN_FALSE;
5241 }
5242
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005243 smsLog( pMac, LOG1, FL("Processing ROAM results..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07005244 switch( Result )
5245 {
5246 case eCsrJoinSuccess:
5247 // reset the IDLE timer
5248 // !!
5249 // !! fall through to the next CASE statement here is intentional !!
5250 // !!
5251 case eCsrReassocSuccess:
5252 if(eCsrReassocSuccess == Result)
5253 {
5254 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
5255 }
5256 else
5257 {
5258 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
5259 }
5260 // Success Join Response from LIM. Tell NDIS we are connected and save the
5261 // Connected state...
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005262 smsLog(pMac, LOGW, FL("receives association indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305263 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005264 //always free the memory here
5265 if(pSession->pWpaRsnRspIE)
5266 {
5267 pSession->nWpaRsnRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305268 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005269 pSession->pWpaRsnRspIE = NULL;
5270 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005271#ifdef FEATURE_WLAN_WAPI
5272 if(pSession->pWapiRspIE)
5273 {
5274 pSession->nWapiRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305275 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005276 pSession->pWapiRspIE = NULL;
5277 }
5278#endif /* FEATURE_WLAN_WAPI */
5279#ifdef FEATURE_WLAN_BTAMP_UT_RF
5280 //Reset counter so no join retry is needed.
5281 pSession->maxRetryCount = 0;
5282 csrRoamStopJoinRetryTimer(pMac, sessionId);
5283#endif
5284 /* This creates problem since we have not saved the connected profile.
5285 So moving this after saving the profile
5286 */
5287 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
Abhishek Singh36abbcb2014-03-20 13:04:09 +05305288
5289 /* Reset remainInPowerActiveTillDHCP as it might have been set
5290 * by last failed secured connection.
5291 * It should be set only for secured connection.
5292 */
5293 pMac->pmc.remainInPowerActiveTillDHCP = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005294 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
5295 {
5296 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
5297 }
5298 else
5299 {
5300 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
5301 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005302 //Use the last connected bssdesc for reassoc-ing to the same AP.
5303 //NOTE: What to do when reassoc to a different AP???
5304 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5305 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5306 {
5307 pSirBssDesc = pSession->pConnectBssDesc;
5308 if(pSirBssDesc)
5309 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305310 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5311 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005312 }
5313 }
5314 else
5315 {
5316
5317 if(pCommand->u.roamCmd.pRoamBssEntry)
5318 {
5319 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
5320 if(pScanResult != NULL)
5321 {
5322 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5323 //this can be NULL
5324 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
Kiet Lam64c1b492013-07-12 13:56:44 +05305325 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5326 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005327 }
5328 }
5329 }
5330 if( pSirBssDesc )
5331 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005332 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07005333 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5334 //Save WPA/RSN IE
5335 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005336#ifdef FEATURE_WLAN_ESE
5337 roamInfo.isESEAssoc = pSession->connectedProfile.isESEAssoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005338#endif
5339
5340 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
5341 // substate change.
5342 // Moving even save profile above so that below mentioned conditon is also met.
5343 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
5344 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005345 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
5346 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
5347 // will be dropped for the security context may not be set properly.
5348 //
5349 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
5350 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
5351 //
5352 // this reordering was done on titan_prod_usb branch and is being replicated here.
5353 //
5354
5355 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
5356 !pProfile->bWPSAssociation)
5357 {
5358 // Issue the set Context request to LIM to establish the Unicast STA context
5359 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
5360 pProfile->negotiatedUCEncryptionType,
5361 pSirBssDesc, &(pSirBssDesc->bssId),
5362 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
5363 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005364 smsLog( pMac, LOGE, FL(" Set context for unicast fail") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005365 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5366 }
5367 // Issue the set Context request to LIM to establish the Broadcast STA context
5368 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
5369 pSirBssDesc, &BroadcastMac,
5370 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5371 }
5372 else
5373 {
5374 //Need to wait for supplicant authtication
5375 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005376 //Set the subestate to WaitForKey in case authentiation is needed
5377 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
5378
Jeff Johnson295189b2012-06-20 16:38:30 -07005379 if(pProfile->bWPSAssociation)
5380 {
5381 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
5382 }
5383 else
5384 {
5385 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
5386 }
5387
5388 //Save sessionId in case of timeout
5389 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
5390 //This time should be long enough for the rest of the process plus setting key
5391 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
5392 {
5393 //Reset our state so nothting is blocked.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005394 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005395 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
5396 }
5397 }
5398
5399 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
5400 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005401 if(Context)
5402 {
5403 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
5404 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07005405 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5406 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
5407#ifdef WLAN_FEATURE_VOWIFI_11R
5408 len += pJoinRsp->parsedRicRspLen;
5409#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005410#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005411 len += pJoinRsp->tspecIeLen;
5412#endif
5413 if(len)
5414 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305415 pSession->connectedInfo.pbFrames = vos_mem_malloc(len);
5416 if ( pSession->connectedInfo.pbFrames != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07005417 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305418 vos_mem_copy(pSession->connectedInfo.pbFrames,
5419 pJoinRsp->frames, len);
5420 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5421 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5422 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
Jeff Johnson295189b2012-06-20 16:38:30 -07005423#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05305424 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005425#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005426#ifdef FEATURE_WLAN_ESE
Kiet Lam64c1b492013-07-12 13:56:44 +05305427 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005428#endif
Kiet Lam64c1b492013-07-12 13:56:44 +05305429 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5430 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5431 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
5432 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
Jeff Johnson295189b2012-06-20 16:38:30 -07005433 }
5434 }
5435 if(pCommand->u.roamCmd.fReassoc)
5436 {
5437 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5438 }
5439 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5440 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5441 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
5442 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
c_hpothu44ff4e02014-05-08 00:13:57 +05305443 roamInfo.maxRateFlags = pJoinRsp->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -07005444 }
5445 else
5446 {
5447 if(pCommand->u.roamCmd.fReassoc)
5448 {
5449 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5450 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5451 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5452 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5453 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5454 }
5455 }
5456#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5457 // Indicate SME-QOS with reassoc success event, only after
5458 // copying the frames
5459 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
5460#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005461 roamInfo.pBssDesc = pSirBssDesc;
5462 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5463 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5464#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5465 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
5466#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
5467 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005468 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
5469 //It may be better to let QoS do this????
5470 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
5471 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005472 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now",
Jeff Johnson295189b2012-06-20 16:38:30 -07005473 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
5474 pmcStartUapsd( pMac, NULL, NULL );
5475 }
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05305476 pSession->connectedProfile.dot11Mode = pSession->bssParams.uCfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005477 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5478 if( pSession->bRefAssocStartCnt > 0 )
5479 {
5480 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005481 //Remove this code once SLM_Sessionization is supported
5482 //BMPS_WORKAROUND_NOT_NEEDED
5483 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005484 {
5485 pMac->roam.configParam.doBMPSWorkaround = 1;
5486 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005487 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5488 }
5489
5490 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005491 // reset the PMKID candidate list
5492 csrResetPMKIDCandidateList( pMac, sessionId );
5493 //Update TL's AC weight base on the current EDCA parameters
5494 //These parameters may change in the course of the connection, that sictuation
5495 //is not taken care here. This change is mainly to address a WIFI WMM test where
5496 //BE has a equal or higher TX priority than VI.
5497 //We only do this for infra link
5498 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
5499 {
5500 csrCheckAndUpdateACWeight(pMac, pIes);
5501 }
5502#ifdef FEATURE_WLAN_WAPI
5503 // reset the BKID candidate list
5504 csrResetBKIDCandidateList( pMac, sessionId );
5505#endif /* FEATURE_WLAN_WAPI */
5506 }
5507 else
5508 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005509 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc");
Jeff Johnson295189b2012-06-20 16:38:30 -07005510 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005511 csrScanCancelIdleScan(pMac);
5512 //Not to signal link up because keys are yet to be set.
5513 //The linkup function will overwrite the sub-state that we need to keep at this point.
5514 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
5515 {
5516 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
5517 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005518 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
5519 //enough to let security and DHCP handshake succeed before entry into BMPS
5520 if (pmcShouldBmpsTimerRun(pMac))
5521 {
Abhishek Singh65d939e2014-04-25 13:33:07 +05305522 /* Set remainInPowerActiveTillDHCP to make sure we wait for
5523 * until keys are set before going into BMPS.
5524 */
5525 if(eANI_BOOLEAN_TRUE == roamInfo.fAuthRequired)
5526 {
5527 pMac->pmc.remainInPowerActiveTillDHCP = TRUE;
5528 smsLog(pMac, LOG1, FL("Set remainInPowerActiveTillDHCP "
5529 "to make sure we wait until keys are set before"
5530 " going to BMPS"));
5531 }
5532
Jeff Johnson295189b2012-06-20 16:38:30 -07005533 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
5534 != eHAL_STATUS_SUCCESS)
5535 {
5536 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
5537 }
5538 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
5539 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005540 break;
5541
Jeff Johnson295189b2012-06-20 16:38:30 -07005542 case eCsrStartBssSuccess:
5543 // on the StartBss Response, LIM is returning the Bss Description that we
5544 // are beaconing. Add this Bss Description to our scan results and
5545 // chain the Profile to this Bss Description. On a Start BSS, there was no
5546 // detected Bss description (no partner) so we issued the Start Bss to
5547 // start the Ibss without any Bss description. Lim was kind enough to return
5548 // the Bss Description that we start beaconing for the newly started Ibss.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005549 smsLog(pMac, LOG2, FL("receives start BSS ok indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005550 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005551 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
Kiet Lam64c1b492013-07-12 13:56:44 +05305552 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005553 if( CSR_IS_IBSS( pProfile ) )
5554 {
5555 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
5556 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005557 else if (CSR_IS_INFRA_AP(pProfile))
5558 {
5559 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
5560 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005561 else
5562 {
5563 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
5564 }
5565 if( !CSR_IS_WDS_STA( pProfile ) )
5566 {
5567 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005568 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
Jeff Johnson295189b2012-06-20 16:38:30 -07005569 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
5570 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05305571 smsLog(pMac, LOGW, FL("cannot parse IBSS IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005572 roamInfo.pBssDesc = pSirBssDesc;
5573 //We need to associate_complete it first, becasue Associate_start already indicated.
5574 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5575 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
5576 break;
5577 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005578 if (!CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07005579 {
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07005580 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005581 }
5582 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
5583 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5584 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5585 if(pSirBssDesc)
5586 {
5587 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
Kiet Lam64c1b492013-07-12 13:56:44 +05305588 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5589 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005590 }
5591 //We are doen with the IEs so free it
Kiet Lam64c1b492013-07-12 13:56:44 +05305592 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005593#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5594 {
5595 vos_log_ibss_pkt_type *pIbssLog;
5596 tANI_U32 bi;
5597
5598 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5599 if(pIbssLog)
5600 {
5601 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5602 {
5603 //We start the IBSS (didn't find any matched IBSS out there)
5604 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
5605 }
5606 else
5607 {
5608 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
5609 }
5610 if(pSirBssDesc)
5611 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305612 vos_mem_copy(pIbssLog->bssid, pSirBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07005613 pIbssLog->operatingChannel = pSirBssDesc->channelId;
5614 }
5615 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
5616 {
5617 //***U8 is not enough for beacon interval
5618 pIbssLog->beaconInterval = (v_U8_t)bi;
5619 }
5620 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5621 }
5622 }
5623#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5624 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
5625 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07005626 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
5627 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005628 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
5629 csrRoamIssueSetContextReq( pMac, sessionId,
5630 pProfile->negotiatedMCEncryptionType,
5631 pSirBssDesc, &BroadcastMac,
5632 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5633 }
5634 }
5635 else
5636 {
5637 //Keep the state to eCSR_ROAMING_STATE_JOINING
5638 //Need to send join_req.
5639 if(pCommand->u.roamCmd.pRoamBssEntry)
5640 {
5641 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
5642 {
5643 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5644 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
5645 // Set the roaming substate to 'join attempt'...
5646 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08005647 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07005648 }
5649 }
5650 else
5651 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005652 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc" );
Jeff Johnson295189b2012-06-20 16:38:30 -07005653 VOS_ASSERT( 0 );
5654 }
5655 }
5656 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5657 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5658 //trigger the connection start indication in Vista
5659 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
5660 {
5661 roamStatus = eCSR_ROAM_IBSS_IND;
5662 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5663 if( CSR_IS_WDS( pProfile ) )
5664 {
5665 roamStatus = eCSR_ROAM_WDS_IND;
5666 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5667 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005668 if( CSR_IS_INFRA_AP( pProfile ) )
5669 {
5670 roamStatus = eCSR_ROAM_INFRA_IND;
5671 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
5672 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005673
5674 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5675 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5676 //trigger the connection start indication in Vista
Kiet Lam64c1b492013-07-12 13:56:44 +05305677 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005678 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5679 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
krunal soni3fc26642013-10-08 22:41:42 -07005680 //We start the IBSS (didn't find any matched IBSS out there)
5681 roamInfo.pBssDesc = pSirBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005682 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
Kiet Lam64c1b492013-07-12 13:56:44 +05305683 vos_mem_copy(roamInfo.bssid, pSirBssDesc->bssId,
5684 sizeof(tCsrBssid));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005685 //Remove this code once SLM_Sessionization is supported
5686 //BMPS_WORKAROUND_NOT_NEEDED
5687 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07005688 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005689 {
5690 pMac->roam.configParam.doBMPSWorkaround = 1;
5691 }
Mohit Khanna349bc392012-09-11 17:24:52 -07005692
Jeff Johnson295189b2012-06-20 16:38:30 -07005693 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5694 }
5695
5696 csrScanCancelIdleScan(pMac);
Ravi Joshi414b14c2013-10-04 16:33:26 -07005697
5698 if( CSR_IS_WDS_STA( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005699 {
5700 //need to send stop BSS because we fail to send join_req
5701 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
5702 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5703 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
5704 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005705 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005706 case eCsrStartBssFailure:
5707#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5708 {
5709 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07005710 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5711 if(pIbssLog)
5712 {
5713 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
5714 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5715 }
5716 }
5717#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07005718 roamStatus = eCSR_ROAM_IBSS_IND;
5719 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5720 if( CSR_IS_WDS( pProfile ) )
5721 {
5722 roamStatus = eCSR_ROAM_WDS_IND;
5723 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5724 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005725 if( CSR_IS_INFRA_AP( pProfile ) )
5726 {
5727 roamStatus = eCSR_ROAM_INFRA_IND;
5728 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
5729 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005730 if(Context)
5731 {
5732 pSirBssDesc = (tSirBssDescription *)Context;
5733 }
5734 else
5735 {
5736 pSirBssDesc = NULL;
5737 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305738 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005739 roamInfo.pBssDesc = pSirBssDesc;
5740 //We need to associate_complete it first, becasue Associate_start already indicated.
5741 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5742 csrSetDefaultDot11Mode( pMac );
5743 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005744 case eCsrSilentlyStopRoaming:
5745 // We are here because we try to start the same IBSS
5746 //No message to PE
5747 // return the roaming state to Joined.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005748 smsLog(pMac, LOGW, FL("receives silently roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005749 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
5750 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05305751 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005752 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5753 if( roamInfo.pBssDesc )
5754 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305755 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5756 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005757 }
5758 //Since there is no change in the current state, simply pass back no result otherwise
5759 //HDD may be mistakenly mark to disconnected state.
5760 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5761 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005762 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005763 case eCsrSilentlyStopRoamingSaveState:
5764 //We are here because we try to connect to the same AP
5765 //No message to PE
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005766 smsLog(pMac, LOGW, FL("receives silently stop roaming indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305767 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005768
5769 //to aviod resetting the substate to NONE
5770 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
5771 //No need to change substate to wai_for_key because there is no state change
5772 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5773 if( roamInfo.pBssDesc )
5774 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305775 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5776 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005777 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005778 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5779 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5780 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5781 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5782 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5783 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5784 roamInfo.staId = pSession->connectedInfo.staId;
5785 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005786 VOS_ASSERT( roamInfo.staId != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005787 pSession->bRefAssocStartCnt--;
5788 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5789 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5790 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
5791 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005792 case eCsrReassocFailure:
5793#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5794 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
5795#endif
5796 case eCsrJoinWdsFailure:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005797 smsLog(pMac, LOGW, FL("failed to join WDS"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005798 csrFreeConnectBssDesc(pMac, sessionId);
5799 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5800 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
Kiet Lam64c1b492013-07-12 13:56:44 +05305801 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005802 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5803 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5804 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5805 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5806 eCSR_ROAM_WDS_IND,
5807 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
5808 //Need to issue stop_bss
5809 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005810 case eCsrJoinFailure:
5811 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07005812 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07005813 default:
5814 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005815 smsLog(pMac, LOGW, FL("receives no association indication"));
5816 smsLog(pMac, LOG1, FL("Assoc ref count %d"),
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07005817 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07005818 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
5819 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
5820 {
5821 //do not free for the other profiles as we need to send down stop BSS later
5822 csrFreeConnectBssDesc(pMac, sessionId);
5823 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5824 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5825 csrSetDefaultDot11Mode( pMac );
5826 }
5827
5828 switch( pCommand->u.roamCmd.roamReason )
5829 {
5830 // If this transition is because of an 802.11 OID, then we transition
5831 // back to INIT state so we sit waiting for more OIDs to be issued and
5832 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07005833 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07005834 case eCsrSmeIssuedAssocToSimilarAP:
5835 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08005836 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07005837 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05305838 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005839 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5840 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5841 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Kiet Lam64c1b492013-07-12 13:56:44 +05305842 vos_mem_copy(&roamInfo.bssid,
5843 &pSession->joinFailStatusCode.bssId,
5844 sizeof(tCsrBssid));
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005845
Jeff Johnson295189b2012-06-20 16:38:30 -07005846 /* Defeaturize this later if needed */
5847#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5848 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
5849 if (csrRoamIsHandoffInProgress(pMac))
5850 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005851 /* Should indicate neighbor roam algorithm about the connect failure here */
5852 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
5853 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005854#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005855 if(pSession->bRefAssocStartCnt > 0)
5856 {
5857 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07005858 if(eCsrJoinFailureDueToConcurrency == Result)
5859 {
5860 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5861 eCSR_ROAM_ASSOCIATION_COMPLETION,
5862 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
5863 }
5864 else
5865 {
5866 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005867 eCSR_ROAM_ASSOCIATION_COMPLETION,
5868 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07005869 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005870 }
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005871 else
5872 {
5873 /* bRefAssocStartCnt is not incremented when
5874 * eRoamState == eCsrStopRoamingDueToConcurrency
5875 * in csrRoamJoinNextBss API. so handle this in
5876 * else case by sending assoc failure
5877 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005878 csrRoamCallCallback(pMac, sessionId, &roamInfo,
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005879 pCommand->u.scanCmd.roamId,
5880 eCSR_ROAM_ASSOCIATION_FAILURE,
5881 eCSR_ROAM_RESULT_FAILURE);
5882 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005883 smsLog(pMac, LOG1, FL(" roam(reason %d) failed"), pCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07005884#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Mukul Sharma5960ac82014-01-09 20:31:35 +05305885 sme_QosUpdateHandOff((tANI_U8)sessionId, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005886 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5887#endif
5888 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5889 csrScanStartIdleScan(pMac);
5890#ifdef FEATURE_WLAN_BTAMP_UT_RF
5891 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
5892 //BT activity and not able to recevie WLAN traffic. Retry the join
5893 if( CSR_IS_WDS_STA(pProfile) )
5894 {
5895 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
5896 }
5897#endif
5898 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005899 case eCsrHddIssuedReassocToSameAP:
5900 case eCsrSmeIssuedReassocToSameAP:
5901 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5902
5903 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5904#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5905 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5906#endif
5907 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5908 csrScanStartIdleScan(pMac);
5909 break;
5910 case eCsrForcedDisassoc:
5911 case eCsrForcedDeauth:
5912 case eCsrSmeIssuedIbssJoinFailure:
5913 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5914
5915 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
5916 {
5917 // Notify HDD that IBSS join failed
5918 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
5919 }
5920 else
5921 {
5922 csrRoamCallCallback(pMac, sessionId, NULL,
5923 pCommand->u.roamCmd.roamId,
5924 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5925 }
5926#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5927 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5928#endif
5929 csrRoamLinkDown(pMac, sessionId);
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08005930 /*
5931 *DelSta not done FW still in conneced state so dont
5932 *issue IMPS req
5933 */
5934 if (pMac->roam.deauthRspStatus == eSIR_SME_DEAUTH_STATUS)
5935 {
5936 smsLog(pMac, LOGW, FL("FW still in connected state "));
5937 break;
5938 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005939 csrScanStartIdleScan(pMac);
5940 break;
5941 case eCsrForcedIbssLeave:
5942 csrRoamCallCallback(pMac, sessionId, NULL,
5943 pCommand->u.roamCmd.roamId,
5944 eCSR_ROAM_IBSS_LEAVE,
5945 eCSR_ROAM_RESULT_IBSS_STOP);
5946 break;
5947 case eCsrForcedDisassocMICFailure:
5948 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5949
5950 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
5951#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5952 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
5953#endif
5954 csrScanStartIdleScan(pMac);
5955 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005956 case eCsrStopBss:
5957 csrRoamCallCallback(pMac, sessionId, NULL,
5958 pCommand->u.roamCmd.roamId,
5959 eCSR_ROAM_INFRA_IND,
5960 eCSR_ROAM_RESULT_INFRA_STOPPED);
5961 break;
5962 case eCsrForcedDisassocSta:
5963 case eCsrForcedDeauthSta:
5964 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
5965 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
5966 {
5967 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005968
5969 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
5970 {
5971 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05305972 vos_mem_copy(roamInfo.peerMac,
5973 pCommand->u.roamCmd.peerMac,
5974 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07005975 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
5976 roamInfo.statusCode = eSIR_SME_SUCCESS;
5977 status = csrRoamCallCallback(pMac, sessionId,
5978 &roamInfo, pCommand->u.roamCmd.roamId,
5979 eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
5980 }
5981 }
5982 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005983 case eCsrLostLink1:
5984 // if lost link roam1 failed, then issue lost link Scan2 ...
5985 csrScanRequestLostLink2(pMac, sessionId);
5986 break;
5987 case eCsrLostLink2:
5988 // if lost link roam2 failed, then issue lost link scan3 ...
5989 csrScanRequestLostLink3(pMac, sessionId);
5990 break;
5991 case eCsrLostLink3:
5992 default:
5993 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5994
5995 //We are done with one round of lostlink roaming here
5996 csrScanHandleFailedLostlink3(pMac, sessionId);
5997 break;
5998 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005999 break;
6000 }
6001 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006002 return ( fReleaseCommand );
6003}
6004
Jeff Johnson295189b2012-06-20 16:38:30 -07006005eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
6006{
6007 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006008 return (status);
6009}
6010
Jeff Johnson295189b2012-06-20 16:38:30 -07006011eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
6012{
6013 eHalStatus status = eHAL_STATUS_SUCCESS;
6014 tANI_U32 size = 0;
6015
6016 do
6017 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306018 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006019 if(pSrcProfile->BSSIDs.numOfBSSIDs)
6020 {
6021 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306022 pDstProfile->BSSIDs.bssid = vos_mem_malloc(size);
6023 if ( NULL == pDstProfile->BSSIDs.bssid )
6024 status = eHAL_STATUS_FAILURE;
6025 else
6026 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006027 if(!HAL_STATUS_SUCCESS(status))
6028 {
6029 break;
6030 }
6031 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306032 vos_mem_copy(pDstProfile->BSSIDs.bssid,
6033 pSrcProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07006034 }
6035 if(pSrcProfile->SSIDs.numOfSSIDs)
6036 {
6037 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306038 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(size);
6039 if ( NULL == pDstProfile->SSIDs.SSIDList )
6040 status = eHAL_STATUS_FAILURE;
6041 else
6042 status = eHAL_STATUS_SUCCESS;
6043 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006044 {
6045 break;
6046 }
6047 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306048 vos_mem_copy(pDstProfile->SSIDs.SSIDList,
6049 pSrcProfile->SSIDs.SSIDList, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07006050 }
6051 if(pSrcProfile->nWPAReqIELength)
6052 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306053 pDstProfile->pWPAReqIE = vos_mem_malloc(pSrcProfile->nWPAReqIELength);
6054 if ( NULL == pDstProfile->pWPAReqIE )
6055 status = eHAL_STATUS_FAILURE;
6056 else
6057 status = eHAL_STATUS_SUCCESS;
6058
6059 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006060 {
6061 break;
6062 }
6063 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306064 vos_mem_copy(pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE,
6065 pSrcProfile->nWPAReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006066 }
6067 if(pSrcProfile->nRSNReqIELength)
6068 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306069 pDstProfile->pRSNReqIE = vos_mem_malloc(pSrcProfile->nRSNReqIELength);
6070 if ( NULL == pDstProfile->pRSNReqIE )
6071 status = eHAL_STATUS_FAILURE;
6072 else
6073 status = eHAL_STATUS_SUCCESS;
6074
6075 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006076 {
6077 break;
6078 }
6079 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306080 vos_mem_copy(pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE,
6081 pSrcProfile->nRSNReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006082 }
6083#ifdef FEATURE_WLAN_WAPI
6084 if(pSrcProfile->nWAPIReqIELength)
6085 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306086 pDstProfile->pWAPIReqIE = vos_mem_malloc(pSrcProfile->nWAPIReqIELength);
6087 if ( NULL == pDstProfile->pWAPIReqIE )
6088 status = eHAL_STATUS_FAILURE;
6089 else
6090 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006091 if(!HAL_STATUS_SUCCESS(status))
6092 {
6093 break;
6094 }
6095 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306096 vos_mem_copy(pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE,
6097 pSrcProfile->nWAPIReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006098 }
6099#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07006100 if(pSrcProfile->nAddIEScanLength)
6101 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05306102 memset(pDstProfile->addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH);
6103 if ( SIR_MAC_MAX_IE_LENGTH >= pSrcProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -07006104 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05306105 vos_mem_copy(pDstProfile->addIEScan, pSrcProfile->addIEScan,
Kiet Lam64c1b492013-07-12 13:56:44 +05306106 pSrcProfile->nAddIEScanLength);
Agarwal Ashish4f616132013-12-30 23:32:50 +05306107 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
6108 }
6109 else
6110 {
6111 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
6112 FL(" AddIEScanLength is not valid %u"),
6113 pSrcProfile->nAddIEScanLength);
6114 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006115 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006116 if(pSrcProfile->nAddIEAssocLength)
6117 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306118 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6119 if ( NULL == pDstProfile->pAddIEAssoc )
6120 status = eHAL_STATUS_FAILURE;
6121 else
6122 status = eHAL_STATUS_SUCCESS;
6123
Jeff Johnson295189b2012-06-20 16:38:30 -07006124 if(!HAL_STATUS_SUCCESS(status))
6125 {
6126 break;
6127 }
6128 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306129 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6130 pSrcProfile->nAddIEAssocLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006131 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006132 if(pSrcProfile->ChannelInfo.ChannelList)
6133 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306134 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(
6135 pSrcProfile->ChannelInfo.numOfChannels);
6136 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6137 status = eHAL_STATUS_FAILURE;
6138 else
6139 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006140 if(!HAL_STATUS_SUCCESS(status))
6141 {
6142 break;
6143 }
6144 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
Kiet Lam64c1b492013-07-12 13:56:44 +05306145 vos_mem_copy(pDstProfile->ChannelInfo.ChannelList,
6146 pSrcProfile->ChannelInfo.ChannelList,
6147 pSrcProfile->ChannelInfo.numOfChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07006148 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006149 pDstProfile->AuthType = pSrcProfile->AuthType;
6150 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
6151 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
6152 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
6153 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
6154 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
Chet Lanctot186b5732013-03-18 10:26:30 -07006155#ifdef WLAN_FEATURE_11W
6156 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
6157 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
6158 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
6159#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006160 pDstProfile->BSSType = pSrcProfile->BSSType;
6161 pDstProfile->phyMode = pSrcProfile->phyMode;
6162 pDstProfile->csrPersona = pSrcProfile->csrPersona;
6163
6164#ifdef FEATURE_WLAN_WAPI
6165 if(csrIsProfileWapi(pSrcProfile))
6166 {
6167 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
6168 {
6169 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
6170 }
6171 }
6172#endif /* FEATURE_WLAN_WAPI */
6173 pDstProfile->CBMode = pSrcProfile->CBMode;
6174 /*Save the WPS info*/
6175 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006176 pDstProfile->bOSENAssociation = pSrcProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07006177 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006178 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07006179 pDstProfile->privacy = pSrcProfile->privacy;
6180 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
6181 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
6182 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
6183 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
6184 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
6185 pDstProfile->protEnabled = pSrcProfile->protEnabled;
6186 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
6187 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
6188 pDstProfile->wps_state = pSrcProfile->wps_state;
6189 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
Kiet Lam64c1b492013-07-12 13:56:44 +05306190 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6191 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006192#ifdef WLAN_FEATURE_VOWIFI_11R
6193 if (pSrcProfile->MDID.mdiePresent)
6194 {
6195 pDstProfile->MDID.mdiePresent = 1;
6196 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6197 }
6198#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006199 }while(0);
6200
6201 if(!HAL_STATUS_SUCCESS(status))
6202 {
6203 csrReleaseProfile(pMac, pDstProfile);
6204 pDstProfile = NULL;
6205 }
6206
6207 return (status);
6208}
Jeff Johnson295189b2012-06-20 16:38:30 -07006209eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
6210{
6211 eHalStatus status = eHAL_STATUS_SUCCESS;
6212 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
6213 do
6214 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306215 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006216 if(pSrcProfile->bssid)
6217 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306218 pDstProfile->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
6219 if ( NULL == pDstProfile->BSSIDs.bssid )
6220 status = eHAL_STATUS_FAILURE;
6221 else
6222 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006223 if(!HAL_STATUS_SUCCESS(status))
6224 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306225 smsLog( pMac, LOGE,
6226 FL("failed to allocate memory for BSSID"
6227 "%02x:%02x:%02x:%02x:%02x:%02x"),
6228 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6229 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006230 break;
6231 }
6232 pDstProfile->BSSIDs.numOfBSSIDs = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05306233 vos_mem_copy(pDstProfile->BSSIDs.bssid, pSrcProfile->bssid,
6234 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006235 }
6236 if(pSrcProfile->SSID.ssId)
6237 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306238 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
6239 if ( NULL == pDstProfile->SSIDs.SSIDList )
6240 status = eHAL_STATUS_FAILURE;
6241 else
6242 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006243 if(!HAL_STATUS_SUCCESS(status))
6244 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306245 smsLog( pMac, LOGE,
6246 FL("failed to allocate memory for SSIDList"
6247 "%02x:%02x:%02x:%02x:%02x:%02x"),
6248 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6249 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006250 break;
6251 }
6252 pDstProfile->SSIDs.numOfSSIDs = 1;
6253 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
6254 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
Kiet Lam64c1b492013-07-12 13:56:44 +05306255 vos_mem_copy(&pDstProfile->SSIDs.SSIDList[0].SSID,
6256 &pSrcProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006257 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006258 if(pSrcProfile->nAddIEAssocLength)
6259 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306260 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6261 if ( NULL == pDstProfile->pAddIEAssoc)
6262 status = eHAL_STATUS_FAILURE;
6263 else
6264 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006265 if(!HAL_STATUS_SUCCESS(status))
6266 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006267 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs ") );
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006268 break;
6269 }
6270 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306271 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6272 pSrcProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006273 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306274 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(1);
6275 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6276 status = eHAL_STATUS_FAILURE;
6277 else
6278 status = eHAL_STATUS_SUCCESS;
6279
Jeff Johnson295189b2012-06-20 16:38:30 -07006280 if(!HAL_STATUS_SUCCESS(status))
6281 {
6282 break;
6283 }
6284 pDstProfile->ChannelInfo.numOfChannels = 1;
6285 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006286 pDstProfile->AuthType.numEntries = 1;
6287 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
6288 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
6289 pDstProfile->EncryptionType.numEntries = 1;
6290 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
6291 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
6292 pDstProfile->mcEncryptionType.numEntries = 1;
6293 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
6294 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
6295 pDstProfile->BSSType = pSrcProfile->BSSType;
6296 pDstProfile->CBMode = pSrcProfile->CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +05306297 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6298 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006299#ifdef WLAN_FEATURE_VOWIFI_11R
6300 if (pSrcProfile->MDID.mdiePresent)
6301 {
6302 pDstProfile->MDID.mdiePresent = 1;
6303 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6304 }
6305#endif
6306
6307 }while(0);
6308
6309 if(!HAL_STATUS_SUCCESS(status))
6310 {
6311 csrReleaseProfile(pMac, pDstProfile);
6312 pDstProfile = NULL;
6313 }
6314
6315 return (status);
6316}
6317
Jeff Johnson295189b2012-06-20 16:38:30 -07006318eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6319 tScanResultHandle hBSSList,
6320 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
6321 tANI_BOOLEAN fClearScan)
6322{
6323 eHalStatus status = eHAL_STATUS_SUCCESS;
6324 tSmeCmd *pCommand;
6325
6326 pCommand = csrGetCommandBuffer(pMac);
6327 if(NULL == pCommand)
6328 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006329 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006330 status = eHAL_STATUS_RESOURCES;
6331 }
6332 else
6333 {
6334 if( fClearScan )
6335 {
6336 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306337 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006338 }
6339 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6340 if(NULL == pProfile)
6341 {
6342 //We can roam now
6343 //Since pProfile is NULL, we need to build our own profile, set everything to default
6344 //We can only support open and no encryption
6345 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
6346 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
6347 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
6348 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6349 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
6350 }
6351 else
6352 {
6353 //make a copy of the profile
6354 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6355 if(HAL_STATUS_SUCCESS(status))
6356 {
6357 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6358 }
6359 }
6360 pCommand->command = eSmeCommandRoam;
6361 pCommand->sessionId = (tANI_U8)sessionId;
6362 pCommand->u.roamCmd.hBSSList = hBSSList;
6363 pCommand->u.roamCmd.roamId = roamId;
6364 pCommand->u.roamCmd.roamReason = reason;
6365 //We need to free the BssList when the command is done
6366 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
6367 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006368 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6369 FL("CSR PERSONA=%d"),
6370 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07006371 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6372 if( !HAL_STATUS_SUCCESS( status ) )
6373 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006374 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006375 csrReleaseCommandRoam( pMac, pCommand );
6376 }
6377 }
6378
6379 return (status);
6380}
Jeff Johnson295189b2012-06-20 16:38:30 -07006381eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6382 tCsrRoamModifyProfileFields *pMmodProfileFields,
6383 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
6384{
6385 eHalStatus status = eHAL_STATUS_SUCCESS;
6386 tSmeCmd *pCommand;
6387
6388 pCommand = csrGetCommandBuffer(pMac);
6389 if(NULL == pCommand)
6390 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006391 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006392 status = eHAL_STATUS_RESOURCES;
6393 }
6394 else
6395 {
6396 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306397 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006398 if(pProfile)
6399 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006400 //This is likely trying to reassoc to different profile
6401 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6402 //make a copy of the profile
6403 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6404 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006405 }
6406 else
6407 {
6408 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
6409 //how to update WPA/WPA2 info in roamProfile??
6410 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006411 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006412 if(HAL_STATUS_SUCCESS(status))
6413 {
6414 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6415 }
6416 pCommand->command = eSmeCommandRoam;
6417 pCommand->sessionId = (tANI_U8)sessionId;
6418 pCommand->u.roamCmd.roamId = roamId;
6419 pCommand->u.roamCmd.roamReason = reason;
6420 //We need to free the BssList when the command is done
6421 //For reassoc there is no BSS list, so the boolean set to false
6422 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
6423 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
6424 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006425 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6426 if( !HAL_STATUS_SUCCESS( status ) )
6427 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006428 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006429 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6430 csrReleaseCommandRoam( pMac, pCommand );
6431 }
6432 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006433 return (status);
6434}
6435
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006436eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
6437 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306438// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006439{
6440 eHalStatus status = eHAL_STATUS_SUCCESS;
6441 tSmeCmd *pCommand;
6442
6443 pCommand = csrGetCommandBuffer(pMac);
6444 if(NULL == pCommand)
6445 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006446 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006447 status = eHAL_STATUS_RESOURCES;
6448 }
6449 else
6450 {
6451 if(pBssDescription)
6452 {
6453 //copy over the parameters we need later
6454 pCommand->command = eSmeCommandRoam;
6455 pCommand->sessionId = (tANI_U8)sessionId;
6456 pCommand->u.roamCmd.roamReason = reason;
6457 //this is the important parameter
6458 //in this case we are using this field for the "next" BSS
6459 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
6460 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
6461 if( !HAL_STATUS_SUCCESS( status ) )
6462 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006463 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d"), status );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006464 csrReleaseCommandPreauth( pMac, pCommand );
6465 }
6466 }
6467 else
6468 {
6469 //Return failure
6470 status = eHAL_STATUS_RESOURCES;
6471 }
6472 }
6473 return (status);
6474}
6475
6476eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
6477{
6478 tListElem *pEntry;
6479 tSmeCmd *pCommand;
6480 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6481 if ( pEntry )
6482 {
6483 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6484 if ( (eSmeCommandRoam == pCommand->command) &&
6485 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
6486 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006487 smsLog( pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006488 pCommand->command, pCommand->u.roamCmd.roamReason);
6489 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
6490 csrReleaseCommandPreauth( pMac, pCommand );
6491 }
6492 } else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006493 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d "),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006494 pCommand->command, pCommand->u.roamCmd.roamReason);
6495 }
6496 }
6497 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006498 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006499 }
6500 smeProcessPendingQueue( pMac );
6501 return eHAL_STATUS_SUCCESS;
6502}
6503
Jeff Johnson295189b2012-06-20 16:38:30 -07006504eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6505 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6506{
6507 eHalStatus status = eHAL_STATUS_FAILURE;
6508 tScanResultHandle hBSSList;
6509 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006510 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
6511 if(HAL_STATUS_SUCCESS(status))
6512 {
6513 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6514 if(pRoamId)
6515 {
6516 *pRoamId = roamId;
6517 }
6518 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6519 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6520 if(!HAL_STATUS_SUCCESS(status))
6521 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006522 smsLog(pMac, LOGE, FL("failed to start a join process"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006523 csrScanResultPurge(pMac, hBSSList);
6524 }
6525 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006526 return (status);
6527}
6528
Jeff Johnson295189b2012-06-20 16:38:30 -07006529eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6530 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6531{
6532 eHalStatus status = eHAL_STATUS_SUCCESS;
6533 tScanResultHandle hBSSList;
6534 tCsrScanResultFilter *pScanFilter;
6535 tANI_U32 roamId = 0;
6536 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
6537 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006538 if (NULL == pProfile)
6539 {
6540 smsLog(pMac, LOGP, FL("No profile specified"));
6541 return eHAL_STATUS_FAILURE;
6542 }
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05306543 smsLog(pMac, LOG1, FL("called BSSType = %s (%d) authtype = %d "
6544 "encryType = %d"),
6545 lim_BssTypetoString(pProfile->BSSType),
6546 pProfile->BSSType,
6547 pProfile->AuthType.authType[0],
6548 pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006549 if( CSR_IS_WDS( pProfile ) &&
6550 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
6551 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006552 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d"),
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006553 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006554 return status;
6555 }
6556 csrRoamCancelRoaming(pMac, sessionId);
6557 csrScanRemoveFreshScanCommand(pMac, sessionId);
6558 csrScanCancelIdleScan(pMac);
6559 //Only abort the scan if it is not used for other roam/connect purpose
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05306560 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Jeff Johnson295189b2012-06-20 16:38:30 -07006561 if (!vos_concurrent_sessions_running() && (VOS_STA_SAP_MODE == pProfile->csrPersona))//In case of AP mode we do not want idle mode scan
6562 {
6563 csrScanDisable(pMac);
6564 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006565 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6566 //Check whether ssid changes
6567 if(csrIsConnStateConnected(pMac, sessionId))
6568 {
6569 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6570 {
6571 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6572 }
6573 }
6574#ifdef FEATURE_WLAN_BTAMP_UT_RF
6575 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
6576#endif
6577 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
6578 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006579 smsLog(pMac, LOG1, FL("is called with BSSList"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006580 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
6581 if(pRoamId)
6582 {
6583 roamId = *pRoamId;
6584 }
6585 if(!HAL_STATUS_SUCCESS(status))
6586 {
6587 fCallCallback = eANI_BOOLEAN_TRUE;
6588 }
6589 }
6590 else
6591 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306592 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
6593 if ( NULL == pScanFilter )
6594 status = eHAL_STATUS_FAILURE;
6595 else
6596 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006597 if(HAL_STATUS_SUCCESS(status))
6598 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306599 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006600 //Try to connect to any BSS
6601 if(NULL == pProfile)
6602 {
6603 //No encryption
6604 pScanFilter->EncryptionType.numEntries = 1;
6605 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6606 }//we don't have a profile
6607 else
6608 {
6609 //Here is the profile we need to connect to
6610 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6611 }//We have a profile
6612 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6613 if(pRoamId)
6614 {
6615 *pRoamId = roamId;
6616 }
6617
6618 if(HAL_STATUS_SUCCESS(status))
6619 {
6620 /*Save the WPS info*/
6621 if(NULL != pProfile)
6622 {
6623 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006624 pScanFilter->bOSENAssociation = pProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07006625 }
6626 else
6627 {
6628 pScanFilter->bWPSAssociation = 0;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006629 pScanFilter->bOSENAssociation = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006630 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006631 do
6632 {
6633 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006634 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006635 )
6636 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006637 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07006638 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6639 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6640 if(!HAL_STATUS_SUCCESS(status))
6641 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006642 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006643 fCallCallback = eANI_BOOLEAN_TRUE;
6644 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006645 else
6646 {
6647 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
6648 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006649 break;
6650 }
6651 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006652 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006653 if(HAL_STATUS_SUCCESS(status))
6654 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006655 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6656 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6657 if(!HAL_STATUS_SUCCESS(status))
6658 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006659 smsLog(pMac, LOGE, FL(" CSR failed to issue connect command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006660 csrScanResultPurge(pMac, hBSSList);
6661 fCallCallback = eANI_BOOLEAN_TRUE;
6662 }
6663 }//Have scan result
6664 else if(NULL != pProfile)
6665 {
6666 //Check whether it is for start ibss
6667 if(CSR_IS_START_IBSS(pProfile))
6668 {
6669 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6670 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6671 if(!HAL_STATUS_SUCCESS(status))
6672 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006673 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006674 fCallCallback = eANI_BOOLEAN_TRUE;
6675 }
6676 }
6677 else
6678 {
6679 //scan for this SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006680 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006681 if(!HAL_STATUS_SUCCESS(status))
6682 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006683 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006684 fCallCallback = eANI_BOOLEAN_TRUE;
6685 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006686 else
6687 {
6688 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
6689 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006690 }
6691 }
6692 else
6693 {
6694 fCallCallback = eANI_BOOLEAN_TRUE;
6695 }
6696 } while (0);
6697 if(NULL != pProfile)
6698 {
6699 //we need to free memory for filter if profile exists
6700 csrFreeScanFilter(pMac, pScanFilter);
6701 }
6702 }//Got the scan filter from profile
6703
Kiet Lam64c1b492013-07-12 13:56:44 +05306704 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006705 }//allocated memory for pScanFilter
6706 }//No Bsslist coming in
6707 //tell the caller if we fail to trigger a join request
6708 if( fCallCallback )
6709 {
6710 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6711 }
6712
6713 return (status);
6714}
Jeff Johnson295189b2012-06-20 16:38:30 -07006715eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6716 tCsrRoamModifyProfileFields modProfileFields,
6717 tANI_U32 *pRoamId)
6718{
6719 eHalStatus status = eHAL_STATUS_SUCCESS;
6720 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
6721 tANI_U32 roamId = 0;
6722 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006723 if (NULL == pProfile)
6724 {
6725 smsLog(pMac, LOGP, FL("No profile specified"));
6726 return eHAL_STATUS_FAILURE;
6727 }
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05306728 smsLog(pMac, LOG1, FL("called BSSType = %s (%d) authtype = %d "
6729 "encryType = %d"),
6730 lim_BssTypetoString(pProfile->BSSType),
6731 pProfile->BSSType,
6732 pProfile->AuthType.authType[0],
6733 pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006734 csrRoamCancelRoaming(pMac, sessionId);
6735 csrScanRemoveFreshScanCommand(pMac, sessionId);
6736 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306737 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006738 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07006739 if(csrIsConnStateConnected(pMac, sessionId))
6740 {
6741 if(pProfile)
6742 {
6743 if(pProfile->SSIDs.numOfSSIDs &&
6744 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6745 {
6746 fCallCallback = eANI_BOOLEAN_FALSE;
6747 }
6748 else
6749 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006750 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006751 }
6752 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306753 else if (!vos_mem_compare(&modProfileFields,
6754 &pSession->connectedProfile.modifyProfileFields,
6755 sizeof(tCsrRoamModifyProfileFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -07006756 {
6757 fCallCallback = eANI_BOOLEAN_FALSE;
6758 }
6759 else
6760 {
6761 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006762 "in tCsrRoamModifyProfileFields got modified"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006763 }
6764 }
6765 else
6766 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006767 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006768 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006769 if(!fCallCallback)
6770 {
6771 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6772 if(pRoamId)
6773 {
6774 *pRoamId = roamId;
6775 }
6776
Jeff Johnson295189b2012-06-20 16:38:30 -07006777 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
6778 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006779 }
6780 else
6781 {
6782 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
6783 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6784 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006785 return status;
6786}
Jeff Johnson295189b2012-06-20 16:38:30 -07006787eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6788{
6789 eHalStatus status = eHAL_STATUS_FAILURE;
6790 tScanResultHandle hBSSList = NULL;
6791 tCsrScanResultFilter *pScanFilter = NULL;
6792 tANI_U32 roamId;
6793 tCsrRoamProfile *pProfile = NULL;
6794 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006795
6796 if(!pSession)
6797 {
6798 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6799 return eHAL_STATUS_FAILURE;
6800 }
6801
Jeff Johnson295189b2012-06-20 16:38:30 -07006802 do
6803 {
6804 if(pSession->pCurRoamProfile)
6805 {
6806 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306807 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006808 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
Kiet Lam64c1b492013-07-12 13:56:44 +05306809 pProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
6810 if ( NULL == pProfile )
6811 status = eHAL_STATUS_FAILURE;
6812 else
6813 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006814 if(!HAL_STATUS_SUCCESS(status))
6815 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05306816 vos_mem_set(pProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006817 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05306818 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006819 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05306820 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
6821 if ( NULL == pScanFilter )
6822 status = eHAL_STATUS_FAILURE;
6823 else
6824 status = eHAL_STATUS_SUCCESS;
6825
Jeff Johnson295189b2012-06-20 16:38:30 -07006826 if(!HAL_STATUS_SUCCESS(status))
6827 {
6828 break;
6829 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306830 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006831 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6832 if(!HAL_STATUS_SUCCESS(status))
6833 {
6834 break;
6835 }
6836 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6837 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
6838 if(HAL_STATUS_SUCCESS(status))
6839 {
6840 //we want to put the last connected BSS to the very beginning, if possible
6841 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
6842 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6843 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6844 if(!HAL_STATUS_SUCCESS(status))
6845 {
6846 csrScanResultPurge(pMac, hBSSList);
6847 break;
6848 }
6849 }
6850 else
6851 {
6852 //Do a scan on this profile
6853 //scan for this SSID only in case the AP suppresses SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006854 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006855 if(!HAL_STATUS_SUCCESS(status))
6856 {
6857 break;
6858 }
6859 }
6860 }//We have a profile
6861 else
6862 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006863 smsLog(pMac, LOGW, FL("cannot find a roaming profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006864 break;
6865 }
6866 }while(0);
6867 if(pScanFilter)
6868 {
6869 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05306870 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006871 }
6872 if(NULL != pProfile)
6873 {
6874 csrReleaseProfile(pMac, pProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05306875 vos_mem_free(pProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07006876 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006877 return (status);
6878}
Jeff Johnson295189b2012-06-20 16:38:30 -07006879eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
6880{
6881 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006882 if(csrIsConnStateConnected(pMac, sessionId))
6883 {
6884 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6885 if(HAL_STATUS_SUCCESS(status))
6886 {
6887 status = csrRoamJoinLastProfile(pMac, sessionId);
6888 }
6889 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006890 return (status);
6891}
6892
Jeff Johnson295189b2012-06-20 16:38:30 -07006893eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6894{
6895 eHalStatus status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006896 smsLog(pMac, LOGW, FL("is called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006897 csrRoamCancelRoaming(pMac, sessionId);
6898 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6899 if(csrIsConnStateDisconnected(pMac, sessionId))
6900 {
6901 status = csrRoamJoinLastProfile(pMac, sessionId);
6902 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006903 return (status);
6904}
6905
Jeff Johnson295189b2012-06-20 16:38:30 -07006906eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
6907{
6908 eHalStatus status = eHAL_STATUS_SUCCESS;
6909 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
6910 eCsrRoamSubState NewSubstate;
6911 tANI_U32 sessionId = pCommand->sessionId;
Abhishek Singhf4669da2014-05-26 15:07:49 +05306912
6913 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
6914 {
6915 smsLog(pMac, LOG1, FL(" Stop Wait for key timer and change substate to"
6916 " eCSR_ROAM_SUBSTATE_NONE"));
6917 csrRoamStopWaitForKeyTimer( pMac );
6918 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6919 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006920 // change state to 'Roaming'...
6921 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
6922
6923 if ( csrIsConnStateIbss( pMac, sessionId ) )
6924 {
6925 // If we are in an IBSS, then stop the IBSS...
6926 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6927 fComplete = (!HAL_STATUS_SUCCESS(status));
6928 }
6929 else if ( csrIsConnStateInfra( pMac, sessionId ) )
6930 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006931 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 -07006932 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
6933 //Restore AC weight in case we change it
6934 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
6935 // in Infrasturcture, we need to disassociate from the Infrastructure network...
6936 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
6937 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
6938 {
6939 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
6940 }
Abhishek Singhcf4590b2014-04-16 18:58:08 +05306941 else
6942 {
6943 // If we are in neighbor preauth done state then on receiving
6944 // disassoc or deauth we dont roam instead we just disassoc
6945 // from current ap and then go to disconnected state
6946 // This happens for ESE and 11r FT connections ONLY.
6947#ifdef WLAN_FEATURE_VOWIFI_11R
6948 if (csrRoamIs11rAssoc(pMac) &&
6949 (csrNeighborRoamStatePreauthDone(pMac)))
6950 {
6951 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
6952 }
6953#endif
6954#ifdef FEATURE_WLAN_ESE
6955 if (csrRoamIsESEAssoc(pMac) &&
6956 (csrNeighborRoamStatePreauthDone(pMac)))
6957 {
6958 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
6959 }
6960#endif
6961#ifdef FEATURE_WLAN_LFR
6962 if (csrRoamIsFastRoamEnabled(pMac, sessionId) &&
6963 (csrNeighborRoamStatePreauthDone(pMac)))
6964 {
6965 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
6966 }
6967#endif
6968 }
6969
Jeff Johnson295189b2012-06-20 16:38:30 -07006970 if( fDisassoc )
6971 {
6972 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
6973 }
6974 else
6975 {
6976 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
6977 }
6978 fComplete = (!HAL_STATUS_SUCCESS(status));
6979 }
6980 else if ( csrIsConnStateWds( pMac, sessionId ) )
6981 {
6982 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
6983 {
6984 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6985 fComplete = (!HAL_STATUS_SUCCESS(status));
6986 }
6987 //This has to be WDS station
6988 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
6989 {
6990
6991 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
6992 if( fDisassoc )
6993 {
6994 status = csrRoamIssueDisassociate( pMac, sessionId,
6995 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
6996 fComplete = (!HAL_STATUS_SUCCESS(status));
6997 }
6998 }
6999 } else {
7000 // we got a dis-assoc request while not connected to any peer
7001 // just complete the command
7002 fComplete = eANI_BOOLEAN_TRUE;
7003 status = eHAL_STATUS_FAILURE;
7004 }
7005 if(fComplete)
7006 {
7007 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7008 }
7009
7010 if(HAL_STATUS_SUCCESS(status))
7011 {
7012 if ( csrIsConnStateInfra( pMac, sessionId ) )
7013 {
7014 //Set the state to disconnect here
7015 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7016 }
7017 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007018 else
7019 {
7020 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
7021 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007022 return (status);
7023}
7024
Jeff Johnson295189b2012-06-20 16:38:30 -07007025/* This is been removed from latest code base */
7026/*
7027static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
7028{
7029 eHalStatus status;
7030 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007031 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
7032 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007033 return ( status );
7034}
7035*/
7036
Jeff Johnson295189b2012-06-20 16:38:30 -07007037eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
7038{
7039 eHalStatus status = eHAL_STATUS_SUCCESS;
7040 tSmeCmd *pCommand;
7041 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007042 do
7043 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08007044 smsLog( pMac, LOG1, FL(" reason = %d"), reason );
Jeff Johnson295189b2012-06-20 16:38:30 -07007045 pCommand = csrGetCommandBuffer( pMac );
7046 if ( !pCommand )
7047 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007048 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007049 status = eHAL_STATUS_RESOURCES;
7050 break;
7051 }
7052 //Change the substate in case it is wait-for-key
7053 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7054 {
7055 csrRoamStopWaitForKeyTimer( pMac );
7056 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7057 }
7058 pCommand->command = eSmeCommandRoam;
7059 pCommand->sessionId = (tANI_U8)sessionId;
7060 switch ( reason )
7061 {
7062 case eCSR_DISCONNECT_REASON_MIC_ERROR:
7063 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
7064 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007065 case eCSR_DISCONNECT_REASON_DEAUTH:
7066 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
7067 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007068 case eCSR_DISCONNECT_REASON_HANDOFF:
7069 fHighPriority = eANI_BOOLEAN_TRUE;
7070 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
7071 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007072 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
7073 case eCSR_DISCONNECT_REASON_DISASSOC:
7074 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
7075 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007076 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
7077 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
7078 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007079 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
7080 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
7081 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007082 default:
7083 break;
7084 }
7085 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7086 if( !HAL_STATUS_SUCCESS( status ) )
7087 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007088 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007089 csrReleaseCommandRoam( pMac, pCommand );
7090 }
7091 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07007092 return( status );
7093}
7094
Jeff Johnson295189b2012-06-20 16:38:30 -07007095eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
7096{
7097 eHalStatus status = eHAL_STATUS_SUCCESS;
7098 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007099 pCommand = csrGetCommandBuffer( pMac );
7100 if ( NULL != pCommand )
7101 {
7102 //Change the substate in case it is wait-for-key
7103 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
7104 {
7105 csrRoamStopWaitForKeyTimer( pMac );
7106 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7107 }
7108 pCommand->command = eSmeCommandRoam;
7109 pCommand->sessionId = (tANI_U8)sessionId;
7110 pCommand->u.roamCmd.roamReason = eCsrStopBss;
7111 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7112 if( !HAL_STATUS_SUCCESS( status ) )
7113 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007114 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007115 csrReleaseCommandRoam( pMac, pCommand );
7116 }
7117 }
7118 else
7119 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007120 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007121 status = eHAL_STATUS_RESOURCES;
7122 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007123 return ( status );
7124}
7125
Jeff Johnson295189b2012-06-20 16:38:30 -07007126eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7127{
7128 eHalStatus status = eHAL_STATUS_SUCCESS;
7129 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007130
7131 if(!pSession)
7132 {
7133 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7134 return eHAL_STATUS_FAILURE;
7135 }
7136
Jeff Johnson295189b2012-06-20 16:38:30 -07007137#ifdef FEATURE_WLAN_BTAMP_UT_RF
7138 //Stop te retry
7139 pSession->maxRetryCount = 0;
7140 csrRoamStopJoinRetryTimer(pMac, sessionId);
7141#endif
7142 //Not to call cancel roaming here
7143 //Only issue disconnect when necessary
7144 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
7145 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
7146 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
7147
7148 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007149 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007150 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
7151 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307152 else
7153 {
7154 smsLog( pMac, LOGE, FL("Roam command is not present"));
7155 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007156 return (status);
7157}
7158
Jeff Johnson295189b2012-06-20 16:38:30 -07007159eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7160{
7161 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007162
7163 if(!pSession)
7164 {
7165 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7166 return eHAL_STATUS_FAILURE;
7167 }
7168
Jeff Johnson295189b2012-06-20 16:38:30 -07007169 csrRoamCancelRoaming(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007170 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
7171
7172 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
7173}
7174
Jeff Johnson295189b2012-06-20 16:38:30 -07007175eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
7176 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
7177{
7178 eHalStatus status = eHAL_STATUS_SUCCESS;
7179 tDot11fBeaconIEs *pIesTemp = pIes;
7180 tANI_U8 index;
7181 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7182 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007183
7184 if(!pSession)
7185 {
7186 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7187 return eHAL_STATUS_FAILURE;
7188 }
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007189 if(pConnectProfile->pAddIEAssoc)
7190 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307191 vos_mem_free(pConnectProfile->pAddIEAssoc);
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007192 pConnectProfile->pAddIEAssoc = NULL;
7193 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307194 vos_mem_set(&pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007195 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
7196 pConnectProfile->AuthInfo = pProfile->AuthType;
7197 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
7198 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
7199 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
7200 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
7201 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
7202 pConnectProfile->BSSType = pProfile->BSSType;
7203 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
7204 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07007205 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
AnjaneeDevi Kapparapu4b043912014-02-18 13:22:35 +05307206 if (!pConnectProfile->beaconInterval)
7207 {
7208 smsLog(pMac, LOGW, FL("ERROR: Beacon interval is ZERO"));
7209 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307210 vos_mem_copy(&pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007211 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
7212 if(pProfile->nAddIEAssocLength)
7213 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307214 pConnectProfile->pAddIEAssoc = vos_mem_malloc(pProfile->nAddIEAssocLength);
7215 if ( NULL == pConnectProfile->pAddIEAssoc )
7216 status = eHAL_STATUS_FAILURE;
7217 else
7218 status = eHAL_STATUS_SUCCESS;
7219 if (!HAL_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007220 {
7221 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
7222 return eHAL_STATUS_FAILURE;
7223 }
7224 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05307225 vos_mem_copy(pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
7226 pProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007227 }
7228
Jeff Johnson295189b2012-06-20 16:38:30 -07007229 //Save bssid
7230 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
7231#ifdef WLAN_FEATURE_VOWIFI_11R
7232 if (pSirBssDesc->mdiePresent)
7233 {
7234 pConnectProfile->MDID.mdiePresent = 1;
7235 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
7236 }
7237#endif
Leela Venkata Kiran Kumar Reddy Chiralad48e3272013-04-12 14:21:07 -07007238 if( NULL == pIesTemp )
7239 {
7240 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
7241 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007242#ifdef FEATURE_WLAN_ESE
7243 if ((csrIsProfileESE(pProfile) ||
7244 ((pIesTemp->ESEVersion.present)
Sandeep Puligilla798d6f22014-04-24 23:30:36 +05307245 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007246 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07007247 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007248 pConnectProfile->isESEAssoc = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007249 }
7250#endif
7251 //save ssid
Jeff Johnson295189b2012-06-20 16:38:30 -07007252 if(HAL_STATUS_SUCCESS(status))
7253 {
7254 if(pIesTemp->SSID.present)
7255 {
7256 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +05307257 vos_mem_copy(pConnectProfile->SSID.ssId, pIesTemp->SSID.ssid,
7258 pIesTemp->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07007259 }
7260
7261 //Save the bss desc
7262 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307263
7264 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07007265 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307266 //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 -07007267 pConnectProfile->qap = TRUE;
7268 }
7269 else
7270 {
7271 pConnectProfile->qap = FALSE;
7272 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007273 if ( NULL == pIes )
7274 {
7275 //Free memory if it allocated locally
Kiet Lam64c1b492013-07-12 13:56:44 +05307276 vos_mem_free(pIesTemp);
Jeff Johnson295189b2012-06-20 16:38:30 -07007277 }
7278 }
7279 //Save Qos connection
7280 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
7281
7282 if(!HAL_STATUS_SUCCESS(status))
7283 {
7284 csrFreeConnectBssDesc(pMac, sessionId);
7285 }
7286 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
7287 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307288 if ((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
7289 vos_mem_compare(pProfile->SSIDs.SSIDList[index].SSID.ssId,
7290 pConnectProfile->SSID.ssId,
7291 pConnectProfile->SSID.length))
Jeff Johnson295189b2012-06-20 16:38:30 -07007292 {
7293 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
7294 break;
7295 }
7296 pConnectProfile->handoffPermitted = FALSE;
7297 }
7298
7299 return (status);
7300}
7301
Jeff Johnson295189b2012-06-20 16:38:30 -07007302static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
7303{
7304 tListElem *pEntry = NULL;
7305 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007306 //The head of the active list is the request we sent
7307 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7308 if(pEntry)
7309 {
7310 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7311 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007312 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7313 {
7314 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
7315 {
7316#ifndef WLAN_MDM_CODE_REDUCTION_OPT
7317 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7318#endif
7319 }
7320 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
7321 }
7322 else
7323 {
7324 tANI_U32 roamId = 0;
7325 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007326 if(!pSession)
7327 {
7328 smsLog(pMac, LOGE, FL(" session %d not found "), pSmeJoinRsp->sessionId);
7329 return;
7330 }
7331
Jeff Johnson295189b2012-06-20 16:38:30 -07007332
7333 //The head of the active list is the request we sent
7334 //Try to get back the same profile and roam again
7335 if(pCommand)
7336 {
7337 roamId = pCommand->u.roamCmd.roamId;
7338 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007339 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
7340 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007341 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007342#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7343 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
7344 if (csrRoamIsHandoffInProgress(pMac))
7345 {
7346 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
7347 /* Should indicate neighbor roam algorithm about the connect failure here */
7348 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
7349 }
7350#endif
7351 if (pCommand)
7352 {
7353 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
7354 {
7355 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7356 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
7357 csrRoamReissueRoamCommand(pMac);
7358 }
7359 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
7360 {
7361 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7362 }
7363 else
7364 {
7365 csrRoam(pMac, pCommand);
7366 }
7367 }
7368 else
7369 {
7370 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7371 }
7372 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
7373}
7374
Jeff Johnson295189b2012-06-20 16:38:30 -07007375eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7376 tDot11fBeaconIEs *pIes,
7377 tCsrRoamProfile *pProfile, tANI_U32 roamId )
7378{
7379 eHalStatus status;
Arif Hussain24bafea2013-11-15 15:10:03 -08007380 smsLog( pMac, LOG1, "Attempting to Join Bssid= "MAC_ADDRESS_STR,
7381 MAC_ADDR_ARRAY(pSirBssDesc->bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07007382
7383 // Set the roaming substate to 'join attempt'...
7384 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007385 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007386 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007387 return (status);
7388}
7389
Jeff Johnson295189b2012-06-20 16:38:30 -07007390static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7391 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
7392{
7393 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007394 // Set the roaming substate to 'join attempt'...
7395 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
7396
Kaushik, Sushant8489f472014-01-27 11:41:22 +05307397 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7398 FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007399
7400 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007401 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07007402}
7403
Jeff Johnson295189b2012-06-20 16:38:30 -07007404void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
7405{
7406 tListElem *pEntry;
7407 tSmeCmd *pCommand;
7408 tCsrRoamInfo roamInfo;
7409 tANI_U32 sessionId;
7410 tCsrRoamSession *pSession;
7411
7412 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7413 if(pEntry)
7414 {
7415 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7416 if ( eSmeCommandRoam == pCommand->command )
7417 {
7418 sessionId = pCommand->sessionId;
7419 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007420
7421 if(!pSession)
7422 {
7423 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7424 return;
7425 }
Abhishek Singhaf15f152013-11-30 16:08:55 +05307426 /* While switching between two AP, csr will reissue roam command again
7427 to the nextbss if it was interrupted by the dissconnect req for the
7428 previous bss.During this csr is incrementing bRefAssocStartCnt twice.
7429 so reset the bRefAssocStartCnt.
7430 */
7431 if(pSession->bRefAssocStartCnt > 0)
7432 {
7433 pSession->bRefAssocStartCnt--;
7434 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007435 if( pCommand->u.roamCmd.fStopWds )
7436 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307437 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007438 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
7439 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
7440 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007441 if (CSR_IS_WDS(&pSession->connectedProfile)){
Jeff Johnson295189b2012-06-20 16:38:30 -07007442 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
7443 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7444 eCSR_ROAM_WDS_IND,
7445 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
Jeff Johnson295189b2012-06-20 16:38:30 -07007446 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
7447 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
7448 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7449 eCSR_ROAM_INFRA_IND,
7450 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
7451 }
7452
Jeff Johnson295189b2012-06-20 16:38:30 -07007453
Jeff Johnson295189b2012-06-20 16:38:30 -07007454 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
7455 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007456 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007457 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7458 }
7459 }
7460 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
7461 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007462 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007463 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7464 }
7465 }
7466 else
7467 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007468 smsLog(pMac, LOGW, " Command is not roaming after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007469 }
7470 }
7471 else
7472 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007473 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available");
Jeff Johnson295189b2012-06-20 16:38:30 -07007474 }
7475}
7476
Jeff Johnson295189b2012-06-20 16:38:30 -07007477tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
7478{
7479 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7480 tListElem *pEntry;
7481 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007482 //alwasy lock active list before locking pending list
7483 csrLLLock( &pMac->sme.smeCmdActiveList );
7484 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7485 if(pEntry)
7486 {
7487 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7488 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7489 {
7490 fRet = eANI_BOOLEAN_TRUE;
7491 }
7492 }
7493 if(eANI_BOOLEAN_FALSE == fRet)
7494 {
7495 csrLLLock(&pMac->sme.smeCmdPendingList);
7496 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
7497 while(pEntry)
7498 {
7499 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7500 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7501 {
7502 fRet = eANI_BOOLEAN_TRUE;
7503 break;
7504 }
7505 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7506 }
7507 csrLLUnlock(&pMac->sme.smeCmdPendingList);
7508 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307509 if (eANI_BOOLEAN_FALSE == fRet)
7510 {
7511 csrLLLock(&pMac->roam.roamCmdPendingList);
7512 pEntry = csrLLPeekHead(&pMac->roam.roamCmdPendingList, LL_ACCESS_NOLOCK);
7513 while (pEntry)
7514 {
7515 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7516 if (( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7517 {
7518 fRet = eANI_BOOLEAN_TRUE;
7519 break;
7520 }
7521 pEntry = csrLLNext(&pMac->roam.roamCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7522 }
7523 csrLLUnlock(&pMac->roam.roamCmdPendingList);
7524 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007525 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007526 return (fRet);
7527}
7528
Jeff Johnson295189b2012-06-20 16:38:30 -07007529tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
7530{
7531 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7532 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07007533 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
7534 {
7535 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
7536 {
7537 break;
7538 }
7539 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007540 return ( fRet );
7541}
7542
Jeff Johnson295189b2012-06-20 16:38:30 -07007543tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
7544{
7545 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007546 //alwasy lock active list before locking pending list
7547 csrLLLock( &pMac->sme.smeCmdActiveList );
7548 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7549 if(eANI_BOOLEAN_FALSE == fRet)
7550 {
7551 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
7552 }
7553 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007554 return (fRet);
7555}
7556
Jeff Johnson295189b2012-06-20 16:38:30 -07007557tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
7558{
7559 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7560 tListElem *pEntry;
7561 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007562 //alwasy lock active list before locking pending list
7563 csrLLLock( &pMac->sme.smeCmdActiveList );
7564 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7565 if( pEntry )
7566 {
7567 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
7568 if( ( eCsrRoamCommandScan == pCommand->command ) &&
7569 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
7570 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
7571 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
7572 {
7573 fRet = eANI_BOOLEAN_TRUE;
7574 }
7575 }
7576 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007577 return (fRet);
7578}
Jeff Johnson295189b2012-06-20 16:38:30 -07007579eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
7580{
7581 eHalStatus status = eHAL_STATUS_SUCCESS;
7582 tSmeCmd *pCommand = NULL;
7583 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
7584 tANI_BOOLEAN fRemoveCmd = FALSE;
7585 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07007586 // Delete the old assoc command. All is setup for reassoc to be serialized
7587 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7588 if ( pEntry )
7589 {
7590 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
7591 if ( !pCommand )
7592 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007593 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007594 return eHAL_STATUS_RESOURCES;
7595 }
7596 if ( eSmeCommandRoam == pCommand->command )
7597 {
7598 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
7599 {
7600 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7601 }
7602 else
7603 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007604 smsLog( pMac, LOGE, FL(" Unexpected active roam command present ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007605 }
7606 if (fRemoveCmd == FALSE)
7607 {
7608 // Implies we did not get the serialized assoc command we
7609 // were expecting
7610 pCommand = NULL;
7611 }
7612 }
7613 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007614 if(NULL == pCommand)
7615 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007616 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007617 return eHAL_STATUS_RESOURCES;
7618 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007619 do
7620 {
7621 //Change the substate in case it is wait-for-key
7622 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7623 {
7624 csrRoamStopWaitForKeyTimer( pMac );
7625 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
7626 }
7627 pCommand->command = eSmeCommandRoam;
7628 pCommand->sessionId = (tANI_U8)sessionId;
7629 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07007630 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7631 if( !HAL_STATUS_SUCCESS( status ) )
7632 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007633 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007634 csrReleaseCommandRoam( pMac, pCommand );
7635 }
7636 } while( 0 );
7637
Jeff Johnson295189b2012-06-20 16:38:30 -07007638 return( status );
7639}
7640static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
7641{
7642 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7643 tCsrScanResult *pScanResult = NULL;
7644 tSirBssDescription *pBssDesc = NULL;
7645 tSmeCmd *pCommand = NULL;
7646 tANI_U32 sessionId;
7647 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07007648 if(NULL == pEntry)
7649 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307650 smsLog(pMac, LOGE, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07007651 return;
7652 }
7653 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7654 sessionId = pCommand->sessionId;
7655 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007656
7657 if(!pSession)
7658 {
7659 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7660 return;
7661 }
7662
Jeff Johnson295189b2012-06-20 16:38:30 -07007663 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
7664 {
7665 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007666 smsLog(pMac, LOGW, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007667 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7668 }
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07007669 /* If the roaming has stopped, not to continue the roaming command*/
7670 else if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
7671 {
7672 //No need to complete roaming here as it already completes
7673 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed\n"),
7674 pCommand->u.roamCmd.roamReason);
7675 csrSetAbortRoamingCommand( pMac, pCommand );
7676 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7677 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007678 else
7679 {
7680 if ( CCM_IS_RESULT_SUCCESS(result) )
7681 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007682 smsLog(pMac, LOG2, "Cfg sequence complete");
Jeff Johnson295189b2012-06-20 16:38:30 -07007683 // Successfully set the configuration parameters for the new Bss. Attempt to
7684 // join the roaming Bss.
7685 if(pCommand->u.roamCmd.pRoamBssEntry)
7686 {
7687 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
7688 pBssDesc = &pScanResult->Result.BssDescriptor;
7689 }
7690 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
7691 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07007692 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07007693 )
7694 {
7695 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
7696 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
7697 pBssDesc, pCommand->u.roamCmd.roamId )))
7698 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307699 smsLog(pMac, LOGE, " CSR start BSS failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07007700 //We need to complete the command
7701 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7702 }
7703 }
7704 else
7705 {
7706 if (!pCommand->u.roamCmd.pRoamBssEntry)
7707 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307708 smsLog(pMac, LOGE, " pRoamBssEntry is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07007709 //We need to complete the command
7710 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
7711 return;
7712 }
7713 // If we are roaming TO an Infrastructure BSS...
7714 VOS_ASSERT(pScanResult != NULL);
7715 if ( csrIsInfraBssDesc( pBssDesc ) )
7716 {
7717 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07007718 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
7719 {
7720 // ..and currently in an Infrastructure connection....
7721 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
7722 {
7723 // ...and the SSIDs are equal, then we Reassoc.
7724 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
7725 pIesLocal ) )
7726 // ..and currently in an infrastructure connection
7727 {
7728 // then issue a Reassoc.
7729 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
7730 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
7731 &pCommand->u.roamCmd.roamProfile );
7732 }
7733 else
7734 {
7735
7736 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
7737 // previously associated AP.
7738 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7739 pIesLocal,
7740 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
7741 {
7742 //try something else
7743 csrRoam( pMac, pCommand );
7744 }
7745 }
7746 }
7747 else
7748 {
7749 eHalStatus status = eHAL_STATUS_SUCCESS;
7750
7751 /* We need to come with other way to figure out that this is because of HO in BMP
7752 The below API will be only available for Android as it uses a different HO algorithm */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007753 /* Reassoc request will be used only for ESE and 11r handoff whereas other legacy roaming should
Jeff Johnson295189b2012-06-20 16:38:30 -07007754 * use join request */
7755#ifdef WLAN_FEATURE_VOWIFI_11R
7756 if (csrRoamIsHandoffInProgress(pMac) &&
7757 csrRoamIs11rAssoc(pMac))
7758 {
7759 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
7760 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
7761 }
7762 else
7763#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007764#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07007765 if (csrRoamIsHandoffInProgress(pMac) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007766 csrRoamIsESEAssoc(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07007767 {
7768 // Now serialize the reassoc command.
7769 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7770 }
7771 else
7772#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007773#ifdef FEATURE_WLAN_LFR
7774 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05307775 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007776 {
7777 // Now serialize the reassoc command.
7778 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7779 }
7780 else
7781#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007782 // else we are not connected and attempting to Join. Issue the
7783 // Join request.
7784 {
7785 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7786 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
7787 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
7788 }
7789 if(!HAL_STATUS_SUCCESS(status))
7790 {
7791 //try something else
7792 csrRoam( pMac, pCommand );
7793 }
7794 }
7795 if( !pScanResult->Result.pvIes )
7796 {
7797 //Locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05307798 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07007799 }
7800 }
7801 }//if ( csrIsInfraBssDesc( pBssDesc ) )
7802 else
7803 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007804 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007805 }
7806 }//else
7807 }//if ( WNI_CFG_SUCCESS == result )
7808 else
7809 {
7810 // In the event the configuration failed, for infra let the roam processor
7811 //attempt to join something else...
7812 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
7813 {
7814 csrRoam(pMac, pCommand);
7815 }
7816 else
7817 {
7818 //We need to complete the command
7819 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
7820 {
7821 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7822 }
7823 else
7824 {
7825 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7826 }
7827 }
7828 }
7829 }//we have active entry
7830}
7831
Jeff Johnson295189b2012-06-20 16:38:30 -07007832static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
7833{
7834 //No one is sending eWNI_SME_AUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007835 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007836 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
7837 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007838 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007839 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
7840 // join the new one...
7841 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07007842 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
7843 }
7844 else {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007845 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08X [%d]", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007846 /***profHandleLostLinkAfterReset(pAdapter);
7847 // In the event the authenticate fails, let the roam processor attempt to join something else...
7848 roamRoam( pAdapter );***/
7849 }
7850}
7851
Jeff Johnson295189b2012-06-20 16:38:30 -07007852static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
7853{
7854 eCsrRoamCompleteResult result;
7855 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
7856 tCsrRoamInfo roamInfo;
7857 tANI_U32 roamId = 0;
7858
7859 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7860 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007861 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007862 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07007863 /* Defeaturize this part later if needed */
7864#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
7865 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
7866 * we need the response contents while processing the result in csrRoamProcessResults() */
7867 if (csrRoamIsHandoffInProgress(pMac))
7868 {
7869 /* Need to dig more on indicating events to SME QoS module */
7870 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7871 csrRoamComplete( pMac, result, pSmeJoinRsp);
7872 }
7873 else
7874#endif
7875 {
7876 csrRoamComplete( pMac, result, NULL );
7877 }
7878 }
7879 /* Should we handle this similar to handling the join failure? Is it ok
7880 * to call csrRoamComplete() with state as CsrJoinFailure */
7881 else
7882 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007883 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007884 result = eCsrReassocFailure;
7885#ifdef WLAN_FEATURE_VOWIFI_11R
7886 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
7887 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode))
7888 {
7889 // Inform HDD to turn off FT flag in HDD
7890 if (pNeighborRoamInfo)
7891 {
7892 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7893 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
7894 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07007895 /*
7896 * Since the above callback sends a disconnect
7897 * to HDD, we should clean-up our state
7898 * machine as well to be in sync with the upper
7899 * layers. There is no need to send a disassoc
7900 * since: 1) we will never reassoc to the current
7901 * AP in LFR, and 2) there is no need to issue a
7902 * disassoc to the AP with which we were trying
7903 * to reassoc.
7904 */
7905 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7906 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07007907 }
7908 }
7909#endif
7910 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
7911 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
7912 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
7913 //The disassoc rsp message will remove the command from active list
7914 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
7915 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
7916 {
7917 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7918 }
7919 }
7920}
7921
Jeff Johnson295189b2012-06-20 16:38:30 -07007922static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
7923{
Jeff Johnson295189b2012-06-20 16:38:30 -07007924#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7925 {
7926 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07007927 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
7928 if(pIbssLog)
7929 {
7930 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
7931 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
7932 {
7933 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
7934 }
7935 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
7936 }
7937 }
7938#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07007939 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7940 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
7941 {
7942 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7943 }
7944 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
7945 {
7946 csrRoamReissueRoamCommand(pMac);
7947 }
7948}
7949
Jeff Johnson295189b2012-06-20 16:38:30 -07007950void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
7951{
7952 tSirResultCodes statusCode;
7953#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7954 tScanResultHandle hBSSList;
7955 tANI_BOOLEAN fCallCallback, fRemoveCmd;
7956 eHalStatus status;
7957 tCsrRoamInfo roamInfo;
7958 tCsrScanResultFilter *pScanFilter = NULL;
7959 tANI_U32 roamId = 0;
7960 tCsrRoamProfile *pCurRoamProfile = NULL;
7961 tListElem *pEntry = NULL;
7962 tSmeCmd *pCommand = NULL;
7963#endif
7964 tANI_U32 sessionId;
7965 tCsrRoamSession *pSession;
Jeff Johnsone7245742012-09-05 17:12:55 -07007966
Jeff Johnson295189b2012-06-20 16:38:30 -07007967 tSirSmeDisassocRsp SmeDisassocRsp;
7968
7969 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
7970 sessionId = SmeDisassocRsp.sessionId;
7971 statusCode = SmeDisassocRsp.statusCode;
7972
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007973 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007974
7975 if ( csrIsConnStateInfra( pMac, sessionId ) )
7976 {
7977 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7978 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007979 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007980
7981 if(!pSession)
7982 {
7983 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7984 return;
7985 }
7986
Jeff Johnson295189b2012-06-20 16:38:30 -07007987 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
7988 {
7989 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7990 }
7991 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
7992 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
7993 {
7994 if ( eSIR_SME_SUCCESS == statusCode )
7995 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007996 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007997 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
7998 }
7999 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8000 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008001 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
8002 {
Kaushik, Sushant8489f472014-01-27 11:41:22 +05308003 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH,
8004 "CSR SmeDisassocReq due to HO on session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07008005#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008006 /*
8007 * First ensure if the roam profile is in the scan cache.
8008 * If not, post a reassoc failure and disconnect.
8009 */
Kiet Lam64c1b492013-07-12 13:56:44 +05308010 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
8011 if ( NULL == pScanFilter )
8012 status = eHAL_STATUS_FAILURE;
8013 else
8014 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008015 if(HAL_STATUS_SUCCESS(status))
8016 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308017 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008018 status = csrRoamPrepareFilterFromProfile(pMac,
8019 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
8020 if(!HAL_STATUS_SUCCESS(status))
8021 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008022 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008023 __func__, status);
8024 goto POST_ROAM_FAILURE;
8025 }
8026 else
8027 {
8028 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
8029 if (!HAL_STATUS_SUCCESS(status))
8030 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008031 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008032 __func__, status);
8033 goto POST_ROAM_FAILURE;
8034 }
8035 }
8036 }
8037 else
8038 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008039 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008040 __func__, status);
8041 goto POST_ROAM_FAILURE;
8042 }
8043
8044 /*
8045 * After ensuring that the roam profile is in the scan result list,
8046 * dequeue the command from the active list.
8047 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008048 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
8049 if ( pEntry )
8050 {
8051 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008052 /* If the head of the queue is Active and it is a ROAM command, remove
8053 * and put this on the Free queue.
8054 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008055 if ( eSmeCommandRoam == pCommand->command )
8056 {
Jeff Johnsone7245742012-09-05 17:12:55 -07008057
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008058 /*
8059 * we need to process the result first before removing it from active list
8060 * because state changes still happening insides roamQProcessRoamResults so
8061 * no other roam command should be issued.
8062 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008063 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
8064 if(pCommand->u.roamCmd.fReleaseProfile)
8065 {
8066 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
8067 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
8068 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008069 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07008070 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07008071 else
8072 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008073 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008074 __func__, pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07008075 }
8076 }
8077 else
8078 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008079 smsLog( pMac, LOGE, "%s: roam command not active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008080 }
8081 }
8082 else
8083 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008084 smsLog( pMac, LOGE, "%s: NO commands are active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008085 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008086
8087 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07008088 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
8089
Kiet Lam64c1b492013-07-12 13:56:44 +05308090 vos_mem_copy(roamInfo.bssid,
8091 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
8092 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008093
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008094 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
8095 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008096
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008097 /* Copy the connected profile to apply the same for this connection as well */
Kiet Lam64c1b492013-07-12 13:56:44 +05308098 pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
8099 if ( pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07008100 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308101 vos_mem_set(pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008102 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
8103 //make sure to put it at the head of the cmd queue
8104 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
8105 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
8106 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
8107
Jeff Johnson295189b2012-06-20 16:38:30 -07008108 if(!HAL_STATUS_SUCCESS(status))
8109 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008110 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008111 __func__, status);
8112 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008113 }
8114
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008115 /* Notify sub-modules like QoS etc. that handoff happening */
8116 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08008117 csrReleaseProfile(pMac, pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05308118 vos_mem_free(pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07008119 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308120 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008121 return;
8122 }
8123
8124POST_ROAM_FAILURE:
8125 if (pScanFilter)
8126 {
8127 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308128 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008129 }
8130 if (pCurRoamProfile)
Kiet Lam64c1b492013-07-12 13:56:44 +05308131 vos_mem_free(pCurRoamProfile);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008132
8133 /* Inform the upper layers that the reassoc failed */
8134 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
8135 csrRoamCallCallback(pMac, sessionId,
8136 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
8137
8138 /*
8139 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
8140 * Upon success, we would re-enter this routine after receiving the disassoc
8141 * response and will fall into the reassoc fail sub-state. And, eventually
8142 * call csrRoamComplete which would remove the roam command from SME active
8143 * queue.
8144 */
8145 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
8146 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
8147 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008148 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008149 __func__, status);
8150 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07008151 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008152#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008153
Jeff Johnson295189b2012-06-20 16:38:30 -07008154 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
8155 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
8156 {
8157 // Disassoc due to Reassoc failure falls into this codepath....
8158 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8159 }
8160 else
8161 {
8162 if ( eSIR_SME_SUCCESS == statusCode )
8163 {
8164 // Successfully disassociated from the 'old' Bss...
8165 //
8166 // We get Disassociate response in three conditions.
8167 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
8168 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
8169 // Infrastructure network.
8170 // - Third is where we are doing an Infra to Infra roam between networks with different
8171 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
8172
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008173 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008174 }
8175 else
8176 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008177 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008178 }
8179 //We are not done yet. Get the data and continue roaming
8180 csrRoamReissueRoamCommand(pMac);
8181 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008182}
8183
Jeff Johnson295189b2012-06-20 16:38:30 -07008184static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
8185{
8186 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008187 //No one is sending eWNI_SME_DEAUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008188 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008189 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08008190 pMac->roam.deauthRspStatus = statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008191 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
8192 {
8193 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8194 }
8195 else
8196 {
8197 if ( eSIR_SME_SUCCESS == statusCode )
8198 {
8199 // Successfully deauth from the 'old' Bss...
8200 //
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008201 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008202 }
8203 else
8204 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008205 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008206 }
8207 //We are not done yet. Get the data and continue roaming
8208 csrRoamReissueRoamCommand(pMac);
8209 }
8210}
8211
Jeff Johnson295189b2012-06-20 16:38:30 -07008212static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
8213{
8214 eCsrRoamCompleteResult result;
8215
8216 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
8217 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008218 smsLog( pMac, LOGW, "SmeStartBssReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008219 result = eCsrStartBssSuccess;
8220 }
8221 else
8222 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008223 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08X", pSmeStartBssRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008224 //Let csrRoamComplete decide what to do
8225 result = eCsrStartBssFailure;
8226 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008227 csrRoamComplete( pMac, result, pSmeStartBssRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -07008228}
8229
Jeff Johnson295189b2012-06-20 16:38:30 -07008230/*
8231 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
8232 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
8233 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
8234 For the messages where sender allocates memory for specific structures, then it can be
8235 cast accordingly.
8236*/
8237void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8238{
8239 tSirSmeRsp *pSmeRsp;
8240 tSmeIbssPeerInd *pIbssPeerInd;
8241 tCsrRoamInfo roamInfo;
8242 // TODO Session Id need to be acquired in this function
8243 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008244 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308245 smsLog(pMac, LOG2, FL("Message %d[0x%04X] received in substate %s"),
8246 pSmeRsp->messageType, pSmeRsp->messageType,
8247 macTraceGetcsrRoamSubState(
8248 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008249 pSmeRsp->messageType = (pSmeRsp->messageType);
8250 pSmeRsp->length = (pSmeRsp->length);
8251 pSmeRsp->statusCode = (pSmeRsp->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008252 switch (pSmeRsp->messageType)
8253 {
8254
8255 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
8256 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
8257 {
8258 //We sent a JOIN_REQ
8259 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
8260 }
8261 break;
8262
8263 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
8264 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
8265 {
8266 //We sent a AUTH_REQ
8267 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
8268 }
8269 break;
8270
8271 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
8272 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
8273 {
8274 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
8275 }
8276 break;
8277
8278 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
8279 {
8280 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
8281 }
8282 break;
8283
8284 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
8285 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
8286 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
8287 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
8288 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
8289 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
8290//HO
8291 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
8292 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308293 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %s"),
8294 macTraceGetcsrRoamSubState(
8295 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008296 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
8297 }
8298 break;
8299
8300 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
8301 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
8302 {
8303 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
8304 }
8305 break;
8306
8307 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
8308 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
8309 {
8310 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
8311 }
8312 break;
8313
8314 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
8315 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
8316 {
8317 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
8318 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008319 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008320 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
8321 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
8322 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008323 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state");
Kiet Lam64c1b492013-07-12 13:56:44 +05308324 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
8325 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008326 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
8327 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05308328 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
8329 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008330 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
8331 eCSR_ROAM_CONNECT_STATUS_UPDATE,
8332 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
8333 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008334 default:
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308335 smsLog(pMac, LOG1,
8336 FL("Unexpected message type = %d[0x%X] received in substate %s"),
8337 pSmeRsp->messageType, pSmeRsp->messageType,
8338 macTraceGetcsrRoamSubState(
8339 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008340
8341 //If we are connected, check the link status change
8342 if(!csrIsConnStateDisconnected(pMac, sessionId))
8343 {
8344 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
8345 }
8346 break;
8347 }
8348}
8349
Jeff Johnson295189b2012-06-20 16:38:30 -07008350void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8351{
8352 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07008353 switch (pSirMsg->messageType)
8354 {
8355 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008356 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008357 csrRoamStatsRspProcessor( pMac, pSirMsg );
8358 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008359 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
8360 {
8361 tCsrRoamSession *pSession;
8362 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
8363 tCsrRoamInfo roamInfo;
8364 tCsrRoamInfo *pRoamInfo = NULL;
8365 tANI_U32 sessionId;
8366 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008367 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer "));
Kiet Lam64c1b492013-07-12 13:56:44 +05308368 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008369 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07008370 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
8371 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
8372 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008373
8374 if(!pSession)
8375 {
8376 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8377 return;
8378 }
8379
Jeff Johnson295189b2012-06-20 16:38:30 -07008380 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
8381 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07008382 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
8383 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
8384 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07008385 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
8386 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05308387 vos_mem_copy(pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr,
8388 sizeof(tSirMacAddr));
8389 vos_mem_copy(&pRoamInfo->bssid, pUpperLayerAssocCnf->bssId,
8390 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008391 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07008392 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
8393 {
8394 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
8395 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
8396 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
8397 }
8398 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8399 {
8400 vos_sleep( 100 );
8401 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
8402 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
8403 }
8404
Jeff Johnson295189b2012-06-20 16:38:30 -07008405 }
8406 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008407 default:
8408 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
8409 break;
8410 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008411}
8412
Jeff Johnson295189b2012-06-20 16:38:30 -07008413eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
8414 tSirBssDescription *pBssDescription,
8415 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
8416 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
8417 tANI_U8 keyId, tANI_U16 keyLength,
8418 tANI_U8 *pKey, tANI_U8 paeRole )
8419{
8420 eHalStatus status = eHAL_STATUS_SUCCESS;
8421 tAniEdType edType;
8422
8423 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
8424 {
8425 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
8426 }
8427
8428 edType = csrTranslateEncryptTypeToEdType( EncryptType );
8429
8430 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
8431 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
8432 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
8433 addKey )
8434 {
8435 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07008436 setKey.encType = EncryptType;
8437 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308438 vos_mem_copy(&setKey.peerMac, bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008439 setKey.paeRole = paeRole; //0 for supplicant
8440 setKey.keyId = keyId; // Kye index
8441 setKey.keyLength = keyLength;
8442 if( keyLength )
8443 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308444 vos_mem_copy(setKey.Key, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008445 }
8446 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
8447 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008448 return (status);
8449}
8450
Jeff Johnson295189b2012-06-20 16:38:30 -07008451static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8452 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8453{
8454 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8455 tSmeCmd *pCommand = NULL;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008456#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008457 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008458#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07008459
8460 do
8461 {
8462 pCommand = csrGetCommandBuffer(pMac);
8463 if(NULL == pCommand)
8464 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008465 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008466 status = eHAL_STATUS_RESOURCES;
8467 break;
8468 }
8469 pCommand->command = eSmeCommandSetKey;
8470 pCommand->sessionId = (tANI_U8)sessionId;
8471 // validate the key length, Adjust if too long...
8472 // for static WEP the keys are not set thru' SetContextReq
8473 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
8474 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
8475 {
8476 //KeyLength maybe 0 for static WEP
8477 if( pSetKey->keyLength )
8478 {
8479 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
8480 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008481 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008482 break;
8483 }
8484
8485 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308486 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8487 CSR_WEP40_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008488 }
8489 }
8490 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
8491 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
8492 {
8493 //KeyLength maybe 0 for static WEP
8494 if( pSetKey->keyLength )
8495 {
8496 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
8497 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008498 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008499 break;
8500 }
8501
8502 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308503 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8504 CSR_WEP104_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008505 }
8506 }
8507 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
8508 {
8509 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
8510 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008511 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008512 break;
8513 }
8514 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308515 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8516 CSR_TKIP_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008517 }
8518 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
8519 {
8520 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
8521 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008522 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008523 break;
8524 }
8525 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308526 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8527 CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008528 }
8529#ifdef FEATURE_WLAN_WAPI
8530 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
8531 {
8532 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
8533 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008534 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008535 break;
8536 }
8537 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308538 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8539 CSR_WAPI_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008540 }
8541#endif /* FEATURE_WLAN_WAPI */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008542#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008543 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8544 {
8545 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
8546 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008547 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008548 break;
8549 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008550 vos_mem_copy(pSession->eseCckmInfo.krk, pSetKey->Key,
Kiet Lam64c1b492013-07-12 13:56:44 +05308551 CSR_KRK_KEY_LEN);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008552 pSession->eseCckmInfo.reassoc_req_num=1;
8553 pSession->eseCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008554 status = eHAL_STATUS_SUCCESS;
8555 break;
8556 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008557#endif /* FEATURE_WLAN_ESE */
Jeff Johnsone7245742012-09-05 17:12:55 -07008558
Jeff Johnson295189b2012-06-20 16:38:30 -07008559#ifdef WLAN_FEATURE_11W
8560 //Check for 11w BIP
Chet Lanctot186b5732013-03-18 10:26:30 -07008561 else if (eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008562 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008563 if (pSetKey->keyLength < CSR_AES_KEY_LEN)
Jeff Johnson295189b2012-06-20 16:38:30 -07008564 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008565 smsLog(pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008566 break;
8567 }
8568 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308569 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008570 }
8571#endif
8572 status = eHAL_STATUS_SUCCESS;
8573 pCommand->u.setKeyCmd.roamId = roamId;
8574 pCommand->u.setKeyCmd.encType = pSetKey->encType;
8575 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308576 vos_mem_copy(&pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac,
8577 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008578 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
8579 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
Kiet Lam64c1b492013-07-12 13:56:44 +05308580 vos_mem_copy(pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008581 //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
8582
8583 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
8584 if( !HAL_STATUS_SUCCESS( status ) )
8585 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008586 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008587 }
8588 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008589 // Free the command if there has been a failure, or it is a
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008590 // "local" operation like the set ESE CCKM KRK key.
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008591 if ( ( NULL != pCommand ) &&
8592 ( (!HAL_STATUS_SUCCESS( status ) )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008593#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008594 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008595#endif /* FEATURE_WLAN_ESE */
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008596 ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008597 {
8598 csrReleaseCommandSetKey( pMac, pCommand );
8599 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008600 return( status );
8601}
8602
Jeff Johnson295189b2012-06-20 16:38:30 -07008603eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8604 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
8605{
8606 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8607 tSmeCmd *pCommand = NULL;
8608 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008609 do
8610 {
8611 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8612 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008613 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008614 status = eHAL_STATUS_CSR_WRONG_STATE;
8615 break;
8616 }
8617 pCommand = csrGetCommandBuffer(pMac);
8618 if(NULL == pCommand)
8619 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008620 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008621 status = eHAL_STATUS_RESOURCES;
8622 break;
8623 }
8624 pCommand->command = eSmeCommandRemoveKey;
8625 pCommand->sessionId = (tANI_U8)sessionId;
8626 pCommand->u.removeKeyCmd.roamId = roamId;
8627 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
Kiet Lam64c1b492013-07-12 13:56:44 +05308628 vos_mem_copy(&pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac,
8629 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008630 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
8631 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8632 {
8633 //in this case, put it to the end of the Q incase there is a set key pending.
8634 fImediate = eANI_BOOLEAN_FALSE;
8635 }
Arif Hussain24bafea2013-11-15 15:10:03 -08008636 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac="MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07008637 pRemoveKey->encType, pRemoveKey->keyId,
Arif Hussain24bafea2013-11-15 15:10:03 -08008638 MAC_ADDR_ARRAY(pCommand->u.removeKeyCmd.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07008639 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
8640 if( !HAL_STATUS_SUCCESS( status ) )
8641 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008642 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008643 break;
8644 }
8645 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008646 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
8647 {
8648 csrReleaseCommandRemoveKey( pMac, pCommand );
8649 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008650 return (status );
8651}
8652
Jeff Johnson295189b2012-06-20 16:38:30 -07008653eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8654{
8655 eHalStatus status;
8656 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
8657 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
8658 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
8659 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008660#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8661 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8662 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
lukez3c809222013-05-03 10:23:02 -07008663 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008664 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308665 vos_mem_set(&setKeyEvent,
8666 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008667 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8668 {
8669 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_REQ;
8670 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8671 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8672 }
8673 else
8674 {
8675 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_REQ;
8676 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8677 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8678 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308679 vos_mem_copy(setKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
lukez3c809222013-05-03 10:23:02 -07008680 if(CSR_IS_ENC_TYPE_STATIC(pCommand->u.setKeyCmd.encType))
Jeff Johnson295189b2012-06-20 16:38:30 -07008681 {
8682 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008683 //It has to be static WEP here
8684 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
8685 {
8686 setKeyEvent.keyId = (v_U8_t)defKeyId;
8687 }
8688 }
8689 else
8690 {
8691 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
8692 }
8693 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8694 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8695 }
8696#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008697 if( csrIsSetKeyAllowed(pMac, sessionId) )
8698 {
8699 status = csrSendMBSetContextReqMsg( pMac, sessionId,
8700 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
8701 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
8702 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
8703 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
8704 pCommand->u.setKeyCmd.keyRsc);
8705 }
8706 else
8707 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008708 smsLog( pMac, LOGW, FL(" cannot process not connected") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008709 //Set this status so the error handling take care of the case.
8710 status = eHAL_STATUS_CSR_WRONG_STATE;
8711 }
8712 if( !HAL_STATUS_SUCCESS(status) )
8713 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008714 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008715 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008716#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
lukez3c809222013-05-03 10:23:02 -07008717 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008718 {
8719 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8720 {
8721 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
8722 }
8723 else
8724 {
8725 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
8726 }
8727 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
8728 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8729 }
8730#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008731 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008732 return ( status );
8733}
8734
Jeff Johnson295189b2012-06-20 16:38:30 -07008735eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8736{
8737 eHalStatus status;
8738 tpSirSmeRemoveKeyReq pMsg = NULL;
8739 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
8740 tANI_U8 *p;
8741 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008742#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8743 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8744 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +05308745 vos_mem_set(&removeKeyEvent,
8746 sizeof(vos_event_wlan_security_payload_type),0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008747 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
8748 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8749 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05308750 vos_mem_copy(removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07008751 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
8752 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8753 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8754#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008755 if( csrIsSetKeyAllowed(pMac, sessionId) )
8756 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308757 pMsg = vos_mem_malloc(wMsgLen);
8758 if ( NULL == pMsg )
8759 status = eHAL_STATUS_FAILURE;
8760 else
8761 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008762 }
8763 else
8764 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008765 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008766 //Set the error status so error handling kicks in below
8767 status = eHAL_STATUS_CSR_WRONG_STATE;
8768 }
8769 if( HAL_STATUS_SUCCESS( status ) )
8770 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308771 vos_mem_set(pMsg, wMsgLen ,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008772 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
8773 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008774 pMsg->sessionId = (tANI_U8)sessionId;
8775 pMsg->transactionId = 0;
8776 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
8777 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
8778 // bssId - copy from session Info
Kiet Lam64c1b492013-07-12 13:56:44 +05308779 vos_mem_copy(p,
8780 &pMac->roam.roamSession[sessionId].connectedProfile.bssid,
8781 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008782 p += sizeof(tSirMacAddr);
8783 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +05308784 vos_mem_copy(p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008785 p += sizeof(tSirMacAddr);
8786 // edType
8787 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
8788 p++;
8789 // weptype
8790 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
8791 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
8792 {
8793 *p = (tANI_U8)eSIR_WEP_STATIC;
8794 }
8795 else
8796 {
8797 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
8798 }
8799 p++;
8800 //keyid
8801 *p = pCommand->u.removeKeyCmd.keyId;
8802 p++;
8803 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008804 status = palSendMBMessage(pMac->hHdd, pMsg);
8805 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008806 if( !HAL_STATUS_SUCCESS( status ) )
8807 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008808 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008809#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8810 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07008811 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008812 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8813#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008814 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
8815 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008816 return ( status );
8817}
8818
Jeff Johnson295189b2012-06-20 16:38:30 -07008819eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8820{
8821 eHalStatus status;
8822
8823 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8824 {
8825 status = eHAL_STATUS_CSR_WRONG_STATE;
8826 }
8827 else
8828 {
8829 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
8830 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008831 return ( status );
8832}
8833
Jeff Johnson295189b2012-06-20 16:38:30 -07008834/*
8835 Prepare a filter base on a profile for parsing the scan results.
8836 Upon successful return, caller MUST call csrFreeScanFilter on
8837 pScanFilter when it is done with the filter.
8838*/
8839eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
8840 tCsrScanResultFilter *pScanFilter)
8841{
8842 eHalStatus status = eHAL_STATUS_SUCCESS;
8843 tANI_U32 size = 0;
8844 tANI_U8 index = 0;
8845
8846 do
8847 {
8848 if(pProfile->BSSIDs.numOfBSSIDs)
8849 {
8850 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308851 pScanFilter->BSSIDs.bssid = vos_mem_malloc(size);
8852 if ( NULL == pScanFilter->BSSIDs.bssid )
8853 status = eHAL_STATUS_FAILURE;
8854 else
8855 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008856 if(!HAL_STATUS_SUCCESS(status))
8857 {
8858 break;
8859 }
8860 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308861 vos_mem_copy(pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07008862 }
8863 if(pProfile->SSIDs.numOfSSIDs)
8864 {
8865 if( !CSR_IS_WDS_STA( pProfile ) )
8866 {
8867 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
8868 }
8869 else
8870 {
8871 //For WDS station
8872 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
8873 pScanFilter->SSIDs.numOfSSIDs = 1;
8874 }
8875 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308876 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(size);
8877 if ( NULL == pScanFilter->SSIDs.SSIDList )
8878 status = eHAL_STATUS_FAILURE;
8879 else
8880 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008881 if(!HAL_STATUS_SUCCESS(status))
8882 {
8883 break;
8884 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308885 vos_mem_copy(pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList,
8886 size);
Jeff Johnson295189b2012-06-20 16:38:30 -07008887 }
8888 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
8889 {
8890 pScanFilter->ChannelInfo.numOfChannels = 0;
8891 pScanFilter->ChannelInfo.ChannelList = NULL;
8892 }
8893 else if(pProfile->ChannelInfo.numOfChannels)
8894 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308895 pScanFilter->ChannelInfo.ChannelList = vos_mem_malloc(
8896 sizeof(*pScanFilter->ChannelInfo.ChannelList) *
8897 pProfile->ChannelInfo.numOfChannels);
8898 if ( NULL == pScanFilter->ChannelInfo.ChannelList )
8899 status = eHAL_STATUS_FAILURE;
8900 else
8901 status = eHAL_STATUS_SUCCESS;
8902
Jeff Johnson295189b2012-06-20 16:38:30 -07008903 pScanFilter->ChannelInfo.numOfChannels = 0;
8904 if(HAL_STATUS_SUCCESS(status))
8905 {
8906 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
8907 {
8908 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
8909 {
8910 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
8911 = pProfile->ChannelInfo.ChannelList[index];
8912 pScanFilter->ChannelInfo.numOfChannels++;
8913 }
8914 else
8915 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008916 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid"), pProfile->ChannelInfo.ChannelList[index]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008917 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008918 }
8919 }
8920 else
8921 {
8922 break;
8923 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008924 }
8925 else
8926 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05308927 smsLog(pMac, LOGE, FL("Channel list empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008928 status = eHAL_STATUS_FAILURE;
8929 break;
8930 }
8931 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
8932 pScanFilter->authType = pProfile->AuthType;
8933 pScanFilter->EncryptionType = pProfile->EncryptionType;
8934 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
8935 pScanFilter->BSSType = pProfile->BSSType;
8936 pScanFilter->phyMode = pProfile->phyMode;
8937#ifdef FEATURE_WLAN_WAPI
8938 //check if user asked for WAPI with 11n or auto mode, in that case modify
8939 //the phymode to 11g
8940 if(csrIsProfileWapi(pProfile))
8941 {
8942 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
8943 {
8944 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
8945 }
8946 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
8947 {
8948 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
8949 }
8950 if(!pScanFilter->phyMode)
8951 {
8952 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
8953 }
8954 }
8955#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07008956 /*Save the WPS info*/
8957 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -07008958 pScanFilter->bOSENAssociation = pProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07008959 if( pProfile->countryCode[0] )
8960 {
8961 //This causes the matching function to use countryCode as one of the criteria.
Kiet Lam64c1b492013-07-12 13:56:44 +05308962 vos_mem_copy(pScanFilter->countryCode, pProfile->countryCode,
8963 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008964 }
8965#ifdef WLAN_FEATURE_VOWIFI_11R
8966 if (pProfile->MDID.mdiePresent)
8967 {
8968 pScanFilter->MDID.mdiePresent = 1;
8969 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
8970 }
8971#endif
8972
8973 }while(0);
8974
8975 if(!HAL_STATUS_SUCCESS(status))
8976 {
8977 csrFreeScanFilter(pMac, pScanFilter);
8978 }
8979
8980 return(status);
8981}
8982
Jeff Johnson295189b2012-06-20 16:38:30 -07008983tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
8984 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
8985{
8986 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
8987 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008988 do
8989 {
8990 // Validate the type is ok...
8991 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
8992 pCommand = csrGetCommandBuffer( pMac );
8993 if ( !pCommand )
8994 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008995 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008996 break;
8997 }
8998 //Change the substate in case it is waiting for key
8999 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
9000 {
9001 csrRoamStopWaitForKeyTimer( pMac );
9002 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
9003 }
9004 pCommand->command = eSmeCommandWmStatusChange;
9005 pCommand->sessionId = (tANI_U8)sessionId;
9006 pCommand->u.wmStatusChangeCmd.Type = Type;
9007 if ( eCsrDisassociated == Type )
9008 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309009 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg,
9010 pSmeRsp,
9011 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07009012 }
9013 else
9014 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309015 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg,
9016 pSmeRsp,
9017 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07009018 }
9019 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
9020 {
9021 fCommandQueued = eANI_BOOLEAN_TRUE;
9022 }
9023 else
9024 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009025 smsLog( pMac, LOGE, FL(" fail to send message ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009026 csrReleaseCommandWmStatusChange( pMac, pCommand );
9027 }
9028
Jeff Johnson295189b2012-06-20 16:38:30 -07009029 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
9030 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07009031 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07009032 return( fCommandQueued );
9033}
9034
Jeff Johnson295189b2012-06-20 16:38:30 -07009035static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
9036{
9037 v_S7_t rssi = 0;
9038 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
9039 if(pGetRssiReq)
9040 {
9041 if(NULL != pGetRssiReq->pVosContext)
9042 {
9043 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
9044 }
9045 else
9046 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009047 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009048 return;
9049 }
9050
9051 if(NULL != pGetRssiReq->rssiCallback)
9052 {
9053 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
9054 }
9055 else
9056 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009057 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009058 return;
9059 }
9060 }
9061 else
9062 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009063 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009064 }
9065 return;
9066}
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309067
9068static void csrUpdateSnr(tpAniSirGlobal pMac, void* pMsg)
9069{
9070 tANI_S8 snr = 0;
9071 tAniGetSnrReq *pGetSnrReq = (tAniGetSnrReq*)pMsg;
9072
9073 if (pGetSnrReq)
9074 {
9075 if (VOS_STATUS_SUCCESS !=
9076 WDA_GetSnr(pGetSnrReq->staId, &snr))
9077 {
9078 smsLog(pMac, LOGE, FL("Error in WLANTL_GetSnr"));
9079 return;
9080 }
9081
9082 if (pGetSnrReq->snrCallback)
9083 {
9084 ((tCsrSnrCallback)(pGetSnrReq->snrCallback))(snr, pGetSnrReq->staId,
9085 pGetSnrReq->pDevContext);
9086 }
9087 else
9088 {
9089 smsLog(pMac, LOGE, FL("pGetSnrReq->snrCallback is NULL"));
9090 return;
9091 }
9092 }
9093 else
9094 {
9095 smsLog(pMac, LOGE, FL("pGetSnrReq is NULL"));
9096 }
9097 return;
9098}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009099#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009100void csrRoamRssiRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9101{
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009102 tAniGetRoamRssiRsp* pRoamRssiRsp = (tAniGetRoamRssiRsp*)pMsg;
9103
Jeff Johnson36d483b2013-04-08 11:08:53 -07009104 if (NULL != pRoamRssiRsp)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009105 {
Jeff Johnson36d483b2013-04-08 11:08:53 -07009106 /* Get roam Rssi request is backed up and passed back to the response,
9107 Extract the request message to fetch callback */
9108 tpAniGetRssiReq reqBkp = (tAniGetRssiReq*)pRoamRssiRsp->rssiReq;
9109 v_S7_t rssi = pRoamRssiRsp->rssi;
9110
9111 if ((NULL != reqBkp) && (NULL != reqBkp->rssiCallback))
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009112 {
9113 ((tCsrRssiCallback)(reqBkp->rssiCallback))(rssi, pRoamRssiRsp->staId, reqBkp->pDevContext);
9114 reqBkp->rssiCallback = NULL;
9115 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009116 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009117 }
9118 else
9119 {
9120 smsLog( pMac, LOGE, FL("reqBkp->rssiCallback is NULL"));
9121 if (NULL != reqBkp)
9122 {
9123 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009124 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009125 }
9126 }
9127 }
9128 else
9129 {
9130 smsLog( pMac, LOGE, FL("pRoamRssiRsp is NULL"));
9131 }
9132 return;
9133}
9134#endif
9135
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009136
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009137#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009138void csrTsmStatsRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9139{
9140 tAniGetTsmStatsRsp* pTsmStatsRsp = (tAniGetTsmStatsRsp*)pMsg;
9141
9142 if (NULL != pTsmStatsRsp)
9143 {
9144 /* Get roam Rssi request is backed up and passed back to the response,
9145 Extract the request message to fetch callback */
9146 tpAniGetTsmStatsReq reqBkp = (tAniGetTsmStatsReq*)pTsmStatsRsp->tsmStatsReq;
9147
9148 if (NULL != reqBkp)
9149 {
9150 if (NULL != reqBkp->tsmStatsCallback)
9151 {
9152 ((tCsrTsmStatsCallback)(reqBkp->tsmStatsCallback))(pTsmStatsRsp->tsmMetrics,
9153 pTsmStatsRsp->staId, reqBkp->pDevContext);
9154 reqBkp->tsmStatsCallback = NULL;
9155 }
9156 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009157 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009158 }
9159 else
9160 {
9161 smsLog( pMac, LOGE, FL("reqBkp is NULL"));
9162 if (NULL != reqBkp)
9163 {
9164 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009165 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009166 }
9167 }
9168 }
9169 else
9170 {
9171 smsLog( pMac, LOGE, FL("pTsmStatsRsp is NULL"));
9172 }
9173 return;
9174}
9175
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009176void csrSendEseAdjacentApRepInd(tpAniSirGlobal pMac, tCsrRoamSession *pSession)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009177{
9178 tANI_U32 roamTS2 = 0;
9179 tCsrRoamInfo roamInfo;
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009180 tpPESession pSessionEntry = NULL;
9181 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009182
9183 if (NULL == pSession)
9184 {
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009185 smsLog(pMac, LOGE, FL("pSession is NULL"));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009186 return;
9187 }
9188
9189 roamTS2 = vos_timer_get_system_time();
9190 roamInfo.tsmRoamDelay = roamTS2 - pSession->roamTS1;
Arif Hussaina7c8e412013-11-20 11:06:42 -08009191 smsLog(pMac, LOG1, "Bssid("MAC_ADDRESS_STR") Roaming Delay(%u ms)",
9192 MAC_ADDR_ARRAY(pSession->connectedProfile.bssid),
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009193 roamInfo.tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009194
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009195 pSessionEntry = peFindSessionByBssid(pMac, pSession->connectedProfile.bssid, &sessionId);
9196 if (NULL == pSessionEntry)
9197 {
9198 smsLog(pMac, LOGE, FL("session %d not found"), sessionId);
9199 return;
9200 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009201 pSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly = roamInfo.tsmRoamDelay;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009202 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009203 0, eCSR_ROAM_ESE_ADJ_AP_REPORT_IND, 0);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009204}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009205#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009206
Jeff Johnsone7245742012-09-05 17:12:55 -07009207static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
9208{
9209 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
9210 if(pTlRssiInd)
9211 {
9212 if(NULL != pTlRssiInd->tlCallback)
9213 {
9214 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -08009215 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07009216 }
9217 else
9218 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009219 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009220 }
9221 }
9222 else
9223 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009224 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009225 }
9226 return;
9227}
Jeff Johnson295189b2012-06-20 16:38:30 -07009228
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309229eHalStatus csrSendResetApCapsChanged(tpAniSirGlobal pMac, tSirMacAddr *bssId)
9230{
9231 tpSirResetAPCapsChange pMsg;
9232 tANI_U16 len;
9233 eHalStatus status = eHAL_STATUS_SUCCESS;
9234
9235 /* Create the message and send to lim */
9236 len = sizeof(tSirResetAPCapsChange);
Kiet Lam64c1b492013-07-12 13:56:44 +05309237 pMsg = vos_mem_malloc(len);
9238 if ( NULL == pMsg )
9239 status = eHAL_STATUS_FAILURE;
9240 else
9241 status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309242 if (HAL_STATUS_SUCCESS(status))
9243 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309244 vos_mem_set(pMsg, sizeof(tSirResetAPCapsChange), 0);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309245 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
9246 pMsg->length = len;
Kiet Lam64c1b492013-07-12 13:56:44 +05309247 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08009248 smsLog( pMac, LOG1, FL("CSR reset caps change for Bssid= "MAC_ADDRESS_STR),
9249 MAC_ADDR_ARRAY(pMsg->bssId));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309250 status = palSendMBMessage(pMac->hHdd, pMsg);
9251 }
9252 else
9253 {
9254 smsLog( pMac, LOGE, FL("Memory allocation failed\n"));
9255 }
9256 return status;
9257}
9258
Jeff Johnson295189b2012-06-20 16:38:30 -07009259void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
9260{
9261 tSirSmeAssocInd *pAssocInd;
9262 tSirSmeDisassocInd *pDisassocInd;
9263 tSirSmeDeauthInd *pDeauthInd;
9264 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
9265 tSirSmeNewBssInfo *pNewBss;
9266 tSmeIbssPeerInd *pIbssPeerInd;
9267 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
9268 tSirSmeApNewCaps *pApNewCaps;
9269 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
9270 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
9271 tCsrRoamInfo *pRoamInfo = NULL;
9272 tCsrRoamInfo roamInfo;
9273 eHalStatus status;
9274 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
9275 tCsrRoamSession *pSession = NULL;
9276 tpSirSmeSwitchChannelInd pSwitchChnInd;
9277 tSmeMaxAssocInd *pSmeMaxAssocInd;
Kiet Lam64c1b492013-07-12 13:56:44 +05309278 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
krunal soni587bf012014-02-04 12:35:11 -08009279
9280
9281 if (NULL == pSirMsg)
9282 { smsLog(pMac, LOGE, FL("pSirMsg is NULL"));
9283 return;
9284 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009285 switch( pSirMsg->messageType )
9286 {
9287 case eWNI_SME_ASSOC_IND:
9288 {
9289 tCsrRoamSession *pSession;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009290 smsLog( pMac, LOG1, FL("ASSOCIATION Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009291 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
9292 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
9293 if( HAL_STATUS_SUCCESS( status ) )
9294 {
9295 pSession = CSR_GET_SESSION(pMac, sessionId);
9296
Jeff Johnson32d95a32012-09-10 13:15:23 -07009297 if(!pSession)
9298 {
9299 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9300 return;
9301 }
9302
Jeff Johnson295189b2012-06-20 16:38:30 -07009303 pRoamInfo = &roamInfo;
9304
9305 // Required for indicating the frames to upper layer
9306 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
9307 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
9308
9309 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
9310 pRoamInfo->beaconLength = pAssocInd->beaconLength;
9311 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
9312 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9313
9314 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
9315 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
9316 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
9317
9318 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
9319 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05309320 vos_mem_copy(pRoamInfo->peerMac, pAssocInd->peerMacAddr,
9321 sizeof(tSirMacAddr));
9322 vos_mem_copy(&pRoamInfo->bssid, pAssocInd->bssId,
9323 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009324 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
9325 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07009326 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -07009327 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
9328 {
9329 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
9330 {
9331 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
9332 pSession->pConnectBssDesc,
9333 &(pRoamInfo->peerMac),
9334 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9335 pRoamInfo->fAuthRequired = FALSE;
9336 }
9337 else
9338 {
9339 pRoamInfo->fAuthRequired = TRUE;
9340 }
9341 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
9342 if (!HAL_STATUS_SUCCESS(status))
9343 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
9344 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009345 /* Send Association completion message to PE */
9346 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
9347
9348 /* send a message to CSR itself just to avoid the EAPOL frames going
9349 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -07009350 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
9351 {
9352 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9353 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009354 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
9355 {
9356 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
9357 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
9358 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9359 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009360 }
9361 }
9362 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009363 case eWNI_SME_DISASSOC_IND:
Jeff Johnson295189b2012-06-20 16:38:30 -07009364 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309365 // Check if AP dis-associated us because of MIC failure. If so,
9366 // then we need to take action immediately and not wait till the
9367 // the WmStatusChange requests is pushed and processed
9368 tSmeCmd *pCommand;
9369
9370 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
9371 status = csrRoamGetSessionIdFromBSSID( pMac,
9372 (tCsrBssid *)pDisassocInd->bssId, &sessionId );
9373 if( HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009374 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309375 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC"
9376 " for session %d "), sessionId);
9377 smsLog( pMac, LOGE, FL("DISASSOCIATION from peer ="
9378 MAC_ADDRESS_STR " "
9379 " reason = %d status = %d "),
9380 MAC_ADDR_ARRAY(pDisassocInd->peerMacAddr),
9381 pDisassocInd->reasonCode,
9382 pDisassocInd->statusCode);
9383 // If we are in neighbor preauth done state then on receiving
9384 // disassoc or deauth we dont roam instead we just disassoc
9385 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009386 // This happens for ESE and 11r FT connections ONLY.
Agarwal Ashish4f616132013-12-30 23:32:50 +05309387#ifdef WLAN_FEATURE_VOWIFI_11R
9388 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9389 {
9390 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9391 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009392#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009393#ifdef FEATURE_WLAN_ESE
9394 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Agarwal Ashish4f616132013-12-30 23:32:50 +05309395 {
9396 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9397 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009398#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009399#ifdef FEATURE_WLAN_LFR
Agarwal Ashish4f616132013-12-30 23:32:50 +05309400 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
9401 {
9402 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9403 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009404#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +05309405 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009406
Agarwal Ashish4f616132013-12-30 23:32:50 +05309407 if (!pSession)
9408 {
9409 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9410 return;
9411 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07009412
Agarwal Ashish4f616132013-12-30 23:32:50 +05309413 if ( csrIsConnStateInfra( pMac, sessionId ) )
9414 {
9415 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9416 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009417#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Agarwal Ashish4f616132013-12-30 23:32:50 +05309418 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009419#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +05309420 csrRoamLinkDown(pMac, sessionId);
9421 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
9422 if (CSR_IS_INFRA_AP(&pSession->connectedProfile))
9423 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309424 pRoamInfo = &roamInfo;
9425 pRoamInfo->statusCode = pDisassocInd->statusCode;
9426 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9427 pRoamInfo->staId = (tANI_U8)pDisassocInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009428
Agarwal Ashish4f616132013-12-30 23:32:50 +05309429 vos_mem_copy(pRoamInfo->peerMac, pDisassocInd->peerMacAddr,
9430 sizeof(tSirMacAddr));
9431 vos_mem_copy(&pRoamInfo->bssid, pDisassocInd->bssId,
9432 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009433
Agarwal Ashish4f616132013-12-30 23:32:50 +05309434 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9435 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DISASSOC_IND);
Jeff Johnson295189b2012-06-20 16:38:30 -07009436
Agarwal Ashish4f616132013-12-30 23:32:50 +05309437 /*
9438 * STA/P2P client got disassociated so remove any pending deauth
9439 * commands in sme pending list
9440 */
Kaushik, Sushant488df382014-03-05 11:43:47 +05309441 pCommand = csrGetCommandBuffer(pMac);
9442 if (NULL == pCommand)
9443 {
9444 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
9445 status = eHAL_STATUS_RESOURCES;
9446 return;
9447 }
Agarwal Ashish4f616132013-12-30 23:32:50 +05309448 pCommand->command = eSmeCommandRoam;
9449 pCommand->sessionId = (tANI_U8)sessionId;
9450 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
9451 vos_mem_copy(pCommand->u.roamCmd.peerMac,
9452 pDisassocInd->peerMacAddr,
9453 sizeof(tSirMacAddr));
9454 csrRoamRemoveDuplicateCommand(pMac, sessionId, pCommand, eCsrForcedDeauthSta);
9455 csrReleaseCommand( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07009456
Agarwal Ashish4f616132013-12-30 23:32:50 +05309457 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009458 }
Agarwal Ashish4f616132013-12-30 23:32:50 +05309459 else
9460 {
9461 smsLog(pMac, LOGE, FL(" Session Id not found for BSSID " MAC_ADDRESS_STR),
9462 MAC_ADDR_ARRAY(pDisassocInd->bssId));
9463 }
Kiet Lam82004c62013-11-11 13:24:28 +05309464 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009465 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009466 case eWNI_SME_DEAUTH_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009467 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009468 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
9469 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
9470 if( HAL_STATUS_SUCCESS( status ) )
9471 {
9472 // If we are in neighbor preauth done state then on receiving
9473 // disassoc or deauth we dont roam instead we just disassoc
9474 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009475 // This happens for ESE and 11r FT connections ONLY.
Jeff Johnson295189b2012-06-20 16:38:30 -07009476#ifdef WLAN_FEATURE_VOWIFI_11R
9477 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9478 {
9479 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9480 }
9481#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009482#ifdef FEATURE_WLAN_ESE
9483 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson295189b2012-06-20 16:38:30 -07009484 {
9485 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9486 }
9487#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009488#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05309489 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009490 {
9491 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9492 }
9493#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009494 pSession = CSR_GET_SESSION( pMac, sessionId );
9495
Jeff Johnson32d95a32012-09-10 13:15:23 -07009496 if(!pSession)
9497 {
9498 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9499 return;
9500 }
9501
Jeff Johnson295189b2012-06-20 16:38:30 -07009502 if ( csrIsConnStateInfra( pMac, sessionId ) )
9503 {
9504 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9505 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009506#ifndef WLAN_MDM_CODE_REDUCTION_OPT
9507 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
9508#endif
9509 csrRoamLinkDown(pMac, sessionId);
9510 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07009511 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
9512 {
9513
9514 pRoamInfo = &roamInfo;
9515
9516 pRoamInfo->statusCode = pDeauthInd->statusCode;
9517 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9518
9519 pRoamInfo->staId = (tANI_U8)pDeauthInd->staId;
9520
Kiet Lam64c1b492013-07-12 13:56:44 +05309521 vos_mem_copy(pRoamInfo->peerMac, pDeauthInd->peerMacAddr,
9522 sizeof(tSirMacAddr));
9523 vos_mem_copy(&pRoamInfo->bssid, pDeauthInd->bssId,
9524 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009525
9526 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DEAUTH_IND);
9527 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009528 }
9529 break;
9530
9531 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 -08009532 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009533 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
9534 //Update with the new channel id.
9535 //The channel id is hidden in the statusCode.
9536 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
9537 if( HAL_STATUS_SUCCESS( status ) )
9538 {
9539 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009540 if(!pSession)
9541 {
9542 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9543 return;
9544 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009545 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
9546 if(pSession->pConnectBssDesc)
9547 {
9548 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
9549 }
9550 }
9551 break;
9552
9553 case eWNI_SME_DEAUTH_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009554 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009555 {
9556 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
9557 sessionId = pDeauthRsp->sessionId;
9558 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9559 {
9560 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009561 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9562 {
9563 pRoamInfo = &roamInfo;
9564 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309565 vos_mem_copy(pRoamInfo->peerMac, pDeauthRsp->peerMacAddr,
9566 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009567 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9568 pRoamInfo->statusCode = pDeauthRsp->statusCode;
9569 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9570 }
9571 }
9572 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009573 break;
9574
9575 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009576 /* session id is invalid here so cant use it to access the array curSubstate as index */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009577 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -07009578 {
9579 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
9580 sessionId = pDisassocRsp->sessionId;
9581 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9582 {
9583 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009584 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9585 {
9586 pRoamInfo = &roamInfo;
9587 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309588 vos_mem_copy(pRoamInfo->peerMac, pDisassocRsp->peerMacAddr,
9589 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009590 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9591 pRoamInfo->statusCode = pDisassocRsp->statusCode;
9592 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9593 }
9594 }
9595 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009596 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009597 case eWNI_SME_MIC_FAILURE_IND:
9598 {
9599 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
9600 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
9601 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Leo Chang9b01ad92013-09-12 17:26:56 -07009602
9603 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
9604 if( HAL_STATUS_SUCCESS( status ) )
9605 {
Kiet Lamf2f201e2013-11-16 21:24:16 +05309606 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Leo Chang9b01ad92013-09-12 17:26:56 -07009607 roamInfo.u.pMICFailureInfo = &pMicInd->info;
9608 pRoamInfo = &roamInfo;
9609 if(pMicInd->info.multicast)
9610 {
9611 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
9612 }
9613 else
9614 {
9615 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
9616 }
9617 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
9618 }
9619
Jeff Johnson295189b2012-06-20 16:38:30 -07009620#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9621 {
lukez3c809222013-05-03 10:23:02 -07009622 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07009623 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009624 if(!pSession)
9625 {
9626 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9627 return;
9628 }
lukez3c809222013-05-03 10:23:02 -07009629
Kiet Lam64c1b492013-07-12 13:56:44 +05309630 vos_mem_set(&secEvent, sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009631 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
9632 secEvent.encryptionModeMulticast =
9633 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9634 secEvent.encryptionModeUnicast =
9635 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9636 secEvent.authMode =
9637 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309638 vos_mem_copy(secEvent.bssid,
9639 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009640 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
9641 }
9642#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009643 }
9644 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009645 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
9646 {
9647 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
9648 tCsrRoamInfo roamInfo;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009649 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009650
9651 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
9652 if( HAL_STATUS_SUCCESS( status ) )
9653 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309654 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009655 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
9656 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
9657 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
9658 }
9659 }
9660 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009661
Jeff Johnson295189b2012-06-20 16:38:30 -07009662 case eWNI_SME_WM_STATUS_CHANGE_NTF:
9663 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
9664 switch( pStatusChangeMsg->statusChangeCode )
9665 {
9666 case eSIR_SME_IBSS_ACTIVE:
9667 sessionId = csrFindIbssSession( pMac );
9668 if( CSR_SESSION_ID_INVALID != sessionId )
9669 {
9670 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009671 if(!pSession)
9672 {
9673 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9674 return;
9675 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009676 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
9677 if(pSession->pConnectBssDesc)
9678 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309679 vos_mem_copy(&roamInfo.bssid,
9680 pSession->pConnectBssDesc->bssId,
9681 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009682 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
9683 pRoamInfo = &roamInfo;
9684 }
9685 else
9686 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009687 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009688 }
9689 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
9690 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9691 }
9692 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009693 case eSIR_SME_IBSS_INACTIVE:
9694 sessionId = csrFindIbssSession( pMac );
9695 if( CSR_SESSION_ID_INVALID != sessionId )
9696 {
9697 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009698 if(!pSession)
9699 {
9700 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9701 return;
9702 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009703 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
9704 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
9705 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9706 }
9707 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009708 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
9709 sessionId = csrFindIbssSession( pMac );
9710 if( CSR_SESSION_ID_INVALID != sessionId )
9711 {
9712 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009713 if(!pSession)
9714 {
9715 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9716 return;
9717 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009718 // update the connection state information
9719 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009720#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9721 {
9722 vos_log_ibss_pkt_type *pIbssLog;
9723 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -07009724 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9725 if(pIbssLog)
9726 {
9727 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
9728 if(pNewBss)
9729 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309730 vos_mem_copy(pIbssLog->bssid, pNewBss->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009731 if(pNewBss->ssId.length)
9732 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309733 vos_mem_copy(pIbssLog->ssid, pNewBss->ssId.ssId,
9734 pNewBss->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07009735 }
9736 pIbssLog->operatingChannel = pNewBss->channelNumber;
9737 }
9738 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
9739 {
9740 //***U8 is not enough for beacon interval
9741 pIbssLog->beaconInterval = (v_U8_t)bi;
9742 }
9743 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9744 }
9745 }
9746#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009747 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009748
9749 if ((eCSR_ENCRYPT_TYPE_NONE ==
9750 pSession->connectedProfile.EncryptionType ))
9751 {
9752 csrRoamIssueSetContextReq( pMac, sessionId,
9753 pSession->connectedProfile.EncryptionType,
9754 pSession->pConnectBssDesc,
9755 &Broadcastaddr,
9756 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
9757 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009758 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
9759 roamStatus = eCSR_ROAM_IBSS_IND;
Kiet Lam64c1b492013-07-12 13:56:44 +05309760 vos_mem_copy(&roamInfo.bssid, &pNewBss->bssId,
9761 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009762 pRoamInfo = &roamInfo;
9763 //This BSSID is th ereal BSSID, let's save it
9764 if(pSession->pConnectBssDesc)
9765 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309766 vos_mem_copy(pSession->pConnectBssDesc->bssId,
9767 &pNewBss->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009768 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009769 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009770 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Jeff Johnson295189b2012-06-20 16:38:30 -07009771 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009772 // detection by LIM that the capabilities of the associated AP have changed.
9773 case eSIR_SME_AP_CAPS_CHANGED:
9774 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009775 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED");
Jeff Johnson295189b2012-06-20 16:38:30 -07009776 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
9777 if( HAL_STATUS_SUCCESS( status ) )
9778 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009779 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
9780 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309781 (eCSR_ROAM_SUBSTATE_NONE == pMac->roam.curSubState[sessionId]) ||
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009782 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
9783 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
9784 )
9785 {
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309786 smsLog(pMac, LOGW, "Calling csrRoamDisconnectInternal");
9787 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009788 }
9789 else
9790 {
9791 smsLog(pMac, LOGW,
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05309792 FL("Skipping csrScanForCapabilityChange as "
9793 "CSR is in state %s and sub-state %s"),
9794 macTraceGetcsrRoamState(
9795 pMac->roam.curState[sessionId]),
9796 macTraceGetcsrRoamSubState(
9797 pMac->roam.curSubState[sessionId]));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309798 /* We ignore the caps change event if CSR is not in full connected state.
9799 * Send one event to PE to reset limSentCapsChangeNtf
9800 * Once limSentCapsChangeNtf set 0, lim can send sub sequent CAPS change event
9801 * otherwise lim cannot send any CAPS change events to SME */
9802 csrSendResetApCapsChanged(pMac, &pApNewCaps->bssId);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009803 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009804 }
9805 break;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309806
Jeff Johnson295189b2012-06-20 16:38:30 -07009807 default:
9808 roamStatus = eCSR_ROAM_FAILED;
9809 result = eCSR_ROAM_RESULT_NONE;
9810 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009811 } // end switch on statusChangeCode
9812 if(eCSR_ROAM_RESULT_NONE != result)
9813 {
9814 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
9815 }
9816 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009817 case eWNI_SME_IBSS_NEW_PEER_IND:
9818 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07009819#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9820 {
9821 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07009822 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9823 if(pIbssLog)
9824 {
9825 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309826 vos_mem_copy(pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009827 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9828 }
9829 }
9830#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009831 sessionId = csrFindIbssSession( pMac );
9832 if( CSR_SESSION_ID_INVALID != sessionId )
9833 {
9834 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009835
9836 if(!pSession)
9837 {
9838 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9839 return;
9840 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009841 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
9842 if(pSession->pConnectBssDesc)
9843 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309844 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
9845 sizeof(tCsrBssid));
9846 vos_mem_copy(&roamInfo.bssid, pSession->pConnectBssDesc->bssId,
9847 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009848 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
9849 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309850 roamInfo.pbFrames = vos_mem_malloc((pIbssPeerInd->mesgLen
9851 - sizeof(tSmeIbssPeerInd)));
9852 if ( NULL == roamInfo.pbFrames )
9853 status = eHAL_STATUS_FAILURE;
9854 else
9855 status = eHAL_STATUS_SUCCESS;
9856 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07009857 {
9858 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
Kiet Lam64c1b492013-07-12 13:56:44 +05309859 vos_mem_copy(roamInfo.pbFrames,
9860 ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
9861 roamInfo.nBeaconLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07009862 }
9863 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9864 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9865 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05309866 roamInfo.pBssDesc = vos_mem_malloc(pSession->pConnectBssDesc->length);
9867 if ( NULL == roamInfo.pBssDesc )
9868 status = eHAL_STATUS_FAILURE;
9869 else
9870 status = eHAL_STATUS_SUCCESS;
9871 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07009872 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309873 vos_mem_copy(roamInfo.pBssDesc,
9874 pSession->pConnectBssDesc,
9875 pSession->pConnectBssDesc->length);
Jeff Johnson295189b2012-06-20 16:38:30 -07009876 }
9877 if(HAL_STATUS_SUCCESS(status))
9878 {
9879 pRoamInfo = &roamInfo;
9880 }
9881 else
9882 {
9883 if(roamInfo.pbFrames)
9884 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309885 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -07009886 }
9887 if(roamInfo.pBssDesc)
9888 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309889 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07009890 }
9891 }
9892 }
9893 else
9894 {
9895 pRoamInfo = &roamInfo;
9896 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009897 if ((eCSR_ENCRYPT_TYPE_NONE ==
9898 pSession->connectedProfile.EncryptionType ))
9899 {
9900 csrRoamIssueSetContextReq( pMac, sessionId,
9901 pSession->connectedProfile.EncryptionType,
9902 pSession->pConnectBssDesc,
9903 &(pIbssPeerInd->peerAddr),
9904 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9905 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009906 }
9907 else
9908 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009909 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009910 }
9911 //send up the sec type for the new peer
9912 if (pRoamInfo)
9913 {
9914 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9915 }
9916 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9917 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
9918 if(pRoamInfo)
9919 {
9920 if(roamInfo.pbFrames)
9921 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309922 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -07009923 }
9924 if(roamInfo.pBssDesc)
9925 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309926 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07009927 }
9928 }
9929 }
9930 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009931 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
9932 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
9933 sessionId = csrFindIbssSession( pMac );
9934 if( CSR_SESSION_ID_INVALID != sessionId )
9935 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009936#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9937 {
9938 vos_log_ibss_pkt_type *pIbssLog;
9939
9940 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9941 if(pIbssLog)
9942 {
9943 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
9944 if(pIbssPeerInd)
9945 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309946 vos_mem_copy(pIbssLog->peerMacAddr,
9947 &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009948 }
9949 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9950 }
9951 }
9952#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009953 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM");
Jeff Johnson295189b2012-06-20 16:38:30 -07009954 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9955 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9956 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05309957 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
9958 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009959 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9960 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
9961 }
9962 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009963 case eWNI_SME_SETCONTEXT_RSP:
9964 {
9965 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
9966 tListElem *pEntry;
9967 tSmeCmd *pCommand;
9968
9969 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9970 if ( pEntry )
9971 {
9972 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9973 if ( eSmeCommandSetKey == pCommand->command )
9974 {
Sandeep Puligilla9f384742014-04-11 02:27:04 +05309975 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009976 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009977
9978 if(!pSession)
9979 {
9980 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9981 return;
9982 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009983
9984#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9985 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
9986 {
9987 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +05309988 vos_mem_set(&setKeyEvent,
9989 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009990 if( pRsp->peerMacAddr[0] & 0x01 )
9991 {
9992 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
9993 }
9994 else
9995 {
9996 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
9997 }
9998 setKeyEvent.encryptionModeMulticast =
9999 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10000 setKeyEvent.encryptionModeUnicast =
10001 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010002 vos_mem_copy(setKeyEvent.bssid,
10003 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010004 setKeyEvent.authMode =
10005 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -070010006 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010007 {
10008 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10009 }
10010 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
10011 }
10012#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
10013 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
10014 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010015 csrRoamStopWaitForKeyTimer( pMac );
10016
Jeff Johnson295189b2012-06-20 16:38:30 -070010017 //We are done with authentication, whethere succeed or not
10018 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010019 //We do it here because this linkup function is not called after association
10020 //when a key needs to be set.
10021 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
10022 {
10023 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10024 }
10025 }
Jeff Johnson43971f52012-07-17 12:26:56 -070010026 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010027 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010028 vos_mem_copy(&roamInfo.peerMac,
10029 &pRsp->peerMacAddr, sizeof(tCsrBssid));
Jeff Johnsone7245742012-09-05 17:12:55 -070010030 //Make sure we install the GTK before indicating to HDD as authenticated
10031 //This is to prevent broadcast packets go out after PTK and before GTK.
Kiet Lam64c1b492013-07-12 13:56:44 +053010032 if ( vos_mem_compare( &Broadcastaddr, pRsp->peerMacAddr,
10033 sizeof(tSirMacAddr) ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070010034 {
Yathish9f22e662012-12-10 14:21:35 -080010035#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
10036 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
10037 {
10038 tpSirSetActiveModeSetBncFilterReq pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053010039 pMsg = vos_mem_malloc(sizeof(tSirSetActiveModeSetBncFilterReq));
Yathish9f22e662012-12-10 14:21:35 -080010040 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
10041 pMsg->length = pal_cpu_to_be16(sizeof( tANI_U8));
10042 pMsg->seesionId = sessionId;
10043 status = palSendMBMessage(pMac->hHdd, pMsg );
10044 }
10045#endif
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010046 /* OBSS SCAN Indication will be sent to Firmware to start OBSS Scan */
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010047 if( CSR_IS_CHANNEL_24GHZ(pSession->connectedProfile.operationChannel)
10048 && IS_HT40_OBSS_SCAN_FEATURE_ENABLE )
10049 {
10050 tpSirSmeHT40OBSSScanInd pMsg;
10051 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSScanInd));
10052 pMsg->messageType =
10053 pal_cpu_to_be16((tANI_U16)eWNI_SME_HT40_OBSS_SCAN_IND);
10054 pMsg->length =
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010055 pal_cpu_to_be16(sizeof( tSirSmeHT40OBSSScanInd));
10056 vos_mem_copy(pMsg->peerMacAddr,
10057 pSession->connectedProfile.bssid,
10058 sizeof(tSirMacAddr));
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010059 status = palSendMBMessage(pMac->hHdd,
10060 pMsg );
10061 }
10062 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -070010063 }
10064 else
10065 {
10066 result = eCSR_ROAM_RESULT_NONE;
10067 }
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010068 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010069 }
10070 else
10071 {
10072 result = eCSR_ROAM_RESULT_FAILURE;
Arif Hussaina7c8e412013-11-20 11:06:42 -080010073 smsLog(pMac, LOGE, "CSR: Roam Completion setkey "
10074 "command failed(%d) PeerMac "MAC_ADDRESS_STR,
10075 pRsp->statusCode, MAC_ADDR_ARRAY(pRsp->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070010076 }
10077 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10078 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -070010079 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
10080 // can go ahead and initiate the TSPEC if any are pending
10081 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010082#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070010083 //Send Adjacent AP repot to new AP.
10084 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
10085 pSession->isPrevApInfoValid &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010086 pSession->connectedProfile.isESEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070010087 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010088#ifdef FEATURE_WLAN_ESE_UPLOAD
10089 csrSendEseAdjacentApRepInd(pMac, pSession);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010090#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010091 csrEseSendAdjacentApRepMsg(pMac, pSession);
Jeff Johnson295189b2012-06-20 16:38:30 -070010092#endif
10093 pSession->isPrevApInfoValid = FALSE;
10094 }
10095#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010096 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10097 {
10098 csrReleaseCommandSetKey( pMac, pCommand );
10099 }
10100 }
10101 else
10102 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010103 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010104 }
10105 }
10106 else
10107 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010108 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010109 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010110 smeProcessPendingQueue( pMac );
10111 }
10112 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010113 case eWNI_SME_REMOVEKEY_RSP:
10114 {
10115 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
10116 tListElem *pEntry;
10117 tSmeCmd *pCommand;
10118
10119 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10120 if ( pEntry )
10121 {
10122 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10123 if ( eSmeCommandRemoveKey == pCommand->command )
10124 {
10125 sessionId = pCommand->sessionId;
10126 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010127
10128 if(!pSession)
10129 {
10130 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10131 return;
10132 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010133#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10134 {
10135 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053010136 vos_mem_set(&removeKeyEvent,
10137 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010138 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
10139 removeKeyEvent.encryptionModeMulticast =
10140 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10141 removeKeyEvent.encryptionModeUnicast =
10142 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010143 vos_mem_copy( removeKeyEvent.bssid,
10144 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010145 removeKeyEvent.authMode =
10146 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -070010147 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010148 {
10149 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10150 }
10151 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
10152 }
10153#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -070010154 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010155 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010156 vos_mem_copy(&roamInfo.peerMac, &pRsp->peerMacAddr,
10157 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010158 result = eCSR_ROAM_RESULT_NONE;
10159 pRoamInfo = &roamInfo;
10160 }
10161 else
10162 {
10163 result = eCSR_ROAM_RESULT_FAILURE;
10164 }
10165 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10166 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
10167 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10168 {
10169 csrReleaseCommandRemoveKey( pMac, pCommand );
10170 }
10171 }
10172 else
10173 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010174 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010175 }
10176 }
10177 else
10178 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010179 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010180 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010181 smeProcessPendingQueue( pMac );
10182 }
10183 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010184 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010185 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010186 csrRoamStatsRspProcessor( pMac, pSirMsg );
10187 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010188#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080010189 case eWNI_SME_GET_ROAM_RSSI_RSP:
10190 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
10191 csrRoamRssiRspProcessor( pMac, pSirMsg );
10192 break;
10193#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010194#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010195 case eWNI_SME_GET_TSM_STATS_RSP:
10196 smsLog( pMac, LOG2, FL("TSM Stats rsp from PE"));
10197 csrTsmStatsRspProcessor( pMac, pSirMsg );
10198 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010199#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -070010200 case eWNI_SME_GET_RSSI_REQ:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010201 smsLog( pMac, LOG2, FL("GetRssiReq from self"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010202 csrUpdateRssi( pMac, pSirMsg );
10203 break;
10204
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053010205 case eWNI_SME_GET_SNR_REQ:
10206 smsLog( pMac, LOG2, FL("GetSnrReq from self"));
10207 csrUpdateSnr(pMac, pSirMsg);
10208 break;
10209
Jeff Johnson295189b2012-06-20 16:38:30 -070010210#ifdef WLAN_FEATURE_VOWIFI_11R
10211 case eWNI_SME_FT_PRE_AUTH_RSP:
10212 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
10213 break;
10214#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010215 case eWNI_SME_MAX_ASSOC_EXCEEDED:
10216 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010217 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 -070010218 sessionId = pSmeMaxAssocInd->sessionId;
10219 roamInfo.sessionId = sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053010220 vos_mem_copy(&roamInfo.peerMac, pSmeMaxAssocInd->peerMac,
10221 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010222 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
10223 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
10224 break;
10225
10226 case eWNI_SME_BTAMP_LOG_LINK_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010227 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010228 btampEstablishLogLinkHdlr( pSirMsg );
10229 break;
Jeff Johnsone7245742012-09-05 17:12:55 -070010230 case eWNI_SME_RSSI_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010231 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread"));
Jeff Johnsone7245742012-09-05 17:12:55 -070010232 csrRoamRssiIndHdlr( pMac, pSirMsg );
10233 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010234#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
10235 case eWNI_SME_CANDIDATE_FOUND_IND:
10236 smsLog( pMac, LOG2, FL("Candidate found indication from PE"));
10237 csrNeighborRoamCandidateFoundIndHdlr( pMac, pSirMsg );
10238 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070010239 case eWNI_SME_HANDOFF_REQ:
10240 smsLog( pMac, LOG2, FL("Handoff Req from self"));
10241 csrNeighborRoamHandoffReqHdlr( pMac, pSirMsg );
10242 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010243#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010244
10245 default:
10246 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010247 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -070010248}
10249
Jeff Johnson295189b2012-06-20 16:38:30 -070010250void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
10251 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
10252{
10253 if(pSession)
10254 {
10255 if(pSession->bRefAssocStartCnt)
10256 {
10257 pSession->bRefAssocStartCnt--;
10258 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
10259 //Need to call association_completion because there is an assoc_start pending.
10260 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
10261 eCSR_ROAM_ASSOCIATION_COMPLETION,
10262 eCSR_ROAM_RESULT_FAILURE);
10263 }
10264 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
10265 }
10266 else
10267 {
10268 smsLog(pMac, LOGW, FL(" pSession is NULL"));
10269 }
10270}
10271
10272
10273eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
10274{
10275 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010276 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
10277 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
10278 {
10279 status = csrScanRequestLostLink1( pMac, sessionId );
10280 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010281 return(status);
10282}
10283
Jeff Johnson295189b2012-06-20 16:38:30 -070010284//return a boolean to indicate whether roaming completed or continue.
10285tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
10286 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
10287{
10288 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
10289 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
10290 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10291 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010292 if(!pSession)
10293 {
10294 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10295 return eANI_BOOLEAN_FALSE;
10296 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010297 //Check whether time is up
10298 if(pSession->fCancelRoaming || fForce ||
10299 ((curTime - pSession->roamingStartTime) > roamTime) ||
10300 eCsrReassocRoaming == pSession->roamingReason ||
10301 eCsrDynamicRoaming == pSession->roamingReason)
10302 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010303 smsLog(pMac, LOGW, FL(" indicates roaming completion"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010304 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
10305 {
10306 //roaming is cancelled, tell HDD to indicate disconnect
10307 //Because LIM overload deauth_ind for both deauth frame and missed beacon
10308 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
10309 //to be eSIR_BEACON_MISSED
10310 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
10311 {
10312 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10313 }
10314 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
10315 {
10316 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
10317 }
10318 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
10319 {
10320 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
10321 }
10322 else
10323 {
10324 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10325 }
10326 }
10327 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10328 pSession->roamingReason = eCsrNotRoaming;
10329 }
10330 else
10331 {
10332 pSession->roamResult = roamResult;
10333 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
10334 {
10335 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10336 pSession->roamingReason = eCsrNotRoaming;
10337 }
10338 else
10339 {
10340 fCompleted = eANI_BOOLEAN_FALSE;
10341 }
10342 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010343 return(fCompleted);
10344}
10345
Jeff Johnson295189b2012-06-20 16:38:30 -070010346void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
10347{
10348 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010349
10350 if(!pSession)
10351 {
10352 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10353 return;
10354 }
10355
Jeff Johnson295189b2012-06-20 16:38:30 -070010356 if(CSR_IS_ROAMING(pSession))
10357 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010358 smsLog(pMac, LOGW, " Cancelling roaming");
Jeff Johnson295189b2012-06-20 16:38:30 -070010359 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
10360 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
10361 {
10362 //No need to do anything in here because the handler takes care of it
10363 }
10364 else
10365 {
10366 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
10367 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
10368 //Roaming is stopped after here
10369 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
10370 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053010371 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010372 csrRoamStopRoamingTimer(pMac, sessionId);
10373 }
10374 }
10375}
10376
Jeff Johnson295189b2012-06-20 16:38:30 -070010377void csrRoamRoamingTimerHandler(void *pv)
10378{
10379 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10380 tpAniSirGlobal pMac = pInfo->pMac;
10381 tANI_U32 sessionId = pInfo->sessionId;
10382 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010383
10384 if(!pSession)
10385 {
10386 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10387 return;
10388 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010389
10390 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
10391 {
10392 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
10393 {
10394 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
10395 pSession->roamingReason = eCsrNotRoaming;
10396 }
10397 }
10398}
10399
Jeff Johnson295189b2012-06-20 16:38:30 -070010400eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
10401{
10402 eHalStatus status;
10403 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010404
10405 if(!pSession)
10406 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010407 smsLog(pMac, LOGE, FL(" session %d not found"), sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -070010408 return eHAL_STATUS_FAILURE;
10409 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010410
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010411 smsLog(pMac, LOG1, " csrScanStartRoamingTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070010412 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010413 status = vos_timer_start(&pSession->hTimerRoaming, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010414
10415 return (status);
10416}
10417
Jeff Johnson295189b2012-06-20 16:38:30 -070010418eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
10419{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010420 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerRoaming));
Jeff Johnson295189b2012-06-20 16:38:30 -070010421}
10422
Jeff Johnson295189b2012-06-20 16:38:30 -070010423void csrRoamWaitForKeyTimeOutHandler(void *pv)
10424{
10425 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10426 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010427 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080010428 eHalStatus status = eHAL_STATUS_FAILURE;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010429
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010430 smsLog(pMac, LOGW, FL("WaitForKey timer expired in state=%s sub-state=%s"),
10431 macTraceGetNeighbourRoamState(
10432 pMac->roam.neighborRoamInfo.neighborRoamState),
10433 macTraceGetcsrRoamSubState(
10434 pMac->roam.curSubState[pInfo->sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010435
Jeff Johnson295189b2012-06-20 16:38:30 -070010436 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
10437 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010438#ifdef FEATURE_WLAN_LFR
10439 if (csrNeighborRoamIsHandoffInProgress(pMac))
10440 {
10441 /*
10442 * Enable heartbeat timer when hand-off is in progress
10443 * and Key Wait timer expired.
10444 */
10445 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010446 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010447 pMac->roam.configParam.HeartbeatThresh24);
10448 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10449 pMac->roam.configParam.HeartbeatThresh24,
10450 NULL, eANI_BOOLEAN_FALSE);
10451 }
10452#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010453 smsLog(pMac, LOGW, " SME pre-auth state timeout. ");
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010454
Jeff Johnson295189b2012-06-20 16:38:30 -070010455 //Change the substate so command queue is unblocked.
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010456 if (CSR_ROAM_SESSION_MAX > pInfo->sessionId)
10457 {
10458 csrRoamSubstateChange(pMac, eCSR_ROAM_SUBSTATE_NONE,
10459 pInfo->sessionId);
10460 }
10461
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010462 if (pSession)
10463 {
10464 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
10465 {
10466 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10467 smeProcessPendingQueue(pMac);
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080010468 if( (pSession->connectedProfile.AuthType ==
10469 eCSR_AUTH_TYPE_SHARED_KEY) &&
10470 ( (pSession->connectedProfile.EncryptionType ==
10471 eCSR_ENCRYPT_TYPE_WEP40) ||
10472 (pSession->connectedProfile.EncryptionType ==
10473 eCSR_ENCRYPT_TYPE_WEP104) ))
10474 {
10475 status = sme_AcquireGlobalLock( &pMac->sme );
10476 if ( HAL_STATUS_SUCCESS( status ) )
10477 {
10478 csrRoamDisconnect( pMac, pInfo->sessionId,
10479 eCSR_DISCONNECT_REASON_UNSPECIFIED );
10480 sme_ReleaseGlobalLock( &pMac->sme );
10481 }
10482 }
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010483 }
10484 else
10485 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010486 smsLog(pMac, LOGW, "%s: could not post link up",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010487 __func__);
10488 }
10489 }
10490 else
10491 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010492 smsLog(pMac, LOGW, "%s: session not found", __func__);
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010493 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010494 }
10495
10496}
10497
Jeff Johnson295189b2012-06-20 16:38:30 -070010498eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
10499{
10500 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010501#ifdef FEATURE_WLAN_LFR
10502 if (csrNeighborRoamIsHandoffInProgress(pMac))
10503 {
10504 /* Disable heartbeat timer when hand-off is in progress */
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010505 smsLog(pMac, LOG2, FL("disabling HB timer in state=%s sub-state=%s"),
10506 macTraceGetNeighbourRoamState(
10507 pMac->roam.neighborRoamInfo.neighborRoamState),
10508 macTraceGetcsrRoamSubState(
10509 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]
10510 ));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010511 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
10512 }
10513#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010514 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010515 status = vos_timer_start(&pMac->roam.hTimerWaitForKey, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010516
10517 return (status);
10518}
10519
Jeff Johnson295189b2012-06-20 16:38:30 -070010520eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
10521{
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010522 smsLog(pMac, LOG2, FL("WaitForKey timer stopped in state=%s sub-state=%s"),
10523 macTraceGetNeighbourRoamState(
10524 pMac->roam.neighborRoamInfo.neighborRoamState),
10525 macTraceGetcsrRoamSubState(
10526 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010527#ifdef FEATURE_WLAN_LFR
10528 if (csrNeighborRoamIsHandoffInProgress(pMac))
10529 {
10530 /*
10531 * Enable heartbeat timer when hand-off is in progress
10532 * and Key Wait timer got stopped for some reason
10533 */
10534 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010535 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010536 pMac->roam.configParam.HeartbeatThresh24);
10537 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10538 pMac->roam.configParam.HeartbeatThresh24,
10539 NULL, eANI_BOOLEAN_FALSE);
10540 }
10541#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010542 return (vos_timer_stop(&pMac->roam.hTimerWaitForKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070010543}
10544
Jeff Johnson295189b2012-06-20 16:38:30 -070010545void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
10546 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
10547{
10548 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
10549 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010550 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
10551 /* To silence the KW tool Null chaeck is added */
10552 if(!pSession)
10553 {
10554 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10555 return;
10556 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010557
10558 if(pCommand)
10559 {
10560 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010561 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070010562 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010563 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
10564 {
10565 //if success, force roaming completion
10566 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
10567 }
10568 else
10569 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010570 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010571 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d"), roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -070010572 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
10573 }
10574}
10575
Jeff Johnson295189b2012-06-20 16:38:30 -070010576eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
10577{
10578 eHalStatus status = eHAL_STATUS_SUCCESS;
10579 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
10580 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
10581 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
10582 tCsrRoamInfo *pRoamInfo = NULL;
10583 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010584 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -070010585 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010586 /* To silence the KW tool Null chaeck is added */
10587 if(!pSession)
10588 {
10589 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10590 return eHAL_STATUS_FAILURE;
10591 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010592 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010593 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -070010594 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
10595 if ( eWNI_SME_DISASSOC_IND == type )
10596 {
10597 result = eCSR_ROAM_RESULT_DISASSOC_IND;
10598 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
10599 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010600 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010601 }
10602 else if ( eWNI_SME_DEAUTH_IND == type )
10603 {
10604 result = eCSR_ROAM_RESULT_DEAUTH_IND;
10605 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
10606 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Madan Mohan Koyyalamudi6a808932012-11-06 16:05:54 -080010607 /* Convert into proper reason code */
10608 pSession->joinFailStatusCode.reasonCode =
10609 (pDeauthIndMsg->reasonCode == eSIR_BEACON_MISSED) ?
Agarwal Ashish838f1f32013-03-11 20:54:52 +053010610 0 : pDeauthIndMsg->reasonCode;
10611 /* cfg layer expects 0 as reason code if
10612 the driver dosent know the reason code
10613 eSIR_BEACON_MISSED is defined as locally */
Jeff Johnson295189b2012-06-20 16:38:30 -070010614 }
10615 else
10616 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010617 smsLog(pMac, LOGW, FL("gets an unknown type (%d)"), type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010618 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010619 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070010620 }
10621
10622 // call profile lost link routine here
Jeff Johnson295189b2012-06-20 16:38:30 -070010623 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -070010624 {
10625 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_LOSTLINK_DETECTED, result);
10626 }
10627
10628 if ( eWNI_SME_DISASSOC_IND == type )
10629 {
10630 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
10631 }
10632 else if ( eWNI_SME_DEAUTH_IND == type )
10633 {
10634 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
10635 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010636 if(!HAL_STATUS_SUCCESS(status))
10637 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010638 //If fail to send confirmation to PE, not to trigger roaming
10639 fToRoam = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010640 }
10641
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010642 //prepare to tell HDD to disconnect
Kiet Lam64c1b492013-07-12 13:56:44 +053010643 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010644 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10645 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010646 if( eWNI_SME_DISASSOC_IND == type)
10647 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010648 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010649 vos_mem_copy(roamInfo.peerMac, pDisassocIndMsg->peerMacAddr,
10650 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010651 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
10652 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010653 else if( eWNI_SME_DEAUTH_IND == type )
10654 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010655 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010656 vos_mem_copy(roamInfo.peerMac, pDeauthIndMsg->peerMacAddr,
10657 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010658 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
10659 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010660 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)"), roamInfo.staId);
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010661
10662 /* See if we can possibly roam. If so, start the roaming process and notify HDD
10663 that we are roaming. But if we cannot possibly roam, or if we are unable to
10664 currently roam, then notify HDD of the lost link */
Jeff Johnson295189b2012-06-20 16:38:30 -070010665 if(fToRoam)
10666 {
10667 //Only remove the connected BSS in infrastructure mode
10668 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10669 //Not to do anying for lostlink with WDS
10670 if( pMac->roam.configParam.nRoamingTime )
10671 {
10672 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
10673 ( eWNI_SME_DEAUTH_IND == type ) ?
10674 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
10675 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010676 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010677 //For IBSS, we need to give some more info to HDD
10678 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
10679 {
10680 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
10681 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10682 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
10683 }
10684 else
10685 {
10686 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
10687 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010688 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010689 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
10690 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
10691 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10692 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
10693 }
10694 else
10695 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010696 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010697 fToRoam = eANI_BOOLEAN_FALSE;
10698 }
10699 }
10700 else
10701 {
10702 //We are told not to roam, indicate lostlink
10703 fToRoam = eANI_BOOLEAN_FALSE;
10704 }
10705 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010706 if(!fToRoam)
10707 {
Madan Mohan Koyyalamudiaf854cf2012-10-30 17:56:25 -070010708 //Tell HDD about the lost link
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010709 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010710 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010711 /* Don't call csrRoamCallCallback for GO/SoftAp case as this indication
10712 * was already given as part of eWNI_SME_DISASSOC_IND msg handling in
10713 * csrRoamCheckForLinkStatusChange API.
10714 */
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010715 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
10716 }
10717
10718 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -070010719 Still enable idle scan for polling in case concurrent sessions are running */
10720 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
10721 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010722 csrScanStartIdleScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010723 }
10724 }
10725
10726 return (status);
10727}
10728
Jeff Johnson295189b2012-06-20 16:38:30 -070010729eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
10730{
10731 eHalStatus status = eHAL_STATUS_SUCCESS;
10732 tListElem *pEntry = NULL;
10733 tSmeCmd *pCommand = NULL;
10734 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010735
10736 if(!pSession)
10737 {
10738 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10739 return eHAL_STATUS_FAILURE;
10740 }
10741
Jeff Johnson295189b2012-06-20 16:38:30 -070010742 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010743 //Only remove the connected BSS in infrastructure mode
10744 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10745 if(pMac->roam.configParam.nRoamingTime)
10746 {
10747 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
10748 {
10749 //before starting the lost link logic release the roam command for handoff
10750 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
10751 if(pEntry)
10752 {
10753 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
10754 }
10755 if(pCommand)
10756 {
10757 if (( eSmeCommandRoam == pCommand->command ) &&
10758 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
10759 {
10760 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10761 {
10762 csrReleaseCommandRoam( pMac, pCommand );
10763 }
10764 }
10765 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010766 smsLog( pMac, LOGW, "Lost link roaming started ...");
Jeff Johnson295189b2012-06-20 16:38:30 -070010767 }
10768 }
10769 else
10770 {
10771 //We are told not to roam, indicate lostlink
10772 status = eHAL_STATUS_FAILURE;
10773 }
10774
10775 return (status);
10776}
Jeff Johnson295189b2012-06-20 16:38:30 -070010777void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
10778{
10779 tListElem *pEntry;
10780 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070010781 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10782 if ( pEntry )
10783 {
10784 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10785 if ( eSmeCommandWmStatusChange == pCommand->command )
10786 {
10787 // Nothing to process in a Lost Link completion.... It just kicks off a
10788 // roaming sequence.
10789 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10790 {
10791 csrReleaseCommandWmStatusChange( pMac, pCommand );
10792 }
10793 else
10794 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010795 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command");
Jeff Johnson295189b2012-06-20 16:38:30 -070010796 }
10797
10798 }
10799 else
10800 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010801 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010802 }
10803 }
10804 else
10805 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010806 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010807 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010808 smeProcessPendingQueue( pMac );
10809}
10810
Jeff Johnson295189b2012-06-20 16:38:30 -070010811void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
10812{
10813 eHalStatus status = eHAL_STATUS_FAILURE;
10814 tSirSmeRsp *pSirSmeMsg;
10815 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010816
10817 if(!pSession)
10818 {
10819 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
10820 return;
10821 }
10822
Jeff Johnson295189b2012-06-20 16:38:30 -070010823 switch ( pCommand->u.wmStatusChangeCmd.Type )
10824 {
10825 case eCsrDisassociated:
10826 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
10827 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
10828 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010829 case eCsrDeauthenticated:
10830 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
10831 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
10832 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010833 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010834 smsLog(pMac, LOGW, FL("gets an unknown command %d"), pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010835 break;
10836 }
10837 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
10838 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
10839 {
10840 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
10841 {
10842 //This is not good
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010843 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010844 }
10845 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010846 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
10847 // command here since there is nothing else to do.
10848 csrRoamWmStatusChangeComplete( pMac );
10849}
10850
Jeff Johnson295189b2012-06-20 16:38:30 -070010851//This function returns band and mode information.
10852//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
10853//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -070010854static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10855 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -070010856{
Jeff Johnson295189b2012-06-20 16:38:30 -070010857 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
10858 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
10859 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070010860 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -070010861
Jeff Johnson295189b2012-06-20 16:38:30 -070010862 //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 -070010863 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
10864 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
10865 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
10866 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -070010867 {
10868 switch( pMac->roam.configParam.uCfgDot11Mode )
10869 {
10870 case eCSR_CFG_DOT11_MODE_11A:
10871 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10872 eBand = eCSR_BAND_5G;
10873 break;
10874 case eCSR_CFG_DOT11_MODE_11B:
10875 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10876 eBand = eCSR_BAND_24;
10877 break;
10878 case eCSR_CFG_DOT11_MODE_11G:
10879 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10880 eBand = eCSR_BAND_24;
10881 break;
10882 case eCSR_CFG_DOT11_MODE_11N:
10883 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010884 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10885 break;
10886#ifdef WLAN_FEATURE_11AC
10887 case eCSR_CFG_DOT11_MODE_11AC:
10888 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10889 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010890 /* If the operating channel is in 2.4 GHz band, check for
10891 * INI item to disable VHT operation in 2.4 GHz band
10892 */
10893 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10894 !pMac->roam.configParam.enableVhtFor24GHz)
10895 {
10896 /* Disable 11AC operation */
10897 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10898 }
10899 else
10900 {
10901 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10902 }
10903 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010904 }
10905 else
10906 {
10907 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10908 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10909 }
10910 break;
10911 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
10912 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10913 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010914 /* If the operating channel is in 2.4 GHz band, check for
10915 * INI item to disable VHT operation in 2.4 GHz band
10916 */
10917 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10918 !pMac->roam.configParam.enableVhtFor24GHz)
10919 {
10920 /* Disable 11AC operation */
10921 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10922 }
10923 else
10924 {
10925 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
10926 }
10927 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010928 }
10929 else
10930 {
10931 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10932 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10933 }
10934 break;
10935#endif
10936 case eCSR_CFG_DOT11_MODE_AUTO:
10937 eBand = pMac->roam.configParam.eBand;
10938 if (eCSR_BAND_24 == eBand)
10939 {
10940 // WiFi tests require IBSS networks to start in 11b mode
10941 // without any change to the default parameter settings
10942 // on the adapter. We use ACU to start an IBSS through
10943 // creation of a startIBSS profile. This startIBSS profile
10944 // has Auto MACProtocol and the adapter property setting
10945 // for dot11Mode is also AUTO. So in this case, let's
10946 // start the IBSS network in 11b mode instead of 11g mode.
10947 // So this is for Auto=profile->MacProtocol && Auto=Global.
10948 // dot11Mode && profile->channel is < 14, then start the IBSS
10949 // in b mode.
10950 //
10951 // Note: we used to have this start as an 11g IBSS for best
10952 // performance... now to specify that the user will have to
10953 // set the do11Mode in the property page to 11g to force it.
10954 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10955 }
10956 else
10957 {
10958#ifdef WLAN_FEATURE_11AC
10959 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10960 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010961 /* If the operating channel is in 2.4 GHz band, check for
10962 * INI item to disable VHT operation in 2.4 GHz band
10963 */
10964 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10965 !pMac->roam.configParam.enableVhtFor24GHz)
10966 {
10967 /* Disable 11AC operation */
10968 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10969 }
10970 else
10971 {
10972 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10973 }
10974 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010975 }
10976 else
10977 {
10978 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10979 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10980 }
10981#else
10982 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10983 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10984#endif
10985 }
10986 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010987 default:
10988 // Global dot11 Mode setting is 11a/b/g.
10989 // use the channel number to determine the Mode setting.
10990 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10991 {
10992 eBand = pMac->roam.configParam.eBand;
10993 if(eCSR_BAND_24 == eBand)
10994 {
10995 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
10996 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10997 }
10998 else
10999 {
11000 //prefer 5GHz
11001 eBand = eCSR_BAND_5G;
11002 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11003 }
11004 }
11005 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11006 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070011007 // WiFi tests require IBSS networks to start in 11b mode
11008 // without any change to the default parameter settings
11009 // on the adapter. We use ACU to start an IBSS through
11010 // creation of a startIBSS profile. This startIBSS profile
11011 // has Auto MACProtocol and the adapter property setting
11012 // for dot11Mode is also AUTO. So in this case, let's
11013 // start the IBSS network in 11b mode instead of 11g mode.
11014 // So this is for Auto=profile->MacProtocol && Auto=Global.
11015 // dot11Mode && profile->channel is < 14, then start the IBSS
11016 // in b mode.
Jeff Johnson295189b2012-06-20 16:38:30 -070011017 //
Ravi Joshia96ceb42013-05-20 18:52:39 -070011018 // Note: we used to have this start as an 11g IBSS for best
11019 // performance... now to specify that the user will have to
11020 // set the do11Mode in the property page to 11g to force it.
Jeff Johnson295189b2012-06-20 16:38:30 -070011021 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11022 eBand = eCSR_BAND_24;
11023 }
11024 else
11025 {
11026 // else, it's a 5.0GHz channel. Set mode to 11a.
11027 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11028 eBand = eCSR_BAND_5G;
11029 }
11030 break;
11031 }//switch
11032 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
11033 else
11034 {
11035 //dot11 mode is set, lets pick the band
11036 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
11037 {
11038 // channel is Auto also.
11039 eBand = pMac->roam.configParam.eBand;
11040 if(eCSR_BAND_ALL == eBand)
11041 {
11042 //prefer 5GHz
11043 eBand = eCSR_BAND_5G;
11044 }
11045 }
11046 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11047 {
11048 eBand = eCSR_BAND_24;
11049 }
11050 else
11051 {
11052 eBand = eCSR_BAND_5G;
11053 }
Ravi Joshia96ceb42013-05-20 18:52:39 -070011054 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011055 if(pBand)
11056 {
11057 *pBand = eBand;
11058 }
11059
11060 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011061 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -070011062 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11063 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011064
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080011065 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
11066 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 -070011067 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011068#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011069 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011070#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011071 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
11072 {
11073 //We cannot do 11n here
11074 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11075 {
11076 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
11077 }
11078 else
11079 {
11080 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11081 }
11082 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011083 return( cfgDot11Mode );
11084}
11085
Jeff Johnson295189b2012-06-20 16:38:30 -070011086eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
11087{
11088 eHalStatus status;
11089 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011090
11091 if(!pSession)
11092 {
11093 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11094 return eHAL_STATUS_FAILURE;
11095 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011096
11097#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11098 {
11099 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011100 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11101 if(pIbssLog)
11102 {
11103 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
11104 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11105 }
11106 }
11107#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011108 // Set the roaming substate to 'stop Bss request'...
11109 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
11110
11111 // attempt to stop the Bss (reason code is ignored...)
11112 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080011113 if(!HAL_STATUS_SUCCESS(status))
11114 {
11115 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
11116 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011117 return (status);
11118}
11119
Jeff Johnson295189b2012-06-20 16:38:30 -070011120//pNumChan is a caller allocated space with the sizeof pChannels
11121eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
11122{
11123
11124 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
11125 (tANI_U8 *)pChannels,
11126 pNumChan));
11127}
11128
Kiran4a17ebe2013-01-31 10:43:43 -080011129tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
11130{
11131 tANI_U32 cfgLength = 0;
11132 tANI_U16 cfgId = 0;
11133 tPowerdBm maxTxPwr = 0;
11134 tANI_U8 *pCountryInfo = NULL;
11135 eHalStatus status;
11136 tANI_U8 count = 0;
11137 tANI_U8 firstChannel;
11138 tANI_U8 maxChannels;
11139
11140 if (CSR_IS_CHANNEL_5GHZ(channel))
11141 {
11142 cfgId = WNI_CFG_MAX_TX_POWER_5;
11143 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
11144 }
11145 else if (CSR_IS_CHANNEL_24GHZ(channel))
11146 {
11147 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
11148 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
11149 }
11150 else
11151 return maxTxPwr;
11152
Kiet Lam64c1b492013-07-12 13:56:44 +053011153 pCountryInfo = vos_mem_malloc(cfgLength);
11154 if ( NULL == pCountryInfo )
11155 status = eHAL_STATUS_FAILURE;
11156 else
11157 status = eHAL_STATUS_SUCCESS;
Kiran4a17ebe2013-01-31 10:43:43 -080011158 if (status != eHAL_STATUS_SUCCESS)
11159 {
11160 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiet Lam64c1b492013-07-12 13:56:44 +053011161 FL("%s: failed to allocate memory, status = %d"),
Kiran4a17ebe2013-01-31 10:43:43 -080011162 __FUNCTION__, status);
11163 goto error;
11164 }
11165 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
11166 if (status != eHAL_STATUS_SUCCESS)
11167 {
11168 goto error;
11169 }
11170 /* Identify the channel and maxtxpower */
11171 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
11172 {
11173 firstChannel = pCountryInfo[count++];
11174 maxChannels = pCountryInfo[count++];
11175 maxTxPwr = pCountryInfo[count++];
11176
11177 if ((channel >= firstChannel) &&
11178 (channel < (firstChannel + maxChannels)))
11179 {
11180 break;
11181 }
11182 }
11183
11184error:
11185 if (NULL != pCountryInfo)
Kiet Lam64c1b492013-07-12 13:56:44 +053011186 vos_mem_free(pCountryInfo);
Kiran4a17ebe2013-01-31 10:43:43 -080011187
11188 return maxTxPwr;
11189}
11190
11191
Jeff Johnson295189b2012-06-20 16:38:30 -070011192tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
11193{
11194 tANI_BOOLEAN fValid = FALSE;
11195 tANI_U32 idxValidChannels;
11196 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11197
11198 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
11199 {
11200 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
11201 {
11202 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
11203 {
11204 fValid = TRUE;
11205 break;
11206 }
11207 }
11208 }
11209 pMac->roam.numValidChannels = len;
11210 return fValid;
11211}
11212
Jeff Johnson295189b2012-06-20 16:38:30 -070011213tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
11214{
11215 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
11216 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011217 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
11218 {
11219 if(channel == pMac->scan.base40MHzChannels.channelList[i])
11220 {
11221 fValid = eANI_BOOLEAN_TRUE;
11222 break;
11223 }
11224 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011225 return (fValid);
11226}
11227
Jeff Johnson295189b2012-06-20 16:38:30 -070011228//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070011229 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011230{
Jeff Johnsone7245742012-09-05 17:12:55 -070011231 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011232 tANI_U8 centerChn;
11233 tANI_U32 ChannelBondingMode;
Sandeep Puligilla60342762014-01-30 21:05:37 +053011234
Jeff Johnson295189b2012-06-20 16:38:30 -070011235 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
11236 {
11237 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
11238 }
11239 else
11240 {
11241 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
11242 }
11243 //Figure what the other side's CB mode
11244 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
11245 {
11246 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
11247 {
Agrawal Ashishf187d512014-04-03 17:01:52 +053011248 // In Case WPA2 and TKIP is the only one cipher suite in Pairwise.
11249 if ((pIes->RSN.present && (pIes->RSN.pwise_cipher_suite_count == 1) &&
11250 !memcmp(&(pIes->RSN.pwise_cipher_suites[0][0]),
11251 "\x00\x0f\xac\x02",4))
11252 //In Case WPA1 and TKIP is the only one cipher suite in Unicast.
11253 ||(pIes->WPA.present && (pIes->WPA.unicast_cipher_count == 1) &&
11254 !memcmp(&(pIes->WPA.unicast_ciphers[0][0]),
11255 "\x00\x50\xf2\x02",4)))
11256
Leela Venkata Kiran Kumar Reddy Chirala10c5a2e2013-12-18 14:41:28 -080011257 {
11258 smsLog(pMac, LOGW, " No channel bonding in TKIP mode ");
11259 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11260 }
11261
11262 else if(pIes->HTInfo.present)
Jeff Johnson295189b2012-06-20 16:38:30 -070011263 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011264 /* This is called during INFRA STA/CLIENT and should use the merged value of
11265 * supported channel width and recommended tx width as per standard
11266 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011267 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070011268 pIes->HTCaps.supportedChannelWidthSet,
11269 pIes->HTInfo.recommendedTxWidthSet,
11270 pIes->HTInfo.secondaryChannelOffset);
11271
11272 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
11273 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070011274 else
Jeff Johnsone7245742012-09-05 17:12:55 -070011275 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11276 switch (eRet) {
11277 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
11278 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
11279 break;
11280 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
11281 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
11282 break;
11283 case PHY_SINGLE_CHANNEL_CENTERED:
11284 default:
11285 centerChn = primaryChn;
11286 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011287 }
Jeff Johnsone7245742012-09-05 17:12:55 -070011288 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070011289 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011290 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Abhishek Singh25144bb2014-05-01 16:03:21 +053011291 eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011292 }
11293 }
11294 }
11295 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011296 return eRet;
11297}
Jeff Johnson295189b2012-06-20 16:38:30 -070011298tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
11299{
11300 tANI_BOOLEAN fFound = FALSE;
11301 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011302 for( idx = 0; idx < pCipherList->numEntries; idx++ )
11303 {
11304 if( pCipherList->encryptionType[idx] == encryptionType )
11305 {
11306 fFound = TRUE;
11307 break;
11308 }
11309 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011310 return fFound;
11311}
Jeff Johnson295189b2012-06-20 16:38:30 -070011312tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
11313{
11314 tANI_BOOLEAN fFound = FALSE;
11315 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011316 for( idx = 0; idx < pAuthList->numEntries; idx++ )
11317 {
11318 if( pAuthList->authType[idx] == authType )
11319 {
11320 fFound = TRUE;
11321 break;
11322 }
11323 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011324 return fFound;
11325}
Jeff Johnson295189b2012-06-20 16:38:30 -070011326tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
11327{
11328 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11329 tCsrScanResultFilter *pScanFilter = NULL;
11330 eHalStatus status = eHAL_STATUS_SUCCESS;
11331
11332 if(pProfile1 && pProfile2)
11333 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011334 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
11335 if ( NULL == pScanFilter )
11336 status = eHAL_STATUS_FAILURE;
11337 else
11338 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011339 if(HAL_STATUS_SUCCESS(status))
11340 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011341 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011342 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
11343 if(HAL_STATUS_SUCCESS(status))
11344 {
11345 fCheck = eANI_BOOLEAN_FALSE;
11346 do
11347 {
11348 tANI_U32 i;
11349 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
11350 {
11351 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
11352 pScanFilter->SSIDs.SSIDList[i].SSID.length,
11353 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
11354 if ( fCheck ) break;
11355 }
11356 if(!fCheck)
11357 {
11358 break;
11359 }
11360 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
11361 || pProfile2->BSSType != pProfile1->BSSType
11362 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
11363 )
11364 {
11365 fCheck = eANI_BOOLEAN_FALSE;
11366 break;
11367 }
11368#ifdef WLAN_FEATURE_VOWIFI_11R
11369 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
11370 {
11371 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
11372 {
11373 fCheck = eANI_BOOLEAN_FALSE;
11374 break;
11375 }
11376 }
11377#endif
11378 //Match found
11379 fCheck = eANI_BOOLEAN_TRUE;
11380 }while(0);
11381 csrFreeScanFilter(pMac, pScanFilter);
11382 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011383 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011384 }
11385 }
11386
11387 return (fCheck);
11388}
11389
Jeff Johnson295189b2012-06-20 16:38:30 -070011390tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
11391{
11392 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11393 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011394 do
11395 {
11396 //Only check for static WEP
11397 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
11398 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
11399 {
11400 fCheck = eANI_BOOLEAN_TRUE;
11401 break;
11402 }
11403 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
11404 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
11405 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
11406 {
11407 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053011408 if (!vos_mem_compare(&pConnProfile->Keys.KeyMaterial[i],
11409 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
Jeff Johnson295189b2012-06-20 16:38:30 -070011410 {
11411 break;
11412 }
11413 }
11414 if( i == CSR_MAX_NUM_KEY)
11415 {
11416 fCheck = eANI_BOOLEAN_TRUE;
11417 }
11418 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011419 return (fCheck);
11420}
11421
Jeff Johnson295189b2012-06-20 16:38:30 -070011422//IBSS
11423
Jeff Johnson295189b2012-06-20 16:38:30 -070011424tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
11425{
11426 tANI_U8 channel = 0;
11427 tANI_U32 idx;
11428 tANI_U32 idxValidChannels;
11429 tANI_BOOLEAN fFound = FALSE;
11430 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11431
11432 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
11433 {
11434 channel = pMac->roam.configParam.AdHocChannel5G;
11435 if(!csrRoamIsChannelValid(pMac, channel))
11436 {
11437 channel = 0;
11438 }
11439 }
11440 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11441 {
11442 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
11443 {
11444 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11445 {
11446 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11447 {
11448 fFound = TRUE;
11449 channel = csrStartIbssChannels50[ idx ];
11450 }
11451 }
11452 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011453 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
11454 if (!fFound)
11455 {
11456 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
11457 {
11458 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idx ]) ) // the max channel# in 11g is 14
11459 {
11460 channel = csrStartIbssChannels50[ idx ];
11461 break;
11462 }
11463 }
11464 }
11465 }//if
11466
11467 return( channel );
11468}
11469
Jeff Johnson295189b2012-06-20 16:38:30 -070011470tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
11471{
11472 tANI_U8 channel = 1;
11473 tANI_U32 idx;
11474 tANI_U32 idxValidChannels;
11475 tANI_BOOLEAN fFound = FALSE;
11476 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11477
11478 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
11479 {
11480 channel = pMac->roam.configParam.AdHocChannel24;
11481 if(!csrRoamIsChannelValid(pMac, channel))
11482 {
11483 channel = 0;
11484 }
11485 }
11486
11487 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11488 {
11489 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
11490 {
11491 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11492 {
11493 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11494 {
11495 fFound = TRUE;
11496 channel = csrStartIbssChannels24[ idx ];
11497 }
11498 }
11499 }
11500 }
11501
11502 return( channel );
11503}
11504
Jeff Johnson295189b2012-06-20 16:38:30 -070011505static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
11506 tCsrRoamStartBssParams *pParam )
11507{
11508 eCsrCfgDot11Mode cfgDot11Mode;
11509 eCsrBand eBand;
11510 tANI_U8 channel = 0;
11511 tSirNwType nwType;
11512 tANI_U8 operationChannel = 0;
11513
11514 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
11515 {
11516 operationChannel = pProfile->ChannelInfo.ChannelList[0];
11517 }
11518
Jeff Johnson295189b2012-06-20 16:38:30 -070011519 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070011520
Jeff Johnson295189b2012-06-20 16:38:30 -070011521 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11522 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
11523 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
11524 )
11525 {
11526 /* This should never happen */
11527 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011528 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070011529 pProfile->csrPersona);
11530 VOS_ASSERT(0);
11531 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011532 switch( cfgDot11Mode )
11533 {
11534 case eCSR_CFG_DOT11_MODE_11G:
11535 nwType = eSIR_11G_NW_TYPE;
11536 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011537 case eCSR_CFG_DOT11_MODE_11B:
11538 nwType = eSIR_11B_NW_TYPE;
11539 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011540 case eCSR_CFG_DOT11_MODE_11A:
11541 nwType = eSIR_11A_NW_TYPE;
11542 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011543 default:
11544 case eCSR_CFG_DOT11_MODE_11N:
11545 case eCSR_CFG_DOT11_MODE_TAURUS:
11546 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
11547 if(eCSR_BAND_24 == eBand)
11548 {
11549 nwType = eSIR_11G_NW_TYPE;
11550 }
11551 else
11552 {
11553 nwType = eSIR_11A_NW_TYPE;
11554 }
11555 break;
11556 }
11557
11558 pParam->extendedRateSet.numRates = 0;
11559
11560 switch ( nwType )
11561 {
11562 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011563 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011564 case eSIR_11A_NW_TYPE:
11565
11566 pParam->operationalRateSet.numRates = 8;
11567
11568 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11569 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11570 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11571 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11572 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11573 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11574 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11575 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11576
11577 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11578 {
11579 channel = csrRoamGetIbssStartChannelNumber50( pMac );
11580 if( 0 == channel &&
11581 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
11582 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
11583 )
11584 {
11585 //We could not find a 5G channel by auto pick, let's try 2.4G channels
11586 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
11587 nwType = eSIR_11B_NW_TYPE;
11588 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11589 pParam->operationalRateSet.numRates = 4;
11590 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11591 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11592 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11593 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11594 }
11595 }
11596 else
11597 {
11598 channel = operationChannel;
11599 }
11600 break;
11601
11602 case eSIR_11B_NW_TYPE:
11603 pParam->operationalRateSet.numRates = 4;
11604 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11605 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11606 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11607 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070011608 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11609 {
11610 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11611 }
11612 else
11613 {
11614 channel = operationChannel;
11615 }
11616
11617 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011618 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070011619 /* For P2P Client and P2P GO, disable 11b rates */
11620 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11621 (pProfile->csrPersona == VOS_P2P_GO_MODE)
11622 )
11623 {
11624 pParam->operationalRateSet.numRates = 8;
11625
11626 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11627 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11628 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11629 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11630 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11631 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11632 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11633 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11634 }
11635 else
Jeff Johnson295189b2012-06-20 16:38:30 -070011636 {
11637 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070011638 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11639 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11640 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11641 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11642
11643 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070011644 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
11645 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
11646 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
11647 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
11648 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
11649 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
11650 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
11651 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
11652 }
11653
11654 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11655 {
11656 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11657 }
11658 else
11659 {
11660 channel = operationChannel;
11661 }
11662
11663 break;
11664 }
11665 pParam->operationChn = channel;
11666 pParam->sirNwType = nwType;
11667}
11668
Jeff Johnson295189b2012-06-20 16:38:30 -070011669static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
11670 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
11671{
11672
11673 if( pParam )
11674 {
11675 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070011676 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011677 pParam->operationChn = pBssDesc->channelId;
Kiet Lam64c1b492013-07-12 13:56:44 +053011678 vos_mem_copy(&pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011679
11680 if( pIes )
11681 {
11682 if(pIes->SuppRates.present)
11683 {
11684 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
11685 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
11686 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011687 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 -070011688 pIes->SuppRates.num_rates);
11689 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
11690 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011691 vos_mem_copy(pParam->operationalRateSet.rate, pIes->SuppRates.rates,
11692 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
Jeff Johnson295189b2012-06-20 16:38:30 -070011693 }
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011694 if (pIes->ExtSuppRates.present)
11695 {
11696 pParam->extendedRateSet.numRates = pIes->ExtSuppRates.num_rates;
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053011697 if(pIes->ExtSuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011698 {
11699 smsLog(pMac, LOGE, FL("num_rates :%d is more than \
11700 SIR_MAC_RATESET_EID_MAX, resetting to \
11701 SIR_MAC_RATESET_EID_MAX"),
11702 pIes->ExtSuppRates.num_rates);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053011703 pIes->ExtSuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011704 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053011705 vos_mem_copy(pParam->extendedRateSet.rate,
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011706 pIes->ExtSuppRates.rates,
11707 sizeof(*pIes->ExtSuppRates.rates) * pIes->ExtSuppRates.num_rates);
11708 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011709 if( pIes->SSID.present )
11710 {
11711 pParam->ssId.length = pIes->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +053011712 vos_mem_copy(pParam->ssId.ssId, pIes->SSID.ssid,
11713 pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011714 }
11715 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070011716 }
11717 else
11718 {
11719 pParam->ssId.length = 0;
11720 pParam->operationalRateSet.numRates = 0;
11721 }
11722 }
11723}
11724
Jeff Johnson295189b2012-06-20 16:38:30 -070011725static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
11726{
11727 tANI_U8 MaxRate = 0;
11728 tANI_U32 i;
11729 tANI_U8 *pRate;
11730
11731 pRate = pSirRateSet->rate;
11732 for ( i = 0; i < pSirRateSet->numRates; i++ )
11733 {
11734 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
11735 }
11736
11737 // Save the max rate in the connected state information...
11738
11739 // modify LastRates variable as well
11740
11741 return;
11742}
11743
Jeff Johnson295189b2012-06-20 16:38:30 -070011744eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
11745 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
11746{
11747 eHalStatus status = eHAL_STATUS_SUCCESS;
11748 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070011749 // Set the roaming substate to 'Start BSS attempt'...
11750 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011751#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11752 //Need to figure out whether we need to log WDS???
11753 if( CSR_IS_IBSS( pProfile ) )
11754 {
11755 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011756 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11757 if(pIbssLog)
11758 {
11759 if(pBssDesc)
11760 {
11761 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
Kiet Lam64c1b492013-07-12 13:56:44 +053011762 vos_mem_copy(pIbssLog->bssid, pBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070011763 }
11764 else
11765 {
11766 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
11767 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011768 vos_mem_copy(pIbssLog->ssid, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011769 if(pProfile->ChannelInfo.numOfChannels == 0)
11770 {
11771 pIbssLog->channelSetting = AUTO_PICK;
11772 }
11773 else
11774 {
11775 pIbssLog->channelSetting = SPECIFIED;
11776 }
11777 pIbssLog->operatingChannel = pParam->operationChn;
11778 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11779 }
11780 }
11781#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
11782 //Put RSN information in for Starting BSS
11783 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
11784 pParam->pRSNIE = pProfile->pRSNReqIE;
11785
Jeff Johnson295189b2012-06-20 16:38:30 -070011786 pParam->privacy = pProfile->privacy;
11787 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
11788 pParam->authType = pProfile->csr80211AuthType;
11789 pParam->beaconInterval = pProfile->beaconInterval;
11790 pParam->dtimPeriod = pProfile->dtimPeriod;
11791 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
11792 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
11793 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
11794 {
11795 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
11796 {
11797 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
11798 }
11799 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011800 pParam->protEnabled = pProfile->protEnabled;
11801 pParam->obssProtEnabled = pProfile->obssProtEnabled;
11802 pParam->ht_protection = pProfile->cfg_protection;
11803 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080011804
Jeff Johnson295189b2012-06-20 16:38:30 -070011805 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
11806 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070011807 pParam->bssPersona = pProfile->csrPersona;
Chet Lanctot8cecea22014-02-11 19:09:36 -080011808
11809#ifdef WLAN_FEATURE_11W
11810 pParam->mfpCapable = (0 != pProfile->MFPCapable);
11811 pParam->mfpRequired = (0 != pProfile->MFPRequired);
11812#endif
11813
Jeff Johnson295189b2012-06-20 16:38:30 -070011814 // When starting an IBSS, start on the channel from the Profile.
11815 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070011816 return (status);
11817}
11818
Jeff Johnson295189b2012-06-20 16:38:30 -070011819static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070011820 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011821{
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011822 tANI_U8 Channel;
Jeff Johnsone7245742012-09-05 17:12:55 -070011823 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011824 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011825
11826 if(!pSession)
11827 {
11828 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11829 return;
11830 }
11831
Jeff Johnson295189b2012-06-20 16:38:30 -070011832 if( pBssDesc )
11833 {
11834 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
11835 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
11836 //The following code has to be do after that.
11837 //For WDS station, use selfMac as the self BSSID
11838 if( CSR_IS_WDS_STA( pProfile ) )
11839 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011840 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
11841 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011842 }
11843 }
11844 else
11845 {
11846 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070011847 //Use the first SSID
11848 if(pProfile->SSIDs.numOfSSIDs)
11849 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011850 vos_mem_copy(&pSession->bssParams.ssId, pProfile->SSIDs.SSIDList,
11851 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011852 }
11853 //For WDS station, use selfMac as the self BSSID
11854 if( CSR_IS_WDS_STA( pProfile ) )
11855 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011856 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
11857 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011858 }
11859 //Use the first BSSID
11860 else if( pProfile->BSSIDs.numOfBSSIDs )
11861 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011862 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid,
11863 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011864 }
11865 else
11866 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011867 vos_mem_set(&pSession->bssParams.bssid, sizeof(tCsrBssid), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011868 }
11869 }
11870 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070011871 //Set operating channel in pProfile which will be used
11872 //in csrRoamSetBssConfigCfg() to determine channel bonding
11873 //mode and will be configured in CFG later
11874 pProfile->operationChannel = Channel;
11875
11876 if(Channel == 0)
11877 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053011878 smsLog(pMac, LOGE, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070011879 }
11880 else
11881 {
11882
11883 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011884 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS( pProfile ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011885 {
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011886 if(CSR_IS_CHANNEL_24GHZ(Channel) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011887 {
Sandeep Puligillae3f239f2014-04-17 02:11:46 +053011888 /* TODO- SAP: HT40 Support in SAP 2.4Ghz mode is not enabled.
11889 so channel bonding in 2.4Ghz is configured as 20MHZ
11890 irrespective of the 'channelBondingMode24GHz' Parameter */
11891 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -070011892 }
11893 else
11894 {
11895 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
11896 }
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011897 smsLog(pMac, LOG1, "## cbMode %d", cbMode);
Jeff Johnsone7245742012-09-05 17:12:55 -070011898 pBssConfig->cbMode = cbMode;
11899 pSession->bssParams.cbMode = cbMode;
11900 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011901 }
11902}
11903
Jeff Johnson295189b2012-06-20 16:38:30 -070011904static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
11905 tANI_BOOLEAN *pfSameIbss )
11906{
11907 eHalStatus status = eHAL_STATUS_SUCCESS;
11908 tANI_BOOLEAN fSameIbss = FALSE;
11909
11910 if ( csrIsConnStateIbss( pMac, sessionId ) )
11911 {
11912 // Check if any profile parameter has changed ? If any profile parameter
11913 // has changed then stop old BSS and start a new one with new parameters
11914 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
11915 {
11916 fSameIbss = TRUE;
11917 }
11918 else
11919 {
11920 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
11921 }
11922 }
11923 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
11924 {
11925 // Disassociate from the connected Infrastructure network...
11926 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
11927 }
11928 else
11929 {
11930 tBssConfigParam *pBssConfig;
11931
Kiet Lam64c1b492013-07-12 13:56:44 +053011932 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
11933 if ( NULL == pBssConfig )
11934 status = eHAL_STATUS_FAILURE;
11935 else
11936 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011937 if(HAL_STATUS_SUCCESS(status))
11938 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011939 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011940 // there is no Bss description before we start an IBSS so we need to adopt
11941 // all Bss configuration parameters from the Profile.
11942 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
11943 if(HAL_STATUS_SUCCESS(status))
11944 {
11945 //save dotMode
11946 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
11947 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070011948 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053011949 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
11950 NULL, pBssConfig,
11951 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011952 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011953
11954 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -070011955 }//Allocate memory
11956 }
11957
11958 if(pfSameIbss)
11959 {
11960 *pfSameIbss = fSameIbss;
11961 }
11962 return( status );
11963}
11964
Jeff Johnson295189b2012-06-20 16:38:30 -070011965static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
11966 tSirSmeNewBssInfo *pNewBss )
11967{
11968 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011969
11970 if(!pSession)
11971 {
11972 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11973 return;
11974 }
11975
Jeff Johnson295189b2012-06-20 16:38:30 -070011976 if( pNewBss )
11977 {
11978 // Set the operating channel.
11979 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
11980 // move the BSSId from the BSS description into the connected state information.
Kiet Lam64c1b492013-07-12 13:56:44 +053011981 vos_mem_copy(&pSession->connectedProfile.bssid, &(pNewBss->bssId),
11982 sizeof( tCsrBssid ));
Jeff Johnson295189b2012-06-20 16:38:30 -070011983 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011984 return;
11985}
11986
Jeff Johnson295189b2012-06-20 16:38:30 -070011987#ifdef FEATURE_WLAN_WAPI
11988eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
11989 tANI_U32 numItems )
11990{
11991 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11992 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011993 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11994 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011995 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011996 return status;
11997 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011998 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011999 pSession = CSR_GET_SESSION( pMac, sessionId );
12000 if(numItems <= CSR_MAX_BKID_ALLOWED)
12001 {
12002 status = eHAL_STATUS_SUCCESS;
12003 //numItems may be 0 to clear the cache
12004 pSession->NumBkidCache = (tANI_U16)numItems;
12005 if(numItems && pBKIDCache)
12006 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012007 vos_mem_copy(pSession->BkidCacheInfo, pBKIDCache,
12008 sizeof(tBkidCacheInfo) * numItems);
12009 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012010 }
12011 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012012 return (status);
12013}
Jeff Johnson295189b2012-06-20 16:38:30 -070012014eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
12015 tBkidCacheInfo *pBkidCache)
12016{
12017 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12018 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070012019 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
12020 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012021 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012022 return status;
12023 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012024 pSession = CSR_GET_SESSION( pMac, sessionId );
12025 if(pNum && pBkidCache)
12026 {
12027 if(pSession->NumBkidCache == 0)
12028 {
12029 *pNum = 0;
12030 status = eHAL_STATUS_SUCCESS;
12031 }
12032 else if(*pNum >= pSession->NumBkidCache)
12033 {
12034 if(pSession->NumBkidCache > CSR_MAX_PMKID_ALLOWED)
12035 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012036 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 -070012037 pSession->NumBkidCache);
12038 pSession->NumBkidCache = CSR_MAX_PMKID_ALLOWED;
12039 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012040 vos_mem_copy(pBkidCache, pSession->BkidCacheInfo,
12041 sizeof(tBkidCacheInfo) * pSession->NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012042 *pNum = pSession->NumBkidCache;
12043 status = eHAL_STATUS_SUCCESS;
12044 }
12045 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012046 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070012047}
Jeff Johnson295189b2012-06-20 16:38:30 -070012048tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
12049{
12050 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012051}
12052#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012053eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
12054 tPmkidCacheInfo *pPMKIDCache, tANI_U32 numItems )
12055{
12056 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12057 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012058
12059 if(!pSession)
12060 {
12061 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12062 return eHAL_STATUS_FAILURE;
12063 }
12064
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012065 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070012066 if(numItems <= CSR_MAX_PMKID_ALLOWED)
12067 {
12068#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12069 {
12070 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053012071 vos_mem_set(&secEvent,
12072 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012073 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
12074 secEvent.encryptionModeMulticast =
12075 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
12076 secEvent.encryptionModeUnicast =
12077 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053012078 vos_mem_copy(secEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070012079 secEvent.authMode =
12080 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
12081 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
12082 }
12083#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070012084 status = eHAL_STATUS_SUCCESS;
12085 //numItems may be 0 to clear the cache
12086 pSession->NumPmkidCache = (tANI_U16)numItems;
12087 if(numItems && pPMKIDCache)
12088 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012089 vos_mem_copy(pSession->PmkidCacheInfo, pPMKIDCache,
12090 sizeof(tPmkidCacheInfo) * numItems);
12091 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012092 }
12093 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012094 return (status);
12095}
12096
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012097eHalStatus csrRoamDelPMKIDfromCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
12098 tANI_U8 *pBSSId )
12099{
12100 eHalStatus status = eHAL_STATUS_FAILURE;
12101 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12102 tANI_BOOLEAN fMatchFound = FALSE;
12103 tANI_U32 Index;
12104 if(!pSession)
12105 {
12106 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12107 return eHAL_STATUS_FAILURE;
12108 }
12109 do
12110 {
12111 for( Index=0; Index < pSession->NumPmkidCache; Index++ )
12112 {
Arif Hussaina7c8e412013-11-20 11:06:42 -080012113 smsLog(pMac, LOGW, "Delete PMKID for "
12114 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pBSSId));
Kiet Lamf2f201e2013-11-16 21:24:16 +053012115 if( vos_mem_compare( pBSSId, pSession->PmkidCacheInfo[Index].BSSID, sizeof(tCsrBssid) ) )
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012116 {
12117 fMatchFound = TRUE;
12118 break;
12119 }
12120 }
12121 if( !fMatchFound ) break;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053012122 vos_mem_set(pSession->PmkidCacheInfo[Index].BSSID, sizeof(tCsrBssid), 0);
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012123 status = eHAL_STATUS_SUCCESS;
12124 }
12125 while( 0 );
12126 smsLog(pMac, LOGW, "csrDelPMKID called return match = %d Status = %d",
12127 fMatchFound, status);
12128 return status;
12129}
Jeff Johnson295189b2012-06-20 16:38:30 -070012130tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
12131{
12132 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
12133}
12134
Jeff Johnson295189b2012-06-20 16:38:30 -070012135eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
12136{
12137 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12138 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012139
12140 if(!pSession)
12141 {
12142 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12143 return eHAL_STATUS_FAILURE;
12144 }
12145
Jeff Johnson295189b2012-06-20 16:38:30 -070012146 if(pNum && pPmkidCache)
12147 {
12148 if(pSession->NumPmkidCache == 0)
12149 {
12150 *pNum = 0;
12151 status = eHAL_STATUS_SUCCESS;
12152 }
12153 else if(*pNum >= pSession->NumPmkidCache)
12154 {
12155 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
12156 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012157 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 -070012158 pSession->NumPmkidCache);
12159 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
12160 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012161 vos_mem_copy(pPmkidCache, pSession->PmkidCacheInfo,
12162 sizeof(tPmkidCacheInfo) * pSession->NumPmkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012163 *pNum = pSession->NumPmkidCache;
12164 status = eHAL_STATUS_SUCCESS;
12165 }
12166 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012167 return (status);
12168}
12169
Jeff Johnson295189b2012-06-20 16:38:30 -070012170eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12171{
12172 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12173 tANI_U32 len;
12174 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012175
12176 if(!pSession)
12177 {
12178 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12179 return eHAL_STATUS_FAILURE;
12180 }
12181
Jeff Johnson295189b2012-06-20 16:38:30 -070012182 if(pLen)
12183 {
12184 len = *pLen;
12185 *pLen = pSession->nWpaRsnReqIeLength;
12186 if(pBuf)
12187 {
12188 if(len >= pSession->nWpaRsnReqIeLength)
12189 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012190 vos_mem_copy(pBuf, pSession->pWpaRsnReqIE,
12191 pSession->nWpaRsnReqIeLength);
12192 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012193 }
12194 }
12195 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012196 return (status);
12197}
12198
Jeff Johnson295189b2012-06-20 16:38:30 -070012199eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12200{
12201 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12202 tANI_U32 len;
12203 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012204
12205 if(!pSession)
12206 {
12207 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12208 return eHAL_STATUS_FAILURE;
12209 }
12210
Jeff Johnson295189b2012-06-20 16:38:30 -070012211 if(pLen)
12212 {
12213 len = *pLen;
12214 *pLen = pSession->nWpaRsnRspIeLength;
12215 if(pBuf)
12216 {
12217 if(len >= pSession->nWpaRsnRspIeLength)
12218 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012219 vos_mem_copy(pBuf, pSession->pWpaRsnRspIE,
12220 pSession->nWpaRsnRspIeLength);
12221 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012222 }
12223 }
12224 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012225 return (status);
12226}
Jeff Johnson295189b2012-06-20 16:38:30 -070012227#ifdef FEATURE_WLAN_WAPI
12228eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12229{
12230 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12231 tANI_U32 len;
12232 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012233
12234 if(!pSession)
12235 {
12236 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12237 return eHAL_STATUS_FAILURE;
12238 }
12239
Jeff Johnson295189b2012-06-20 16:38:30 -070012240 if(pLen)
12241 {
12242 len = *pLen;
12243 *pLen = pSession->nWapiReqIeLength;
12244 if(pBuf)
12245 {
12246 if(len >= pSession->nWapiReqIeLength)
12247 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012248 vos_mem_copy(pBuf, pSession->pWapiReqIE,
12249 pSession->nWapiReqIeLength);
12250 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012251 }
12252 }
12253 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012254 return (status);
12255}
Jeff Johnson295189b2012-06-20 16:38:30 -070012256eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12257{
12258 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12259 tANI_U32 len;
12260 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012261
12262 if(!pSession)
12263 {
12264 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12265 return eHAL_STATUS_FAILURE;
12266 }
12267
Jeff Johnson295189b2012-06-20 16:38:30 -070012268 if(pLen)
12269 {
12270 len = *pLen;
12271 *pLen = pSession->nWapiRspIeLength;
12272 if(pBuf)
12273 {
12274 if(len >= pSession->nWapiRspIeLength)
12275 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012276 vos_mem_copy(pBuf, pSession->pWapiRspIE,
12277 pSession->nWapiRspIeLength);
12278 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012279 }
12280 }
12281 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012282 return (status);
12283}
12284#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012285eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
12286{
12287 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
12288 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012289
12290 if(!pSession)
12291 {
12292 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12293 return (retStatus);
12294 }
12295
Jeff Johnson295189b2012-06-20 16:38:30 -070012296 if(CSR_IS_ROAMING(pSession))
12297 {
12298 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
12299 pSession->fRoaming = eANI_BOOLEAN_FALSE;
12300 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012301 return (retStatus);
12302}
12303
Jeff Johnson295189b2012-06-20 16:38:30 -070012304//This function remove the connected BSS from te cached scan result
12305eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
12306 tCsrRoamConnectedProfile *pConnProfile)
12307{
12308 eHalStatus status = eHAL_STATUS_FAILURE;
12309 tCsrScanResultFilter *pScanFilter = NULL;
12310 tListElem *pEntry;
12311 tCsrScanResult *pResult;
12312 tDot11fBeaconIEs *pIes;
12313 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070012314 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
12315 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
12316 {
12317 do
12318 {
12319 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
Kiet Lam64c1b492013-07-12 13:56:44 +053012320 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
12321 if ( NULL == pScanFilter )
12322 status = eHAL_STATUS_FAILURE;
12323 else
12324 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012325 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012326 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
12327 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
12328 if ( NULL == pScanFilter->BSSIDs.bssid )
12329 status = eHAL_STATUS_FAILURE;
12330 else
12331 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012332 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012333 vos_mem_copy(pScanFilter->BSSIDs.bssid, &pConnProfile->bssid,
12334 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012335 pScanFilter->BSSIDs.numOfBSSIDs = 1;
12336 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
12337 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012338 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
12339 if ( NULL == pScanFilter->SSIDs.SSIDList )
12340 status = eHAL_STATUS_FAILURE;
12341 else
12342 status = eHAL_STATUS_SUCCESS;
12343 if (!HAL_STATUS_SUCCESS(status)) break;
12344 vos_mem_copy(&pScanFilter->SSIDs.SSIDList[0].SSID,
12345 &pConnProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012346 }
12347 pScanFilter->authType.numEntries = 1;
12348 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
12349 pScanFilter->BSSType = pConnProfile->BSSType;
12350 pScanFilter->EncryptionType.numEntries = 1;
12351 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
12352 pScanFilter->mcEncryptionType.numEntries = 1;
12353 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
12354 //We ignore the channel for now, BSSID should be enough
12355 pScanFilter->ChannelInfo.numOfChannels = 0;
12356 //Also ignore the following fields
12357 pScanFilter->uapsd_mask = 0;
12358 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070012359 pScanFilter->bOSENAssociation = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012360 pScanFilter->countryCode[0] = 0;
12361 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012362 csrLLLock(&pMac->scan.scanResultList);
12363 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
12364 while( pEntry )
12365 {
12366 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
12367 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
12368 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
12369 pScanFilter, NULL, NULL, NULL, &pIes);
12370 //Release the IEs allocated by csrMatchBSS is needed
12371 if( !pResult->Result.pvIes )
12372 {
12373 //need to free the IEs since it is allocated by csrMatchBSS
Kiet Lam64c1b492013-07-12 13:56:44 +053012374 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012375 }
12376 if(fMatch)
12377 {
12378 //We found the one
12379 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
12380 {
12381 //Free the memory
12382 csrFreeScanResultEntry( pMac, pResult );
12383 }
12384 break;
12385 }
12386 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
12387 }//while
12388 csrLLUnlock(&pMac->scan.scanResultList);
12389 }while(0);
12390 if(pScanFilter)
12391 {
12392 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +053012393 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012394 }
12395 }
12396 return (status);
12397}
12398
Jeff Johnson295189b2012-06-20 16:38:30 -070012399//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070012400eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
12401{
12402 eHalStatus status = eHAL_STATUS_SUCCESS;
12403 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012404 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
12405 {
12406 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
12407 {
12408 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
12409 {
12410 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012411 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012412 status = eHAL_STATUS_CSR_WRONG_STATE;
12413 break;
12414 }
12415 if( csrIsConnStateInfra( pMac, sessionId ) )
12416 {
12417 if( chnId &&
12418 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
12419 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012420 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070012421 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
12422 status = eHAL_STATUS_CSR_WRONG_STATE;
12423 break;
12424 }
12425 }
12426 }
12427 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012428 return ( status );
12429}
12430
Jeff Johnson295189b2012-06-20 16:38:30 -070012431static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
12432{
12433 eHalStatus status = eHAL_STATUS_SUCCESS;
12434 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12435 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012436
12437 if(!pSession)
12438 {
12439 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12440 return eHAL_STATUS_FAILURE;
12441 }
12442
Jeff Johnson295189b2012-06-20 16:38:30 -070012443 if ( csrIsConnStateIbss( pMac, sessionId ) )
12444 {
12445 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
12446 }
12447 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
12448 {
12449 // Disassociate from the connected Infrastructure network...
12450 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
12451 }
12452 else
12453 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012454 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
12455 //Otherwise we need to add code to handle the
12456 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
12457 //send stop_bss to PE, before we can continue.
12458 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012459 vos_mem_set(&bssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012460 /* Assume HDD provide bssid in profile */
Kiet Lam64c1b492013-07-12 13:56:44 +053012461 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0],
12462 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012463 // there is no Bss description before we start an WDS so we need
12464 // to adopt all Bss configuration parameters from the Profile.
12465 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
12466 if(HAL_STATUS_SUCCESS(status))
12467 {
12468 //Save profile for late use
12469 csrFreeRoamProfile( pMac, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +053012470 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
12471 if (pSession->pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -070012472 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012473 vos_mem_set(pSession->pCurRoamProfile,
12474 sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012475 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
12476 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012477 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070012478 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012479 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
12480 NULL, &bssConfig,
12481 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012482 }
12483 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012484
Jeff Johnson295189b2012-06-20 16:38:30 -070012485 return( status );
12486}
12487
Jeff Johnson295189b2012-06-20 16:38:30 -070012488////////////////////Mail box
12489
Jeff Johnson295189b2012-06-20 16:38:30 -070012490//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
12491//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012492static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
12493 tSirBssDescription *pBssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -070012494 tANI_U8 *pBuf, tANI_U8 uapsdMask)
12495{
12496 tCsrChannelSet channelGroup;
12497 tSirMacCapabilityInfo *pAP_capabilityInfo;
12498 tAniBool fTmp;
12499 tANI_BOOLEAN found = FALSE;
12500 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012501 tANI_S8 pwrLimit = 0;
12502 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070012503 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
12504 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
12505 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
12506 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070012507 // 802.11h
12508 //We can do this because it is in HOST CPU order for now.
12509 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080012510 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
12511 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
12512 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012513 fTmp = (tAniBool)pal_cpu_to_be32(1);
12514 }
12515 else
12516 fTmp = (tAniBool)0;
12517
12518 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
Kiet Lam64c1b492013-07-12 13:56:44 +053012519 vos_mem_copy(pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool));
Jeff Johnson295189b2012-06-20 16:38:30 -070012520 pBuf += sizeof(tAniBool);
12521 *pBuf++ = MIN_STA_PWR_CAP_DBM; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012522 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070012523 // This is required for 11k test VoWiFi Ent: Test 2.
12524 // We need the power capabilities for Assoc Req.
12525 // This macro is provided by the halPhyCfg.h. We pick our
12526 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080012527 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
12528 if (0 != pwrLimit)
12529 {
12530 *pBuf++ = pwrLimit;
12531 }
12532 else
12533 {
12534 *pBuf++ = MAX_STA_PWR_CAP_DBM;
12535 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012536 size = sizeof(pMac->roam.validChannelList);
12537 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
12538 {
12539 *pBuf++ = (tANI_U8)size; //tSirSupChnl->numChnl
12540 for ( i = 0; i < size; i++)
12541 {
12542 *pBuf++ = pMac->roam.validChannelList[ i ]; //tSirSupChnl->channelList[ i ]
12543
12544 }
12545 }
12546 else
12547 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012548 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012549 *pBuf++ = 0; //tSirSupChnl->numChnl
12550 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012551 //Check whether it is ok to enter UAPSD
12552#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12553 if( btcIsReadyForUapsd(pMac) )
12554#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12555 {
12556 *pBuf++ = uapsdMask;
12557 }
12558#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12559 else
12560 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012561 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070012562 *pBuf++ = 0;
12563 }
12564#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12565
Jeff Johnson295189b2012-06-20 16:38:30 -070012566 // move the entire BssDescription into the join request.
Kiet Lam64c1b492013-07-12 13:56:44 +053012567 vos_mem_copy(pBuf, pBssDescription,
12568 pBssDescription->length + sizeof( pBssDescription->length ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012569 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
12570}
12571
Jeff Johnson295189b2012-06-20 16:38:30 -070012572/*
12573 * The communication between HDD and LIM is thru mailbox (MB).
12574 * Both sides will access the data structure "tSirSmeJoinReq".
12575 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
12576 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
12577 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
12578 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
12579 */
12580eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012581 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012582{
12583 eHalStatus status = eHAL_STATUS_SUCCESS;
12584 tSirSmeJoinReq *pMsg;
12585 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012586 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070012587 tANI_U16 msgLen, wTmp, ieLen;
12588 tSirMacRateSet OpRateSet;
12589 tSirMacRateSet ExRateSet;
12590 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12591 tANI_U32 dwTmp;
12592 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012593 tANI_U32 ucDot11Mode = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012594
12595 if(!pSession)
12596 {
12597 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12598 return eHAL_STATUS_FAILURE;
12599 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012600 /* To satisfy klockworks */
12601 if (NULL == pBssDescription)
12602 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012603 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012604 return eHAL_STATUS_FAILURE;
12605 }
12606
Jeff Johnson295189b2012-06-20 16:38:30 -070012607 do {
12608 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
12609 pSession->joinFailStatusCode.reasonCode = 0;
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -070012610 memcpy (&pSession->joinFailStatusCode.bssId, &pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012611 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
12612 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
12613 // IE fields, but the length field in the bssDescription needs to be interpreted to
12614 // determine length of the IE fields.
12615 //
12616 // So, take the size of the JoinReq, subtract the size of the bssDescription and
12617 // add in the length from the bssDescription (then add the size of the 'length' field
12618 // itself because that is NOT included in the length field).
12619 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
12620 pBssDescription->length + sizeof( pBssDescription->length ) +
12621 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 +053012622 pMsg = vos_mem_malloc(msgLen);
12623 if (NULL == pMsg)
12624 status = eHAL_STATUS_FAILURE;
12625 else
12626 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012627 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012628 vos_mem_set(pMsg, msgLen , 0);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012629 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012630 pMsg->length = pal_cpu_to_be16(msgLen);
12631 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012632 // sessionId
12633 *pBuf = (tANI_U8)sessionId;
12634 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012635 // transactionId
12636 *pBuf = 0;
12637 *( pBuf + 1 ) = 0;
12638 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012639 // ssId
12640 if( pIes->SSID.present && pIes->SSID.num_ssid )
12641 {
12642 // ssId len
12643 *pBuf = pIes->SSID.num_ssid;
12644 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053012645 vos_mem_copy(pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -070012646 pBuf += pIes->SSID.num_ssid;
12647 }
12648 else
12649 {
12650 *pBuf = 0;
12651 pBuf++;
12652 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012653 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053012654 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
12655 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012656 pBuf += sizeof(tSirMacAddr);
12657 // bsstype
12658 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
12659 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
Kiet Lam64c1b492013-07-12 13:56:44 +053012660 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070012661 pBuf += sizeof(tSirBssType);
12662 // dot11mode
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012663 ucDot11Mode = csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
12664 if (pBssDescription->channelId <= 14 &&
12665 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
12666 WNI_CFG_DOT11_MODE_11AC == ucDot11Mode)
12667 {
12668 //Need to disable VHT operation in 2.4 GHz band
12669 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
12670 }
12671 *pBuf = (tANI_U8)ucDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -070012672 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012673 //Persona
12674 *pBuf = (tANI_U8)pProfile->csrPersona;
12675 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070012676 //CBMode
12677 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
12678 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012679
12680 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -070012681 FL("CSR PERSONA=%d CSR CbMode %d"), pProfile->csrPersona, pSession->bssParams.cbMode);
12682
Jeff Johnson295189b2012-06-20 16:38:30 -070012683 // uapsdPerAcBitmask
12684 *pBuf = pProfile->uapsd_mask;
12685 pBuf++;
12686
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012687
12688
Jeff Johnson295189b2012-06-20 16:38:30 -070012689 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012690 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012691 {
12692 // OperationalRateSet
12693 if (OpRateSet.numRates) {
12694 *pBuf++ = OpRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012695 vos_mem_copy(pBuf, OpRateSet.rate, OpRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012696 pBuf += OpRateSet.numRates;
12697 } else *pBuf++ = 0;
12698 // ExtendedRateSet
12699 if (ExRateSet.numRates) {
12700 *pBuf++ = ExRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012701 vos_mem_copy(pBuf, ExRateSet.rate, ExRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012702 pBuf += ExRateSet.numRates;
12703 } else *pBuf++ = 0;
12704 }
12705 else
12706 {
12707 *pBuf++ = 0;
12708 *pBuf++ = 0;
12709 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012710 // rsnIE
12711 if ( csrIsProfileWpa( pProfile ) )
12712 {
12713 // Insert the Wpa IE into the join request
12714 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
12715 (tCsrWpaIe *)( wpaRsnIE ) );
12716 }
12717 else if( csrIsProfileRSN( pProfile ) )
12718 {
12719 // Insert the RSN IE into the join request
12720 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12721 (tCsrRSNIe *)( wpaRsnIE ) );
12722 }
12723#ifdef FEATURE_WLAN_WAPI
12724 else if( csrIsProfileWapi( pProfile ) )
12725 {
12726 // Insert the WAPI IE into the join request
12727 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12728 (tCsrWapiIe *)( wpaRsnIE ) );
12729 }
12730#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012731 else
12732 {
12733 ieLen = 0;
12734 }
12735 //remember the IE for future use
12736 if( ieLen )
12737 {
12738 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
12739 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012740 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 -070012741 ieLen = DOT11F_IE_RSN_MAX_LEN;
12742 }
12743#ifdef FEATURE_WLAN_WAPI
12744 if( csrIsProfileWapi( pProfile ) )
12745 {
12746 //Check whether we need to allocate more memory
12747 if(ieLen > pSession->nWapiReqIeLength)
12748 {
12749 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
12750 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012751 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012752 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012753 pSession->pWapiReqIE = vos_mem_malloc(ieLen);
12754 if (NULL == pSession->pWapiReqIE)
12755 status = eHAL_STATUS_FAILURE;
12756 else
12757 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012758 if(!HAL_STATUS_SUCCESS(status)) break;
12759 }
12760 pSession->nWapiReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012761 vos_mem_copy(pSession->pWapiReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012762 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012763 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012764 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012765 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012766 pBuf += ieLen;
12767 }
12768 else//should be WPA/WPA2 otherwise
12769#endif /* FEATURE_WLAN_WAPI */
12770 {
12771 //Check whether we need to allocate more memory
12772 if(ieLen > pSession->nWpaRsnReqIeLength)
12773 {
12774 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
12775 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012776 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012777 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012778 pSession->pWpaRsnReqIE = vos_mem_malloc(ieLen);
12779 if (NULL == pSession->pWpaRsnReqIE)
12780 status = eHAL_STATUS_FAILURE;
12781 else
12782 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012783 if(!HAL_STATUS_SUCCESS(status)) break;
12784 }
12785 pSession->nWpaRsnReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012786 vos_mem_copy(pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012787 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012788 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012789 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012790 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012791 pBuf += ieLen;
12792 }
12793 }
12794 else
12795 {
12796 //free whatever old info
12797 pSession->nWpaRsnReqIeLength = 0;
12798 if(pSession->pWpaRsnReqIE)
12799 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012800 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012801 pSession->pWpaRsnReqIE = NULL;
12802 }
12803#ifdef FEATURE_WLAN_WAPI
12804 pSession->nWapiReqIeLength = 0;
12805 if(pSession->pWapiReqIE)
12806 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012807 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012808 pSession->pWapiReqIE = NULL;
12809 }
12810#endif /* FEATURE_WLAN_WAPI */
12811 //length is two bytes
12812 *pBuf = 0;
12813 *(pBuf + 1) = 0;
12814 pBuf += 2;
12815 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012816#ifdef FEATURE_WLAN_ESE
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012817 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012818 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012819 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070012820 //length is two bytes
12821 *pBuf = 0;
12822 *(pBuf + 1) = 0;
12823 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012824 }
12825 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012826 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012827 // cckmIE
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012828 if( csrIsProfileESE( pProfile ) )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012829 {
12830 // Insert the CCKM IE into the join request
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012831#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070012832 ieLen = pSession->suppCckmIeInfo.cckmIeLen;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080012833 vos_mem_copy((void *) (wpaRsnIE),
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070012834 pSession->suppCckmIeInfo.cckmIe, ieLen);
12835#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012836 ieLen = csrConstructEseCckmIe( pMac,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012837 pSession,
12838 pProfile,
12839 pBssDescription,
12840 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070012841 pSession->nWpaRsnReqIeLength,
12842 (void *)( wpaRsnIE ) );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012843#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012844 }
12845 else
12846 {
12847 ieLen = 0;
12848 }
12849 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
12850 if( ieLen )
12851 {
12852 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
12853 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012854 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012855 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012856 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012857 pBuf += ieLen;
12858 }
12859 else
12860 {
12861 //Indicate you have no CCKM IE
12862 //length is two bytes
12863 *pBuf = 0;
12864 *(pBuf + 1) = 0;
12865 pBuf += 2;
12866 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012867 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012868#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -070012869 // addIEScan
Agarwal Ashish4f616132013-12-30 23:32:50 +053012870 if (pProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070012871 {
12872 ieLen = pProfile->nAddIEScanLength;
Agarwal Ashish4f616132013-12-30 23:32:50 +053012873 memset(pSession->addIEScan, 0 , pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070012874 pSession->nAddIEScanLength = ieLen;
Agarwal Ashish4f616132013-12-30 23:32:50 +053012875 vos_mem_copy(pSession->addIEScan, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012876 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012877 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012878 pBuf += sizeof(tANI_U16);
Agarwal Ashish4f616132013-12-30 23:32:50 +053012879 vos_mem_copy(pBuf, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012880 pBuf += ieLen;
12881 }
12882 else
12883 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053012884 memset(pSession->addIEScan, 0, pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070012885 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012886 *pBuf = 0;
12887 *(pBuf + 1) = 0;
12888 pBuf += 2;
12889 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012890 // addIEAssoc
12891 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
12892 {
12893 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070012894 if(ieLen > pSession->nAddIEAssocLength)
12895 {
12896 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
Kiet Lam64c1b492013-07-12 13:56:44 +053012897 {
12898 vos_mem_free(pSession->pAddIEAssoc);
12899 }
12900 pSession->pAddIEAssoc = vos_mem_malloc(ieLen);
12901 if (NULL == pSession->pAddIEAssoc)
12902 status = eHAL_STATUS_FAILURE;
12903 else
12904 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012905 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012906 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012907 pSession->nAddIEAssocLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012908 vos_mem_copy(pSession->pAddIEAssoc, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012909 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012910 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012911 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012912 vos_mem_copy(pBuf, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012913 pBuf += ieLen;
12914 }
12915 else
12916 {
12917 pSession->nAddIEAssocLength = 0;
12918 if(pSession->pAddIEAssoc)
12919 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012920 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070012921 pSession->pAddIEAssoc = NULL;
12922 }
12923 *pBuf = 0;
12924 *(pBuf + 1) = 0;
12925 pBuf += 2;
12926 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012927
12928 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012929 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012930 //Unmask any AC in reassoc that is ACM-set
12931 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
12932 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012933 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012934 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
12935 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012936#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012937 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012938#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012939 }
12940 else
12941 {
12942 uapsd_mask = 0;
12943 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012944 }
12945 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012946
Jeff Johnson295189b2012-06-20 16:38:30 -070012947 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012948 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012949 pBuf += sizeof(tANI_U32);
12950
Jeff Johnson295189b2012-06-20 16:38:30 -070012951 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012952 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012953 pBuf += sizeof(tANI_U32);
Chet Lanctot186b5732013-03-18 10:26:30 -070012954#ifdef WLAN_FEATURE_11W
12955 //MgmtEncryption
12956 if (pProfile->MFPEnabled)
12957 {
12958 dwTmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
12959 }
12960 else
12961 {
12962 dwTmp = pal_cpu_to_be32(eSIR_ED_NONE);
12963 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012964 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Chet Lanctot186b5732013-03-18 10:26:30 -070012965 pBuf += sizeof(tANI_U32);
12966#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012967#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012968 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053012969 if (csrIsProfile11r( pProfile )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012970#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala09dd66b2013-04-01 17:13:01 +053012971 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012972 (pIes->ESEVersion.present) && (pMac->roam.configParam.isEseIniFeatureEnabled))
Saurabh Gupta775073c2013-02-14 13:31:36 +053012973#endif
12974 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012975 {
12976 // is11Rconnection;
12977 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012978 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool)) ;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012979 pBuf += sizeof(tAniBool);
12980 }
12981 else
12982 {
12983 // is11Rconnection;
12984 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012985 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012986 pBuf += sizeof(tAniBool);
12987 }
12988#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012989#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012990
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012991 // isESEFeatureIniEnabled
12992 if (TRUE == pMac->roam.configParam.isEseIniFeatureEnabled)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012993 {
12994 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012995 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012996 pBuf += sizeof(tAniBool);
12997 }
12998 else
12999 {
13000 dwTmp = pal_cpu_to_be32(FALSE);
Srinivas Girigowda18112782013-11-27 12:21:19 -080013001 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013002 pBuf += sizeof(tAniBool);
13003 }
13004
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013005 /* A profile can not be both ESE and 11R. But an 802.11R AP
13006 * may be advertising support for ESE as well. So if we are
13007 * associating Open or explicitly ESE then we will get ESE.
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013008 * If we are associating explictly 11R only then we will get
13009 * 11R.
13010 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013011 if ((csrIsProfileESE(pProfile) ||
13012 ((pIes->ESEVersion.present)
Sandeep Puligilla798d6f22014-04-24 23:30:36 +053013013 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013014 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013015 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013016 // isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013017 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013018 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013019 pBuf += sizeof(tAniBool);
13020 }
13021 else
13022 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013023 //isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013024 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013025 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013026 pBuf += sizeof(tAniBool);
13027 }
13028
13029 if (eWNI_SME_JOIN_REQ == messageType)
13030 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013031 tESETspecInfo eseTspec;
13032 // ESE-Tspec IEs in the ASSOC request is presently not supported
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013033 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013034 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13035 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
13036 pBuf += sizeof(tESETspecInfo);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013037 }
13038 else if (eWNI_SME_REASSOC_REQ == messageType)
13039 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013040 if ((csrIsProfileESE(pProfile) ||
13041 ((pIes->ESEVersion.present)
Sandeep Puligilla798d6f22014-04-24 23:30:36 +053013042 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013043 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070013044 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013045 tESETspecInfo eseTspec;
13046 // ESE Tspec information
13047 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13048 eseTspec.numTspecs = sme_QosESERetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &eseTspec.tspec[0]);
13049 *pBuf = eseTspec.numTspecs;
Jeff Johnson295189b2012-06-20 16:38:30 -070013050 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013051 // Copy the TSPEC information only if present
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013052 if (eseTspec.numTspecs) {
13053 vos_mem_copy(pBuf, (void*)&eseTspec.tspec[0],
13054 (eseTspec.numTspecs*sizeof(tTspecInfo)));
Jeff Johnson295189b2012-06-20 16:38:30 -070013055 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013056 pBuf += sizeof(eseTspec.tspec);
Jeff Johnson295189b2012-06-20 16:38:30 -070013057 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013058 else
Jeff Johnson295189b2012-06-20 16:38:30 -070013059 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013060 tESETspecInfo eseTspec;
13061 // ESE-Tspec IEs in the ASSOC request is presently not supported
Jeff Johnson295189b2012-06-20 16:38:30 -070013062 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013063 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13064 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
13065 pBuf += sizeof(tESETspecInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070013066 }
13067 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013068#endif // FEATURE_WLAN_ESE
13069#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070013070 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013071 if (pMac->roam.configParam.isFastTransitionEnabled
13072#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053013073 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013074#endif
13075 )
Jeff Johnson295189b2012-06-20 16:38:30 -070013076 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013077 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013078 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013079 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070013080 }
13081 else
13082 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013083 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013084 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013085 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070013086 }
13087#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070013088#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053013089 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070013090 {
13091 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013092 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013093 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013094 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070013095 }
13096 else
13097 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013098 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013099 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013100 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070013101 }
13102#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013103
13104 // txLdpcIniFeatureEnabled
13105 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
13106 pBuf++;
13107
Kiran4a17ebe2013-01-31 10:43:43 -080013108 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
13109 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
13110 {
13111 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
13112 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
13113 csrApplyPower2Current(pMac);
13114 }
13115
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080013116#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080013117 // txBFIniFeatureEnabled
13118 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
13119 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080013120
13121 // txBFCsnValue
13122 *pBuf = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
13123 pBuf++;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080013124#endif
krunal soni5afa96c2013-09-06 22:19:02 -070013125 *pBuf = (tANI_U8)pMac->roam.configParam.isAmsduSupportInAMPDU;
13126 pBuf++;
13127
Sandeep Puligillaaea98a22013-12-04 13:36:32 +053013128 // WME
13129 if(pMac->roam.roamSession[sessionId].fWMMConnection)
13130 {
13131 //WME enabled
13132 dwTmp = pal_cpu_to_be32(TRUE);
13133 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13134 pBuf += sizeof(tAniBool);
13135 }
13136 else
13137 {
13138 dwTmp = pal_cpu_to_be32(FALSE);
13139 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13140 pBuf += sizeof(tAniBool);
13141 }
13142
13143 // QOS
13144 if(pMac->roam.roamSession[sessionId].fQOSConnection)
13145 {
13146 //QOS enabled
13147 dwTmp = pal_cpu_to_be32(TRUE);
13148 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13149 pBuf += sizeof(tAniBool);
13150 }
13151 else
13152 {
13153 dwTmp = pal_cpu_to_be32(FALSE);
13154 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13155 pBuf += sizeof(tAniBool);
13156 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013157 //BssDesc
13158 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
13159 (tANI_U8)pProfile->uapsd_mask);
krunal soni5afa96c2013-09-06 22:19:02 -070013160
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013161 status = palSendMBMessage(pMac->hHdd, pMsg );
13162 if(!HAL_STATUS_SUCCESS(status))
13163 {
13164 break;
13165 }
13166 else
13167 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013168#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013169 if (eWNI_SME_JOIN_REQ == messageType)
13170 {
13171 //Tush-QoS: notify QoS module that join happening
13172 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
13173 }
13174 else if (eWNI_SME_REASSOC_REQ == messageType)
13175 {
13176 //Tush-QoS: notify QoS module that reassoc happening
13177 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
13178 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013179#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013180 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013181 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013182 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013183}
13184
Jeff Johnson295189b2012-06-20 16:38:30 -070013185//
13186eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13187{
13188 eHalStatus status = eHAL_STATUS_SUCCESS;
13189 tSirSmeDisassocReq *pMsg;
13190 tANI_U8 *pBuf;
13191 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013192 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13193 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13194 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013195 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013196 pMsg = vos_mem_malloc(sizeof(tSirSmeDisassocReq));
13197 if (NULL == pMsg)
13198 status = eHAL_STATUS_FAILURE;
13199 else
13200 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013201 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013202 vos_mem_set(pMsg, sizeof( tSirSmeDisassocReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013203 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
13204 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013205 pBuf = &pMsg->sessionId;
13206 // sessionId
13207 *pBuf++ = (tANI_U8)sessionId;
13208 // transactionId
13209 *pBuf = 0;
13210 *( pBuf + 1 ) = 0;
13211 pBuf += sizeof(tANI_U16);
13212
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053013213 if ( (pSession->pCurRoamProfile != NULL) &&
13214 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
13215 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013216 {
13217 // Set the bssid address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013218 vos_mem_copy((tSirMacAddr *)pBuf, pSession->selfMacAddr,
13219 sizeof( tSirMacAddr ));
13220 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013221 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070013222 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013223 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
13224 //perMacAddr is passed as bssId for softAP
13225 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013226 pBuf = pBuf + sizeof ( tSirMacAddr );
13227 }
13228 else
13229 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013230 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013231 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
13232 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013233 pBuf = pBuf + sizeof ( tSirMacAddr );
Kiet Lam64c1b492013-07-12 13:56:44 +053013234 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ));
13235 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013236 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070013237 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013238 if(!HAL_STATUS_SUCCESS(status))
13239 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013240 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013241 break;
13242 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013243 // reasonCode
13244 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013245 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
13246 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013247 if(!HAL_STATUS_SUCCESS(status))
13248 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013249 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013250 break;
13251 }
13252 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013253 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
13254 Here we should not send the disassoc over the air to the AP */
13255 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
13256#ifdef WLAN_FEATURE_VOWIFI_11R
13257 && csrRoamIs11rAssoc(pMac)
13258#endif
13259 )
13260 {
13261 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
13262 }
13263 pBuf += sizeof(tANI_U8);
13264 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013265 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013266 return( status );
13267}
Jeff Johnson295189b2012-06-20 16:38:30 -070013268eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
13269{
13270 eHalStatus status = eHAL_STATUS_SUCCESS;
13271 tSirSmeTkipCntrMeasReq *pMsg;
13272 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013273 do
13274 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013275 pMsg = vos_mem_malloc(sizeof( tSirSmeTkipCntrMeasReq ));
13276 if ( NULL == pMsg )
13277 status = eHAL_STATUS_FAILURE;
13278 else
13279 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013280 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013281 vos_mem_set(pMsg, sizeof( tSirSmeTkipCntrMeasReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013282 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
13283 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013284 pBuf = &pMsg->sessionId;
13285 // sessionId
13286 *pBuf++ = (tANI_U8)sessionId;
13287 // transactionId
13288 *pBuf = 0;
13289 *( pBuf + 1 ) = 0;
13290 pBuf += sizeof(tANI_U16);
13291 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053013292 vos_mem_copy(pMsg->bssId, bssId, sizeof( tSirMacAddr ));
13293 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013294 pBuf = pBuf + sizeof ( tSirMacAddr );
13295 // bEnable
13296 *pBuf = (tANI_BOOLEAN)bEnable;
13297 if(!HAL_STATUS_SUCCESS(status))
13298 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013299 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013300 break;
13301 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013302 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013303 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013304 return( status );
13305}
Jeff Johnson295189b2012-06-20 16:38:30 -070013306eHalStatus
13307csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
13308 VOS_MODULE_ID modId, tSirMacAddr bssId,
13309 void *pUsrContext, void *pfnSapEventCallback,
13310 tANI_U8 *pAssocStasBuf )
13311{
13312 eHalStatus status = eHAL_STATUS_SUCCESS;
13313 tSirSmeGetAssocSTAsReq *pMsg;
13314 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
13315 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013316 do
13317 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013318 pMsg = vos_mem_malloc(sizeof( tSirSmeGetAssocSTAsReq ));
13319 if ( NULL == pMsg )
13320 status = eHAL_STATUS_FAILURE;
13321 else
13322 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013323 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013324 vos_mem_set(pMsg, sizeof( tSirSmeGetAssocSTAsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013325 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013326 pBuf = (tANI_U8 *)&pMsg->bssId;
13327 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013328 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013329 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013330 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013331 // modId
13332 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013333 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013334 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013335 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080013336 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void *));
13337 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013338 // pfnSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080013339 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void*));
13340 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013341 // pAssocStasBuf
krunal soni4f802b22014-02-11 17:01:13 -080013342 vos_mem_copy(pBuf, pAssocStasBuf, sizeof(void*));
13343 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013344 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013345 status = palSendMBMessage( pMac->hHdd, pMsg );
13346 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013347 return( status );
13348 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013349eHalStatus
13350csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
13351 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
13352 {
13353 eHalStatus status = eHAL_STATUS_SUCCESS;
13354 tSirSmeGetWPSPBCSessionsReq *pMsg;
13355 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
krunal soni4f802b22014-02-11 17:01:13 -080013356
Jeff Johnson295189b2012-06-20 16:38:30 -070013357 do
13358 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013359 pMsg = vos_mem_malloc(sizeof(tSirSmeGetWPSPBCSessionsReq));
13360 if ( NULL == pMsg )
13361 status = eHAL_STATUS_FAILURE;
13362 else
13363 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013364 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013365 vos_mem_set(pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013366 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013367 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
lukez3c809222013-05-03 10:23:02 -070013368 VOS_ASSERT(pBuf);
13369
Jeff Johnson295189b2012-06-20 16:38:30 -070013370 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013371 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080013372 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void*));
13373 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070013374 // pSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080013375 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void *));
13376 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070013377 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013378 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013379 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013380 // MAC Address of STA in WPS session
Kiet Lam64c1b492013-07-12 13:56:44 +053013381 vos_mem_copy((tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
Jeff Johnson295189b2012-06-20 16:38:30 -070013382 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070013383 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013384 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013385 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013386 return( status );
13387}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013388
13389eHalStatus
13390csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
13391{
13392 tpSirChangeBIParams pMsg;
13393 tANI_U16 len = 0;
13394 eHalStatus status = eHAL_STATUS_SUCCESS;
13395 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13396
13397 if(!pSession)
13398 {
13399 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13400 return eHAL_STATUS_FAILURE;
13401 }
13402
13403 //NO need to update the Beacon Params if update beacon parameter flag is not set
13404 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
13405 return eHAL_STATUS_SUCCESS;
13406
13407 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
13408
13409 /* Create the message and send to lim */
13410 len = sizeof(tSirChangeBIParams);
Kiet Lam64c1b492013-07-12 13:56:44 +053013411 pMsg = vos_mem_malloc(len);
13412 if ( NULL == pMsg )
13413 status = eHAL_STATUS_FAILURE;
13414 else
13415 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013416 if(HAL_STATUS_SUCCESS(status))
13417 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013418 vos_mem_set(pMsg, sizeof(tSirChangeBIParams), 0);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013419 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
13420 pMsg->length = len;
13421
13422 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013423 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
13424 sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -080013425 smsLog( pMac, LOG1, FL("CSR Attempting to change BI for Bssid= "MAC_ADDRESS_STR),
13426 MAC_ADDR_ARRAY(pMsg->bssId));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013427 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013428 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013429 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
13430 status = palSendMBMessage(pMac->hHdd, pMsg);
13431 }
13432 return status;
13433}
13434
Jeff Johnson295189b2012-06-20 16:38:30 -070013435eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13436{
13437 eHalStatus status = eHAL_STATUS_SUCCESS;
13438 tSirSmeDeauthReq *pMsg;
13439 tANI_U8 *pBuf;
13440 tANI_U16 wTmp;
13441 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13442 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13443 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013444 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013445 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthReq ));
13446 if ( NULL == pMsg )
13447 status = eHAL_STATUS_FAILURE;
13448 else
13449 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013450 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013451 vos_mem_set(pMsg, sizeof( tSirSmeDeauthReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013452 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
13453 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
13454 //sessionId
13455 pBuf = &pMsg->sessionId;
13456 *pBuf++ = (tANI_U8)sessionId;
13457
13458 //tansactionId
13459 *pBuf = 0;
13460 *(pBuf + 1 ) = 0;
13461 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013462 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070013463 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070013464 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
13465 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013466 vos_mem_copy( (tSirMacAddr *)pBuf, pSession->selfMacAddr,
13467 sizeof( pMsg->peerMacAddr ) );
13468 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013469 pBuf = pBuf + sizeof(tSirMacAddr);
13470 }
13471 else
13472 {
13473 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013474 vos_mem_copy( (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13475 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013476 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013477 }
13478 if(!HAL_STATUS_SUCCESS(status))
13479 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013480 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013481 break;
13482 }
13483 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013484 vos_mem_copy( (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13485 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013486 pBuf = pBuf + sizeof(tSirMacAddr);
13487 if(!HAL_STATUS_SUCCESS(status))
13488 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013489 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013490 break;
13491 }
13492 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013493 vos_mem_copy( pBuf, &wTmp,sizeof( tANI_U16 ) );
13494 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013495 if(!HAL_STATUS_SUCCESS(status))
13496 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013497 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013498 break;
13499 }
13500 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013501 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013502 return( status );
13503}
13504
Jeff Johnson295189b2012-06-20 16:38:30 -070013505eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
13506{
13507 eHalStatus status = eHAL_STATUS_SUCCESS;
13508 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013509 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013510 pMsg = vos_mem_malloc(sizeof( tSirSmeDisassocCnf ));
13511 if ( NULL == pMsg )
13512 status = eHAL_STATUS_FAILURE;
13513 else
13514 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013515 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013516 vos_mem_set(pMsg, sizeof( tSirSmeDisassocCnf), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013517 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
13518 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13519 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013520 vos_mem_copy(pMsg->peerMacAddr, pDisassocInd->peerMacAddr,
13521 sizeof(pMsg->peerMacAddr));
13522 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013523 if(!HAL_STATUS_SUCCESS(status))
13524 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013525 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013526 break;
13527 }
13528//To test reconn
Kiet Lam64c1b492013-07-12 13:56:44 +053013529 vos_mem_copy(pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
13530 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013531 if(!HAL_STATUS_SUCCESS(status))
13532 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013533 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013534 break;
13535 }
13536//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070013537 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013538 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013539 return( status );
13540}
13541
Jeff Johnson295189b2012-06-20 16:38:30 -070013542eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
13543{
13544 eHalStatus status = eHAL_STATUS_SUCCESS;
13545 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013546 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013547 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthCnf ));
13548 if ( NULL == pMsg )
13549 status = eHAL_STATUS_FAILURE;
13550 else
13551 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013552 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013553 vos_mem_set(pMsg, sizeof( tSirSmeDeauthCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013554 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
13555 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13556 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013557 vos_mem_copy(pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
13558 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013559 if(!HAL_STATUS_SUCCESS(status))
13560 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013561 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013562 break;
13563 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013564 vos_mem_copy(pMsg->peerMacAddr, pDeauthInd->peerMacAddr,
13565 sizeof(pMsg->peerMacAddr));
13566 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013567 if(!HAL_STATUS_SUCCESS(status))
13568 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013569 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013570 break;
13571 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013572 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013573 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013574 return( status );
13575}
Jeff Johnson295189b2012-06-20 16:38:30 -070013576eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
13577{
13578 eHalStatus status = eHAL_STATUS_SUCCESS;
13579 tSirSmeAssocCnf *pMsg;
13580 tANI_U8 *pBuf;
13581 tSirResultCodes statusCode;
13582 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013583 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013584 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocCnf ));
13585 if ( NULL == pMsg )
13586 status = eHAL_STATUS_FAILURE;
13587 else
13588 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013589 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013590 vos_mem_set(pMsg, sizeof( tSirSmeAssocCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013591 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
13592 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013593 pBuf = (tANI_U8 *)&pMsg->statusCode;
13594 if(HAL_STATUS_SUCCESS(Halstatus))
13595 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13596 else
13597 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053013598 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes));
Jeff Johnson295189b2012-06-20 16:38:30 -070013599 pBuf += sizeof(tSirResultCodes);
13600 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013601 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13602 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013603 pBuf += sizeof (tSirMacAddr);
13604 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013605 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13606 sizeof(tSirMacAddr));
13607 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013608 pBuf += sizeof (tSirMacAddr);
13609 // aid
13610 wTmp = pal_cpu_to_be16(pAssocInd->aid);
Kiet Lam64c1b492013-07-12 13:56:44 +053013611 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013612 pBuf += sizeof (tANI_U16);
13613 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013614 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13615 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013616 pBuf += sizeof (tSirMacAddr);
13617 // alternateChannelId
13618 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070013619 status = palSendMBMessage( pMac->hHdd, pMsg );
13620 if(!HAL_STATUS_SUCCESS(status))
13621 {
13622 //pMsg is freed by palSendMBMessage
13623 break;
13624 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013625 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013626 return( status );
13627}
Jeff Johnson295189b2012-06-20 16:38:30 -070013628eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
13629 tpSirSmeAssocInd pAssocInd,
13630 eHalStatus Halstatus,
13631 tANI_U8 sessionId)
13632{
13633 tSirMsgQ msgQ;
Jeff Johnson295189b2012-06-20 16:38:30 -070013634 tSirSmeAssocIndToUpperLayerCnf *pMsg;
13635 tANI_U8 *pBuf;
13636 tSirResultCodes statusCode;
13637 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013638 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013639 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocIndToUpperLayerCnf ));
13640 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13641 vos_mem_set(pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ), 0);
Jeff Johnsone7245742012-09-05 17:12:55 -070013642
Jeff Johnson295189b2012-06-20 16:38:30 -070013643 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
13644 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
13645
13646 pMsg->sessionId = sessionId;
13647
13648 pBuf = (tANI_U8 *)&pMsg->statusCode;
13649 if(HAL_STATUS_SUCCESS(Halstatus))
13650 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13651 else
13652 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053013653 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes)) ;
Jeff Johnson295189b2012-06-20 16:38:30 -070013654 pBuf += sizeof(tSirResultCodes);
13655 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013656 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013657 pBuf += sizeof (tSirMacAddr);
13658 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013659 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13660 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013661 pBuf += sizeof (tSirMacAddr);
13662 // StaId
13663 wTmp = pal_cpu_to_be16(pAssocInd->staId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013664 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013665 pBuf += sizeof (tANI_U16);
13666 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013667 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013668 pBuf += sizeof (tSirMacAddr);
13669 // alternateChannelId
13670 *pBuf = 11;
13671 pBuf += sizeof (tANI_U8);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013672 // Instead of copying roam Info, we just copy only WmmEnabled, RsnIE information
Jeff Johnson295189b2012-06-20 16:38:30 -070013673 //Wmm
13674 *pBuf = pAssocInd->wmmEnabledSta;
13675 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013676 //RSN IE
Kiet Lam64c1b492013-07-12 13:56:44 +053013677 vos_mem_copy((tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070013678 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070013679 //Additional IE
Kiet Lam64c1b492013-07-12 13:56:44 +053013680 vos_mem_copy((void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
Jeff Johnson295189b2012-06-20 16:38:30 -070013681 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070013682 //reassocReq
13683 *pBuf = pAssocInd->reassocReq;
13684 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013685 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
13686 msgQ.bodyptr = pMsg;
13687 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013688 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013689 } while( 0 );
Kiet Lam64c1b492013-07-12 13:56:44 +053013690 return( eHAL_STATUS_SUCCESS );
Jeff Johnson295189b2012-06-20 16:38:30 -070013691}
Jeff Johnson295189b2012-06-20 16:38:30 -070013692
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013693eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -070013694 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
13695 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
13696 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
13697 tANI_U8 *pKeyRsc )
13698{
13699 tSirSmeSetContextReq *pMsg;
13700 tANI_U16 msgLen;
13701 eHalStatus status = eHAL_STATUS_FAILURE;
13702 tAniEdType tmpEdType;
13703 tAniKeyDirection tmpDirection;
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +053013704 tANI_U8 *pBuf = NULL;
13705 tANI_U8 *p = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013706 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013707 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070013708 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013709 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
13710 // key set. Since we only support upto one key, we always allocate memory for 1 key
13711 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
13712 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
13713 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
13714 ( sizeof( pMsg->keyMaterial.key ) );
13715
Kiet Lam64c1b492013-07-12 13:56:44 +053013716 pMsg = vos_mem_malloc(msgLen);
13717 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13718 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013719 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
13720 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013721 //sessionId
13722 pBuf = &pMsg->sessionId;
13723 *pBuf = (tANI_U8)sessionId;
13724 pBuf++;
13725 // transactionId
13726 *pBuf = 0;
13727 *(pBuf + 1) = 0;
13728 pBuf += sizeof(tANI_U16);
13729 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013730 vos_mem_copy(pBuf, (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013731
13732 pBuf += sizeof(tSirMacAddr);
13733
13734 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013735 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
13736 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013737
13738 pBuf += sizeof(tSirMacAddr);
13739
13740 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013741 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
13742 // in the tSirKeyMaterial keyMaterial; field).
13743 //
13744 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
13745 // shorter than this max size. Is LIM interpreting this ok ?
13746 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 -070013747 // set pMsg->keyMaterial.edType
13748 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013749 vos_mem_copy(p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013750 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070013751 // set the pMsg->keyMaterial.numKeys field
13752 *p = numKeys;
13753 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070013754 // set pSirKey->keyId = keyId;
13755 *p = keyId;
13756 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013757 // set pSirKey->unicast = (tANI_U8)fUnicast;
13758 *p = (tANI_U8)fUnicast;
13759 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070013760 // set pSirKey->keyDirection = aniKeyDirection;
13761 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
Kiet Lam64c1b492013-07-12 13:56:44 +053013762 vos_mem_copy(p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection));
Jeff Johnson295189b2012-06-20 16:38:30 -070013763 p += sizeof(tAniKeyDirection);
13764 // pSirKey->keyRsc = ;;
Kiet Lam64c1b492013-07-12 13:56:44 +053013765 vos_mem_copy(p, pKeyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -070013766 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070013767 // set pSirKey->paeRole
13768 *p = paeRole; // 0 is Supplicant
13769 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013770 // set pSirKey->keyLength = keyLength;
13771 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013772 if ( keyLength && pKey )
13773 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013774 vos_mem_copy(p, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013775 if(keyLength == 16)
13776 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013777 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 -070013778 keyId, edType, pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
13779 pKey[5], pKey[6], pKey[7], pKey[8],
13780 pKey[9], pKey[10], pKey[11], pKey[12], pKey[13], pKey[14], pKey[15]);
13781 }
13782 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013783 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013784 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013785 return( status );
13786}
13787
Jeff Johnson295189b2012-06-20 16:38:30 -070013788eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
13789 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
13790{
13791 eHalStatus status;
13792 tSirSmeStartBssReq *pMsg;
13793 tANI_U8 *pBuf = NULL;
13794 tANI_U8 *wTmpBuf = NULL;
13795 tANI_U16 msgLen, wTmp;
13796 tANI_U32 dwTmp;
13797 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070013798 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070013799 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070013800 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013801
13802 if(!pSession)
13803 {
13804 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13805 return eHAL_STATUS_FAILURE;
13806 }
13807
Jeff Johnson295189b2012-06-20 16:38:30 -070013808 do {
13809 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
13810 pSession->joinFailStatusCode.reasonCode = 0;
13811 msgLen = sizeof(tSirSmeStartBssReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053013812 pMsg = vos_mem_malloc(msgLen);
13813 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13814 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013815 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013816 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013817 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013818 //sessionId
13819 *pBuf = (tANI_U8)sessionId;
13820 pBuf++;
13821 // transactionId
13822 *pBuf = 0;
13823 *(pBuf + 1) = 0;
13824 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013825 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053013826 vos_mem_copy(pBuf, pParam->bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013827 pBuf += sizeof(tSirMacAddr);
13828 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013829 vos_mem_copy(pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013830 pBuf += sizeof(tSirMacAddr);
13831 // beaconInterval
13832 if( pBssDesc && pBssDesc->beaconInterval )
13833 {
13834 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
13835 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013836 else if(pParam->beaconInterval)
13837 {
13838 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
13839 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013840 else
13841 {
13842 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
13843 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -070013844 if(csrIsconcurrentsessionValid (pMac, sessionId,
13845 pParam->bssPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -070013846 == eHAL_STATUS_SUCCESS )
13847 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013848 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070013849 pParam->bssPersona);
13850 //Update the beacon Interval
13851 pParam->beaconInterval = wTmp;
13852 }
13853 else
13854 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013855 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070013856 status = eHAL_STATUS_FAILURE;
Kiet Lam64c1b492013-07-12 13:56:44 +053013857 vos_mem_free(pMsg);
Jeff Johnsone7245742012-09-05 17:12:55 -070013858 return status;
13859 }
13860
Kiet Lam64c1b492013-07-12 13:56:44 +053013861 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013862 pBuf += sizeof(tANI_U16);
13863 // dot11mode
13864 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
13865 pBuf += 1;
13866 // bssType
13867 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013868 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013869 pBuf += sizeof(tSirBssType);
13870 // ssId
13871 if( pParam->ssId.length )
13872 {
13873 // ssId len
13874 *pBuf = pParam->ssId.length;
13875 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053013876 vos_mem_copy(pBuf, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070013877 pBuf += pParam->ssId.length;
13878 }
13879 else
13880 {
13881 *pBuf = 0;
13882 pBuf++;
13883 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013884 // set the channel Id
13885 *pBuf = pParam->operationChn;
13886 pBuf++;
13887 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070013888 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013889 vos_mem_copy(pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState));
Jeff Johnsone7245742012-09-05 17:12:55 -070013890 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070013891
Jeff Johnson295189b2012-06-20 16:38:30 -070013892 // Set privacy
13893 *pBuf = pParam->privacy;
13894 pBuf++;
13895
13896 //Set Uapsd
13897 *pBuf = pParam->ApUapsdEnable;
13898 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013899 //Set SSID hidden
13900 *pBuf = pParam->ssidHidden;
13901 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013902 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
13903 pBuf++;
13904
13905 //Ht protection Enable/Disable
13906 *pBuf = (tANI_U8)pParam->protEnabled;
13907 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013908 //Enable Beacons to Receive for OBSS protection Enable/Disable
13909 *pBuf = (tANI_U8)pParam->obssProtEnabled;
13910 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013911 //set cfg related to protection
13912 wTmp = pal_cpu_to_be16( pParam->ht_protection );
Kiet Lam64c1b492013-07-12 13:56:44 +053013913 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013914 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013915 // Set Auth type
13916 authType = pal_cpu_to_be32(pParam->authType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013917 vos_mem_copy(pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013918 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013919 // Set DTIM
13920 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
Kiet Lam64c1b492013-07-12 13:56:44 +053013921 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013922 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013923 // Set wps_state
13924 *pBuf = pParam->wps_state;
13925 pBuf++;
krunal sonie9002db2013-11-25 14:24:17 -080013926 // set isCoalesingInIBSSAllowed
13927 *pBuf = pMac->isCoalesingInIBSSAllowed;
13928 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013929 //Persona
13930 *pBuf = (tANI_U8)pParam->bssPersona;
13931 pBuf++;
13932
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080013933 //txLdpcIniFeatureEnabled
13934 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
13935 pBuf++;
krunal soni4f087d22013-07-29 16:32:26 -070013936
Chet Lanctot8cecea22014-02-11 19:09:36 -080013937#ifdef WLAN_FEATURE_11W
13938 // Set MFP capable/required
13939 *pBuf = (tANI_U8)pParam->mfpCapable;
13940 pBuf++;
13941 *pBuf = (tANI_U8)pParam->mfpRequired;
13942 pBuf++;
13943#endif
13944
krunal soni4f087d22013-07-29 16:32:26 -070013945 // set RSN IE
Jeff Johnson295189b2012-06-20 16:38:30 -070013946 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
13947 {
13948 status = eHAL_STATUS_INVALID_PARAMETER;
Kiet Lam64c1b492013-07-12 13:56:44 +053013949 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013950 break;
13951 }
13952 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
Kiet Lam64c1b492013-07-12 13:56:44 +053013953 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013954 pBuf += sizeof(tANI_U16);
13955 if( wTmp )
13956 {
13957 wTmp = pParam->nRSNIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +053013958 vos_mem_copy(pBuf, pParam->pRSNIE, wTmp);
Jeff Johnson295189b2012-06-20 16:38:30 -070013959 pBuf += wTmp;
13960 }
13961 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013962 vos_mem_copy(pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013963 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070013964 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
13965 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053013966 vos_mem_copy(pBuf, pParam->operationalRateSet.rate,
13967 pParam->operationalRateSet.numRates );
Jeff Johnson295189b2012-06-20 16:38:30 -070013968 pBuf += pParam->operationalRateSet.numRates ;
13969 *pBuf++ = pParam->extendedRateSet.numRates;
13970 if(0 != pParam->extendedRateSet.numRates)
13971 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013972 vos_mem_copy(pBuf, pParam->extendedRateSet.rate,
13973 pParam->extendedRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070013974 pBuf += pParam->extendedRateSet.numRates;
13975 }
krunal sonie9002db2013-11-25 14:24:17 -080013976
Jeff Johnson295189b2012-06-20 16:38:30 -070013977 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
13978 pMsg->length = pal_cpu_to_be16(msgLen);
13979
13980 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013981 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013982 return( status );
13983}
13984
Jeff Johnson295189b2012-06-20 16:38:30 -070013985eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
13986{
13987 eHalStatus status = eHAL_STATUS_FAILURE;
13988 tSirSmeStopBssReq *pMsg;
13989 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13990 tANI_U8 *pBuf;
13991 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013992
13993 if(!pSession)
13994 {
13995 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13996 return eHAL_STATUS_FAILURE;
13997 }
13998
Jeff Johnson295189b2012-06-20 16:38:30 -070013999 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053014000 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
14001 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14002 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014003 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
14004 pBuf = &pMsg->sessionId;
14005 //sessionId
14006 *pBuf = (tANI_U8)sessionId;
14007 pBuf++;
14008 // transactionId
14009 *pBuf = 0;
14010 pBuf += sizeof(tANI_U16);
14011 //reason code
14012 *pBuf = 0;
14013 pBuf += sizeof(tSirResultCodes);
14014 // bssid
14015 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
14016 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
14017 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014018 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->selfMacAddr,
14019 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014020 }
14021 else
14022 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014023 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
14024 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014025 }
14026 pBuf += sizeof(tSirMacAddr);
14027 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
14028 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014029 status = palSendMBMessage( pMac->hHdd, pMsg );
14030#if 0
Kiet Lam64c1b492013-07-12 13:56:44 +053014031 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
14032 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14033 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014034 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
14035 pMsg->reasonCode = 0;
14036 // bssid
14037 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
14038 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
14039 {
14040 pbBssid = (tANI_U8 *)&pSession->selfMacAddr;
14041 }
14042 else
14043 {
14044 pbBssid = (tANI_U8 *)&pSession->connectedProfile.bssid;
14045 }
Kiet Lam64c1b492013-07-12 13:56:44 +053014046 vos_mem_copy(&pMsg->bssId, pbBssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014047 pMsg->transactionId = 0;
14048 pMsg->sessionId = (tANI_U8)sessionId;
14049 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeStopBssReq ));
14050 status = palSendMBMessage( pMac->hHdd, pMsg );
14051#endif
14052 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014053 return( status );
14054}
14055
Jeff Johnson295189b2012-06-20 16:38:30 -070014056eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
14057 tCsrRoamModifyProfileFields *pModProfileFields,
14058 tANI_U32 *pRoamId, v_BOOL_t fForce)
14059{
Jeff Johnson295189b2012-06-20 16:38:30 -070014060 eHalStatus status = eHAL_STATUS_FAILURE;
14061 tANI_U32 roamId = 0;
14062 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014063 if((csrIsConnStateConnected(pMac, sessionId)) &&
Kiet Lam64c1b492013-07-12 13:56:44 +053014064 (fForce || (!vos_mem_compare( &pModProfileFields,
14065 &pSession->connectedProfile.modifyProfileFields,
14066 sizeof(tCsrRoamModifyProfileFields)))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070014067 {
14068 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
14069 if(pRoamId)
14070 {
14071 *pRoamId = roamId;
14072 }
14073
Jeff Johnson295189b2012-06-20 16:38:30 -070014074 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
14075 eCsrSmeIssuedReassocToSameAP, roamId,
14076 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014077 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014078 return status;
14079}
Jeff Johnson295189b2012-06-20 16:38:30 -070014080static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
14081{
14082 eHalStatus status = eHAL_STATUS_SUCCESS;
14083 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +053014084 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014085 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
14086 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
14087 return (status);
14088}
Jeff Johnson295189b2012-06-20 16:38:30 -070014089eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
14090{
14091 eHalStatus status = eHAL_STATUS_SUCCESS;
14092 tListElem *pEntry = NULL;
14093 tSmeCmd *pCommand = NULL;
14094 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014095 do
14096 {
14097 if(pMsg == NULL)
14098 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014099 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014100 status = eHAL_STATUS_FAILURE;
14101 break;
14102 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014103 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
14104 if(pEntry)
14105 {
14106 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14107 if(eSmeCommandAddStaSession == pCommand->command)
14108 {
14109 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014110 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Siddharth Bhal85f99b12014-05-09 08:09:07 +053014111 if (pRsp->status == eSIR_FAILURE) {
14112 VOS_ASSERT( 0 );
14113 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014114 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070014115 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014116 //Remove this command out of the active list
14117 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
14118 {
14119 //Now put this command back on the avilable command list
14120 csrReleaseCommand(pMac, pCommand);
14121 }
14122 smeProcessPendingQueue( pMac );
14123 }
14124 else
14125 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014126 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 -070014127 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014128 status = eHAL_STATUS_FAILURE;
14129 break;
14130 }
14131 }
14132 else
14133 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014134 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 -070014135 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014136 status = eHAL_STATUS_FAILURE;
14137 break;
14138 }
14139 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014140 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014141}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014142eHalStatus csrSendMBAddSelfStaReqMsg(tpAniSirGlobal pMac,
14143 tAddStaForSessionCmd *pAddStaReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070014144{
14145 tSirSmeAddStaSelfReq *pMsg;
14146 tANI_U16 msgLen;
14147 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014148 do {
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014149 msgLen = sizeof(tSirSmeAddStaSelfReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053014150 pMsg = vos_mem_malloc(msgLen);
14151 if ( NULL == pMsg ) break;
14152 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014153 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
14154 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014155 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053014156 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr,
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014157 (tANI_U8 *)&pAddStaReq->selfMacAddr, sizeof(tSirMacAddr));
14158
14159 pMsg->currDeviceMode = pAddStaReq->currDeviceMode;
14160
Arif Hussain24bafea2013-11-15 15:10:03 -080014161 smsLog( pMac, LOG1, FL("selfMac="MAC_ADDRESS_STR),
14162 MAC_ADDR_ARRAY(pMsg->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014163 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014164 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014165 return( status );
14166}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014167eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac,
14168 tANI_U32 sessionId,
14169 tSirMacAddr sessionMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -070014170{
14171 eHalStatus status = eHAL_STATUS_SUCCESS;
14172 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014173 pCommand = csrGetCommandBuffer(pMac);
14174 if(NULL == pCommand)
14175 {
14176 status = eHAL_STATUS_RESOURCES;
14177 }
14178 else
14179 {
14180 pCommand->command = eSmeCommandAddStaSession;
14181 pCommand->sessionId = (tANI_U8)sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053014182 vos_mem_copy(pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr,
14183 sizeof( tSirMacAddr ) );
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014184 pCommand->u.addStaSessionCmd.currDeviceMode = pMac->sme.currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070014185 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
14186 if( !HAL_STATUS_SUCCESS( status ) )
14187 {
14188 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014189 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014190 }
14191 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014192 return (status);
14193}
Jeff Johnson295189b2012-06-20 16:38:30 -070014194eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14195{
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014196 return csrSendMBAddSelfStaReqMsg(pMac, &pCommand->u.addStaSessionCmd);
Jeff Johnson295189b2012-06-20 16:38:30 -070014197}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014198eHalStatus csrRoamOpenSession(tpAniSirGlobal pMac,
14199 csrRoamCompleteCallback callback,
14200 void *pContext, tANI_U8 *pSelfMacAddr,
14201 tANI_U8 *pbSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -070014202{
14203 eHalStatus status = eHAL_STATUS_SUCCESS;
14204 tANI_U32 i;
14205 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070014206 *pbSessionId = CSR_SESSION_ID_INVALID;
14207 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14208 {
14209 if( !CSR_IS_SESSION_VALID( pMac, i ) )
14210 {
14211 pSession = CSR_GET_SESSION( pMac, i );
14212 status = eHAL_STATUS_SUCCESS;
14213 pSession->sessionActive = eANI_BOOLEAN_TRUE;
14214 pSession->sessionId = (tANI_U8)i;
14215 pSession->callback = callback;
14216 pSession->pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053014217 vos_mem_copy(&pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070014218 *pbSessionId = (tANI_U8)i;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014219 status = vos_timer_init(&pSession->hTimerRoaming, VOS_TIMER_TYPE_SW,
14220 csrRoamRoamingTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070014221 &pSession->roamingTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014222 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014223 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014224 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014225 break;
14226 }
14227#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014228 status = vos_timer_init(&pSession->hTimerJoinRetry, VOS_TIMER_TYPE_SW,
14229 csrRoamJoinRetryTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070014230 &pSession->joinRetryTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014231 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014232 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014233 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014234 break;
14235 }
14236#endif
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014237 status = csrIssueAddStaForSessionReq (pMac, i, pSelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014238 break;
14239 }
14240 }
14241 if( CSR_ROAM_SESSION_MAX == i )
14242 {
14243 //No session is available
14244 status = eHAL_STATUS_RESOURCES;
14245 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014246 return ( status );
14247}
Jeff Johnson295189b2012-06-20 16:38:30 -070014248eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
14249{
14250 eHalStatus status = eHAL_STATUS_SUCCESS;
14251 tListElem *pEntry = NULL;
14252 tSmeCmd *pCommand = NULL;
14253 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014254 do
14255 {
14256 if(pMsg == NULL)
14257 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014258 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014259 status = eHAL_STATUS_FAILURE;
14260 break;
14261 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014262 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
14263 if(pEntry)
14264 {
14265 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14266 if(eSmeCommandDelStaSession == pCommand->command)
14267 {
14268 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070014269 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014270 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014271 //This session is done.
14272 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014273 if(pCommand->u.delStaSessionCmd.callback)
14274 {
14275
14276 status = sme_ReleaseGlobalLock( &pMac->sme );
14277 if ( HAL_STATUS_SUCCESS( status ) )
14278 {
14279 pCommand->u.delStaSessionCmd.callback(
14280 pCommand->u.delStaSessionCmd.pContext);
14281 status = sme_AcquireGlobalLock( &pMac->sme );
14282 if (! HAL_STATUS_SUCCESS( status ) )
14283 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014284 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014285 return status;
14286 }
14287 }
14288 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014289 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014290 }
14291 }
14292
14293 //Remove this command out of the active list
14294 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
14295 {
14296 //Now put this command back on the avilable command list
14297 csrReleaseCommand(pMac, pCommand);
14298 }
14299 smeProcessPendingQueue( pMac );
14300 }
14301 else
14302 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014303 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 -070014304 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014305 status = eHAL_STATUS_FAILURE;
14306 break;
14307 }
14308 }
14309 else
14310 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014311 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 -070014312 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014313 status = eHAL_STATUS_FAILURE;
14314 break;
14315 }
14316 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014317 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014318}
Jeff Johnson295189b2012-06-20 16:38:30 -070014319eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
14320{
14321 tSirSmeDelStaSelfReq *pMsg;
14322 tANI_U16 msgLen;
14323 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014324 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070014325 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
14326 sizeof( tSirBssType )*/;
Kiet Lam64c1b492013-07-12 13:56:44 +053014327 pMsg = vos_mem_malloc(msgLen);
14328 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14329 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014330 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
14331 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014332 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053014333 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr,
14334 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014335 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014336 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014337 return( status );
14338}
Jeff Johnson295189b2012-06-20 16:38:30 -070014339eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
14340 tSirMacAddr sessionMacAddr,
14341 csrRoamSessionCloseCallback callback,
14342 void *pContext)
14343{
14344 eHalStatus status = eHAL_STATUS_SUCCESS;
14345 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014346 pCommand = csrGetCommandBuffer(pMac);
14347 if(NULL == pCommand)
14348 {
14349 status = eHAL_STATUS_RESOURCES;
14350 }
14351 else
14352 {
14353 pCommand->command = eSmeCommandDelStaSession;
14354 pCommand->sessionId = (tANI_U8)sessionId;
14355 pCommand->u.delStaSessionCmd.callback = callback;
14356 pCommand->u.delStaSessionCmd.pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053014357 vos_mem_copy(pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr,
14358 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014359 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
14360 if( !HAL_STATUS_SUCCESS( status ) )
14361 {
14362 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014363 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014364 }
14365 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014366 return (status);
14367}
Jeff Johnson295189b2012-06-20 16:38:30 -070014368eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14369{
14370 return csrSendMBDelSelfStaReqMsg( pMac,
14371 pCommand->u.delStaSessionCmd.selfMacAddr );
14372}
Jeff Johnson295189b2012-06-20 16:38:30 -070014373static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
14374{
14375 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
14376 tListElem *pEntry, *pNext;
14377 tSmeCmd *pCommand;
14378 tDblLinkList localList;
14379
14380 vos_mem_zero(&localList, sizeof(tDblLinkList));
14381 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
14382 {
14383 smsLog(pMac, LOGE, FL(" failed to open list"));
14384 return;
14385 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014386 csrLLLock(pList);
14387 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
14388 while(pEntry != NULL)
14389 {
14390 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
14391 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14392 if(pCommand->sessionId == sessionId)
14393 {
14394 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
14395 {
14396 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
14397 }
14398 }
14399 pEntry = pNext;
14400 }
14401 csrLLUnlock(pList);
14402
14403 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
14404 {
14405 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14406 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
14407 }
14408 csrLLClose(&localList);
14409}
14410
Jeff Johnson295189b2012-06-20 16:38:30 -070014411void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
14412{
14413 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14414 {
14415 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014416 csrRoamStop(pMac, sessionId);
14417 csrFreeConnectBssDesc(pMac, sessionId);
14418 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
14419 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014420 vos_timer_destroy(&pSession->hTimerRoaming);
Jeff Johnson295189b2012-06-20 16:38:30 -070014421#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014422 vos_timer_destroy(&pSession->hTimerJoinRetry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014423#endif
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014424 purgeSmeSessionCmdList(pMac, sessionId, &pMac->sme.smeCmdPendingList);
14425 if (pMac->fScanOffload)
14426 {
14427 purgeSmeSessionCmdList(pMac, sessionId,
14428 &pMac->sme.smeScanCmdPendingList);
14429 }
14430
Jeff Johnson295189b2012-06-20 16:38:30 -070014431 purgeCsrSessionCmdList(pMac, sessionId);
14432 csrInitSession(pMac, sessionId);
14433 }
14434}
14435
Jeff Johnson295189b2012-06-20 16:38:30 -070014436eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
14437 tANI_BOOLEAN fSync,
14438 csrRoamSessionCloseCallback callback,
14439 void *pContext )
14440{
14441 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014442 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14443 {
14444 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14445 if(fSync)
14446 {
14447 csrCleanupSession(pMac, sessionId);
14448 }
14449 else
14450 {
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014451 purgeSmeSessionCmdList(pMac, sessionId,
14452 &pMac->sme.smeCmdPendingList);
14453 if (pMac->fScanOffload)
14454 {
14455 purgeSmeSessionCmdList(pMac, sessionId,
14456 &pMac->sme.smeScanCmdPendingList);
14457 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014458 purgeCsrSessionCmdList(pMac, sessionId);
14459 status = csrIssueDelStaForSessionReq( pMac, sessionId,
14460 pSession->selfMacAddr, callback, pContext);
14461 }
14462 }
14463 else
14464 {
14465 status = eHAL_STATUS_INVALID_PARAMETER;
14466 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014467 return ( status );
14468}
14469
Jeff Johnson295189b2012-06-20 16:38:30 -070014470static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
14471{
14472 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014473
14474 if(!pSession)
14475 {
14476 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14477 return;
14478 }
14479
Jeff Johnson295189b2012-06-20 16:38:30 -070014480 pSession->sessionActive = eANI_BOOLEAN_FALSE;
14481 pSession->sessionId = CSR_SESSION_ID_INVALID;
14482 pSession->callback = NULL;
14483 pSession->pContext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014484 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
14485 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
14486 csrFreeRoamProfile( pMac, sessionId );
14487 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
14488 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
14489 csrFreeConnectBssDesc(pMac, sessionId);
14490 csrScanEnable(pMac);
Kiet Lam64c1b492013-07-12 13:56:44 +053014491 vos_mem_set(&pSession->selfMacAddr, sizeof(tCsrBssid), 0);
14492 if (pSession->pWpaRsnReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014493 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014494 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014495 pSession->pWpaRsnReqIE = NULL;
14496 }
14497 pSession->nWpaRsnReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014498 if (pSession->pWpaRsnRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014499 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014500 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014501 pSession->pWpaRsnRspIE = NULL;
14502 }
14503 pSession->nWpaRsnRspIeLength = 0;
14504#ifdef FEATURE_WLAN_WAPI
Kiet Lam64c1b492013-07-12 13:56:44 +053014505 if (pSession->pWapiReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014506 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014507 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014508 pSession->pWapiReqIE = NULL;
14509 }
14510 pSession->nWapiReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014511 if (pSession->pWapiRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014512 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014513 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014514 pSession->pWapiRspIE = NULL;
14515 }
14516 pSession->nWapiRspIeLength = 0;
14517#endif /* FEATURE_WLAN_WAPI */
Agarwal Ashish4f616132013-12-30 23:32:50 +053014518 if (pSession->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070014519 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053014520 memset(pSession->addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH);
Jeff Johnson295189b2012-06-20 16:38:30 -070014521 }
14522 pSession->nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053014523
Kiet Lam64c1b492013-07-12 13:56:44 +053014524 if (pSession->pAddIEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070014525 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014526 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070014527 pSession->pAddIEAssoc = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053014528 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014529 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014530}
14531
Jeff Johnson295189b2012-06-20 16:38:30 -070014532eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
14533{
14534 eHalStatus status = eHAL_STATUS_FAILURE;
14535 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070014536 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14537 {
14538 if( CSR_IS_SESSION_VALID( pMac, i ) )
14539 {
14540 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
14541 {
14542 //Found it
14543 status = eHAL_STATUS_SUCCESS;
14544 *pSessionId = i;
14545 break;
14546 }
14547 }
14548 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014549 return( status );
14550}
14551
Jeff Johnson295189b2012-06-20 16:38:30 -070014552//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
14553//session because for IBSS, the bssid changes.
14554static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
14555{
14556 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
14557 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070014558 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14559 {
14560 if( CSR_IS_SESSION_VALID( pMac, i ) )
14561 {
14562 pSession = CSR_GET_SESSION( pMac, i );
14563 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
14564 {
14565 //Found it
14566 nRet = i;
14567 break;
14568 }
14569 }
14570 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014571 return (nRet);
14572}
Jeff Johnson295189b2012-06-20 16:38:30 -070014573static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
14574{
14575 /* Update the current BSS info in ho control block based on connected
14576 profile info from pmac global structure */
14577
Arif Hussain24bafea2013-11-15 15:10:03 -080014578 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= "MAC_ADDRESS_STR,
14579 MAC_ADDR_ARRAY(bssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070014580 /* Check for user misconfig of RSSI trigger threshold */
14581 pMac->roam.configParam.vccRssiThreshold =
14582 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
14583 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
14584 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070014585 /* Check for user misconfig of UL MAC Loss trigger threshold */
14586 pMac->roam.configParam.vccUlMacLossThreshold =
14587 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
14588 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014589#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14590 {
14591 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014592 /* Indicate the neighbor roal algorithm about the connect indication */
14593 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
14594 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
14595 }
14596#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014597}
14598
Jeff Johnson295189b2012-06-20 16:38:30 -070014599static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
14600{
14601 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014602
14603 if(!pSession)
14604 {
14605 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14606 return;
14607 }
14608
Jeff Johnson295189b2012-06-20 16:38:30 -070014609 //Only to handle the case for Handover on infra link
14610 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
14611 {
14612 return;
14613 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014614 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
14615 csrRoamDeregStatisticsReq(pMac);
14616 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14617#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14618 /* Indicate the neighbor roal algorithm about the disconnect indication */
14619 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
14620#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070014621
14622 //Remove this code once SLM_Sessionization is supported
14623 //BMPS_WORKAROUND_NOT_NEEDED
14624 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070014625 csrIsInfraApStarted( pMac ) &&
14626 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070014627 {
14628 pMac->roam.configParam.doBMPSWorkaround = 0;
14629 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014630}
14631
Jeff Johnson295189b2012-06-20 16:38:30 -070014632void csrRoamTlStatsTimerHandler(void *pv)
14633{
14634 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
14635 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014636 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14637
Jeff Johnsone7245742012-09-05 17:12:55 -070014638 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
14639
Jeff Johnson295189b2012-06-20 16:38:30 -070014640#if 0
14641 // TODO Persession .???
14642 //req TL for stats
14643 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
14644 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014645 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014646 }
14647 else
14648 {
14649 //save in SME
14650 csrRoamSaveStatsFromTl(pMac, tlStats);
14651 }
14652#endif
14653 if(!pMac->roam.tlStatsReqInfo.timerRunning)
14654 {
14655 if(pMac->roam.tlStatsReqInfo.periodicity)
14656 {
14657 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014658 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
14659 pMac->roam.tlStatsReqInfo.periodicity);
14660 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014661 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014662 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014663 return;
14664 }
14665 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
14666 }
14667 }
14668}
Jeff Johnson295189b2012-06-20 16:38:30 -070014669void csrRoamPeStatsTimerHandler(void *pv)
14670{
14671 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
14672 eHalStatus status;
14673 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
14674 VOS_STATUS vosStatus;
14675 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070014676 pPeStatsReqListEntry->timerRunning = FALSE;
14677 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
14678 {
14679 // If we entered here, meaning the timer could not be successfully
14680 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
14681
14682 /* Destroy the timer */
14683 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
14684 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14685 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014686 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014687 }
14688
14689 // Free the entry
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014690 vos_mem_free(pPeStatsReqListEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014691 pPeStatsReqListEntry = NULL;
14692 }
14693 else
14694 {
14695 if(!pPeStatsReqListEntry->rspPending)
14696 {
14697 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
14698 pPeStatsReqListEntry->staId);
14699 if(!HAL_STATUS_SUCCESS(status))
14700 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014701 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014702 }
14703 else
14704 {
14705 pPeStatsReqListEntry->rspPending = TRUE;
14706 }
14707 }
14708
14709 //send down a req
14710 if(pPeStatsReqListEntry->periodicity &&
14711 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
14712 {
14713 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
14714 if(ePMC_FULL_POWER == powerState)
14715 {
14716 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
14717 {
14718 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
14719 }
14720 }
14721 else
14722 {
14723 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
14724 {
14725 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
14726 }
14727 }
14728 //start timer
14729 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
14730 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14731 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014732 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014733 return;
14734 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014735 pPeStatsReqListEntry->timerRunning = TRUE;
14736
14737 }
14738
14739 }
14740}
Jeff Johnson295189b2012-06-20 16:38:30 -070014741void csrRoamStatsClientTimerHandler(void *pv)
14742{
14743 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070014744 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
14745 {
14746#if 0
14747 // TODO Stats fix for multisession
14748 //start the timer
14749 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
14750
14751 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14752 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014753 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014754 }
14755#endif
14756 }
14757#if 0
14758 //send up the stats report
14759 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
14760 pStaEntry->staId, pStaEntry->pContext);
14761#endif
14762}
14763
14764
14765
Jeff Johnson295189b2012-06-20 16:38:30 -070014766eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
14767{
14768 tAniGetPEStatsReq *pMsg;
14769 eHalStatus status = eHAL_STATUS_SUCCESS;
Kiet Lam64c1b492013-07-12 13:56:44 +053014770 pMsg = vos_mem_malloc(sizeof(tAniGetPEStatsReq));
14771 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070014772 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053014773 smsLog(pMac, LOGE, FL( "Failed to allocate mem for stats req "));
Kiet Lam64c1b492013-07-12 13:56:44 +053014774 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014775 }
14776 // need to initiate a stats request to PE
14777 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_STATISTICS_REQ);
14778 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
14779 pMsg->staId = staId;
14780 pMsg->statsMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070014781 status = palSendMBMessage(pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070014782 if(!HAL_STATUS_SUCCESS(status))
14783 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053014784 smsLog(pMac, LOG1, FL("Failed to send down the stats req "));
Jeff Johnson295189b2012-06-20 16:38:30 -070014785 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014786 return status;
14787}
Jeff Johnson295189b2012-06-20 16:38:30 -070014788void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
14789{
14790 tAniGetPEStatsRsp *pSmeStatsRsp;
14791 eHalStatus status = eHAL_STATUS_FAILURE;
14792 tListElem *pEntry = NULL;
14793 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
14794 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
14795 tANI_U32 tempMask = 0;
14796 tANI_U8 counter = 0;
14797 tANI_U8 *pStats = NULL;
14798 tANI_U32 length = 0;
14799 v_PVOID_t pvosGCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014800 v_S7_t rssi = 0, snr = 0;
14801 tANI_U32 *pRssi = NULL, *pSnr = NULL;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014802 tANI_U32 linkCapacity;
Jeff Johnson295189b2012-06-20 16:38:30 -070014803 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
14804 if(pSmeStatsRsp->rc)
14805 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014806 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014807 goto post_update;
14808 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014809 tempMask = pSmeStatsRsp->statsMask;
14810 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070014811 /* subtract all statistics from this length, and after processing the entire
14812 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
14813 * in this 'stats' message.
14814 */
14815 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070014816 //new stats info from PE, fill up the stats strucutres in PMAC
14817 while(tempMask)
14818 {
14819 if(tempMask & 1)
14820 {
14821 switch(counter)
14822 {
14823 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014824 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014825 vos_mem_copy((tANI_U8 *)&pMac->roam.summaryStatsInfo,
14826 pStats, sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014827 pStats += sizeof(tCsrSummaryStatsInfo);
14828 length -= sizeof(tCsrSummaryStatsInfo);
14829 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014830 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014831 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014832 vos_mem_copy((tANI_U8 *)&pMac->roam.classAStatsInfo,
14833 pStats, sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014834 pStats += sizeof(tCsrGlobalClassAStatsInfo);
14835 length -= sizeof(tCsrGlobalClassAStatsInfo);
14836 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014837 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014838 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014839 vos_mem_copy((tANI_U8 *)&pMac->roam.classBStatsInfo,
14840 pStats, sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014841 pStats += sizeof(tCsrGlobalClassBStatsInfo);
14842 length -= sizeof(tCsrGlobalClassBStatsInfo);
14843 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014844 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014845 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014846 vos_mem_copy((tANI_U8 *)&pMac->roam.classCStatsInfo,
14847 pStats, sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014848 pStats += sizeof(tCsrGlobalClassCStatsInfo);
14849 length -= sizeof(tCsrGlobalClassCStatsInfo);
14850 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014851 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014852 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014853 if( CSR_MAX_STA > pSmeStatsRsp->staId )
14854 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014855 vos_mem_copy((tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
14856 pStats, sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014857 }
14858 else
14859 {
14860 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014861 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014862 VOS_ASSERT( 0 );
14863 }
14864 if(!HAL_STATUS_SUCCESS(status))
14865 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014866 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014867 }
14868 pStats += sizeof(tCsrPerStaStatsInfo);
14869 length -= sizeof(tCsrPerStaStatsInfo);
14870 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014871 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014872 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014873 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014874 }
14875 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014876 tempMask >>=1;
14877 counter++;
14878 }
14879 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
14880 if (length != 0)
14881 {
14882 pRssi = (tANI_U32*)pStats;
14883 rssi = (v_S7_t)*pRssi;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014884 pStats += sizeof(tANI_U32);
14885 length -= sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070014886 }
14887 else
14888 {
14889 /* If riva is not sending rssi, continue to use the hack */
14890 rssi = RSSI_HACK_BMPS;
14891 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014892
Jeff Johnson295189b2012-06-20 16:38:30 -070014893 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014894
14895 if (length != 0)
14896 {
14897 linkCapacity = *(tANI_U32*)pStats;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014898 pStats += sizeof(tANI_U32);
14899 length -= sizeof(tANI_U32);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014900 }
14901 else
14902 {
14903 linkCapacity = 0;
14904 }
14905
14906 WDA_UpdateLinkCapacity(pvosGCtx, pSmeStatsRsp->staId, linkCapacity);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014907
14908 if (length != 0)
14909 {
14910 pSnr = (tANI_U32*)pStats;
14911 snr = (v_S7_t)*pSnr;
14912 }
14913 else
14914 {
14915 snr = SNR_HACK_BMPS;
14916 }
14917
14918 WDA_UpdateSnrBmps(pvosGCtx, pSmeStatsRsp->staId, snr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014919post_update:
14920 //make sure to update the pe stats req list
14921 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
14922 if(pEntry)
14923 {
14924 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
14925 pPeStaEntry->rspPending = FALSE;
14926
14927 }
14928 //check the one timer cases
14929 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
14930 if(pEntry)
14931 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014932 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014933 if(pTempStaEntry->timerExpired)
14934 {
14935 //send up the stats report
14936 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
14937 pTempStaEntry->staId, pTempStaEntry->pContext);
14938 //also remove from the client list
14939 csrRoamRemoveStatListEntry(pMac, pEntry);
14940 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014941 }
14942 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014943}
Jeff Johnson295189b2012-06-20 16:38:30 -070014944tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14945{
14946 tListElem *pEntry = NULL;
14947 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014948 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014949 if(!pEntry)
14950 {
14951 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014952 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070014953 return NULL;
14954 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014955 while( pEntry )
14956 {
14957 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014958 if(pTempStaEntry->statsMask == statsMask)
14959 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014960 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014961 break;
14962 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014963 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
14964 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014965 return pEntry;
14966}
14967
Jeff Johnson295189b2012-06-20 16:38:30 -070014968tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
14969 tANI_BOOLEAN update)
14970{
14971 tListElem *pEntry;
14972 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014973 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014974 if(!pEntry)
14975 {
14976 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014977 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014978 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014979 return NULL;
14980 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014981 while( pEntry )
14982 {
14983 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014984 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
14985 (pTempStaEntry->statsMask == pStaEntry->statsMask))
14986 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014987 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014988 if(update)
14989 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014990 pTempStaEntry->periodicity = pStaEntry->periodicity;
14991 pTempStaEntry->callback = pStaEntry->callback;
14992 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070014993 }
14994 break;
14995 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014996 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14997 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014998 return pEntry;
14999}
Jeff Johnson295189b2012-06-20 16:38:30 -070015000tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
15001{
15002 tListElem *pEntry;
15003 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070015004 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015005 if(!pEntry)
15006 {
15007 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070015008 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015009 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070015010 return NULL;
15011 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015012 while( pEntry )
15013 {
15014 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015015 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
15016 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015017 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015018 break;
15019 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015020 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
15021 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015022 return pEntry;
15023}
Jeff Johnson295189b2012-06-20 16:38:30 -070015024eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
15025 csrRoamLinkQualityIndCallback callback,
15026 void *pContext)
15027{
15028 pMac->roam.linkQualityIndInfo.callback = callback;
15029 pMac->roam.linkQualityIndInfo.context = pContext;
15030 if( NULL == callback )
15031 {
15032 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
15033 }
15034 else
15035 {
15036 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070015037 /* do we need to invoke the callback to notify client of initial value ?? */
15038 }
15039 return eHAL_STATUS_SUCCESS;
15040}
Jeff Johnson295189b2012-06-20 16:38:30 -070015041void csrRoamVccTrigger(tpAniSirGlobal pMac)
15042{
15043 eCsrRoamLinkQualityInd newVccLinkQuality;
15044 tANI_U32 ul_mac_loss = 0;
15045 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070015046 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
15047 /*-------------------------------------------------------------------------
15048 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070015049 Check for a change in link quality and notify client if necessary
15050 -------------------------------------------------------------------------*/
15051 ul_mac_loss_trigger_threshold =
15052 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070015053 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015054 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015055 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070015056 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
15057 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015058 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070015059 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
15060 }
15061 else
15062 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015063 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070015064 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
15065 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015066 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
15067 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070015068 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
15069 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015070 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070015071 if(NULL != pMac->roam.linkQualityIndInfo.callback)
15072 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015073 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015074 newVccLinkQuality );
15075
15076 /* we now invoke the callback once to notify client of initial value */
15077 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
15078 pMac->roam.linkQualityIndInfo.context );
15079 //event: EVENT_WLAN_VCC
15080 }
15081 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015082 pMac->roam.vccLinkQuality = newVccLinkQuality;
15083
Jeff Johnson295189b2012-06-20 16:38:30 -070015084}
Jeff Johnson295189b2012-06-20 16:38:30 -070015085VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
15086 v_U8_t rssiNotification,
15087 void * context)
15088{
15089 tpAniSirGlobal pMac = PMAC_STRUCT( context );
15090 eCsrRoamLinkQualityInd newVccLinkQuality;
15091 // TODO : Session info unavailable
15092 tANI_U32 sessionId = 0;
15093 VOS_STATUS status = VOS_STATUS_SUCCESS;
15094 /*-------------------------------------------------------------------------
15095 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070015096 Check for a change in link quality and notify client if necessary
15097 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015098 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015099 pMac->roam.configParam.vccRssiThreshold);
15100 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
15101 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015102 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070015103 return VOS_STATUS_SUCCESS;
15104 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015105 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
15106 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015107 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070015108 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
15109 }
15110 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
15111 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015112 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070015113 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
15114 }
15115 else
15116 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015117 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070015118 //Set to this so the code below won't do anything
15119 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070015120 VOS_ASSERT(0);
15121 }
15122
Jeff Johnson295189b2012-06-20 16:38:30 -070015123 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
15124 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015125 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070015126 if(NULL != pMac->roam.linkQualityIndInfo.callback)
15127 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015128 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015129 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070015130 /* we now invoke the callback once to notify client of initial value */
15131 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
15132 pMac->roam.linkQualityIndInfo.context );
15133 //event: EVENT_WLAN_VCC
15134 }
15135 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015136 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070015137 return status;
15138}
Jeff Johnson295189b2012-06-20 16:38:30 -070015139tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
15140 tDblLinkList *pStaList,
15141 tCsrStatsClientReqInfo *pStaEntry)
15142{
15143 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015144 //if same entity requested for same set of stats with different periodicity &
15145 // callback update it
15146 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
15147 {
15148
Kiet Lam64c1b492013-07-12 13:56:44 +053015149 pNewStaEntry = vos_mem_malloc(sizeof(tCsrStatsClientReqInfo));
15150 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015151 {
15152 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015153 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070015154 return NULL;
15155 }
15156
Jeff Johnson295189b2012-06-20 16:38:30 -070015157 pNewStaEntry->callback = pStaEntry->callback;
15158 pNewStaEntry->pContext = pStaEntry->pContext;
15159 pNewStaEntry->periodicity = pStaEntry->periodicity;
15160 pNewStaEntry->requesterId = pStaEntry->requesterId;
15161 pNewStaEntry->statsMask = pStaEntry->statsMask;
15162 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
15163 pNewStaEntry->pMac = pStaEntry->pMac;
15164 pNewStaEntry->staId = pStaEntry->staId;
15165 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
15166
15167 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
15168 }
15169 return pNewStaEntry;
15170}
15171
Jeff Johnson295189b2012-06-20 16:38:30 -070015172tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
15173 tDblLinkList *pStaList,
15174 tCsrPeStatsReqInfo *pStaEntry)
15175{
15176 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053015177 pNewStaEntry = vos_mem_malloc(sizeof(tCsrPeStatsReqInfo));
15178 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015179 {
15180 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015181 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070015182 return NULL;
15183 }
15184
Jeff Johnson295189b2012-06-20 16:38:30 -070015185 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
15186 pNewStaEntry->numClient = pStaEntry->numClient;
15187 pNewStaEntry->periodicity = pStaEntry->periodicity;
15188 pNewStaEntry->statsMask = pStaEntry->statsMask;
15189 pNewStaEntry->pMac = pStaEntry->pMac;
15190 pNewStaEntry->staId = pStaEntry->staId;
15191 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
15192 pNewStaEntry->rspPending = pStaEntry->rspPending;
15193
15194 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015195 return pNewStaEntry;
15196}
Jeff Johnson295189b2012-06-20 16:38:30 -070015197eHalStatus csrGetRssi(tpAniSirGlobal pMac,
15198 tCsrRssiCallback callback,
15199 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
15200{
15201 eHalStatus status = eHAL_STATUS_SUCCESS;
15202 vos_msg_t msg;
15203 tANI_U32 sessionId;
15204
15205 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015206 smsLog(pMac, LOG2, FL("called"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015207 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
15208 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070015209 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015210 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053015211 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015212 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015213 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
15214
15215 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
15216 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
15217 pMsg->sessionId = sessionId;
15218 pMsg->staId = staId;
15219 pMsg->rssiCallback = callback;
15220 pMsg->pDevContext = pContext;
15221 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070015222 msg.type = eWNI_SME_GET_RSSI_REQ;
15223 msg.bodyptr = pMsg;
15224 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015225 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
15226 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015227 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053015228 vos_mem_free((void *)pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015229 status = eHAL_STATUS_FAILURE;
15230 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015231 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015232 return status;
15233}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015234
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015235eHalStatus csrGetSnr(tpAniSirGlobal pMac,
15236 tCsrSnrCallback callback,
15237 tANI_U8 staId, tCsrBssid bssId,
15238 void *pContext)
15239{
15240 eHalStatus status = eHAL_STATUS_SUCCESS;
15241 vos_msg_t msg;
15242 tANI_U32 sessionId;
15243
15244 tAniGetSnrReq *pMsg;
15245
15246 smsLog(pMac, LOG2, FL("called"));
15247
15248 pMsg =(tAniGetSnrReq *)vos_mem_malloc(sizeof(tAniGetSnrReq));
15249 if (NULL == pMsg )
15250 {
15251 smsLog(pMac, LOGE, "%s: failed to allocate mem for req",__func__);
15252 return status;
15253 }
15254
15255 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
15256
15257 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_SNR_REQ);
15258 pMsg->msgLen = (tANI_U16)sizeof(tAniGetSnrReq);
15259 pMsg->sessionId = sessionId;
15260 pMsg->staId = staId;
15261 pMsg->snrCallback = callback;
15262 pMsg->pDevContext = pContext;
15263 msg.type = eWNI_SME_GET_SNR_REQ;
15264 msg.bodyptr = pMsg;
15265 msg.reserved = 0;
15266
15267 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
15268 {
15269 smsLog(pMac, LOGE, "%s failed to post msg to self", __func__);
15270 vos_mem_free((v_VOID_t *)pMsg);
15271 status = eHAL_STATUS_FAILURE;
15272 }
15273
15274 smsLog(pMac, LOG2, FL("returned"));
15275 return status;
15276}
15277
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015278#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015279eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
15280 tCsrRssiCallback callback,
15281 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
15282{
15283 eHalStatus status = eHAL_STATUS_SUCCESS;
15284 tAniGetRssiReq *pMsg;
15285
Kiet Lam64c1b492013-07-12 13:56:44 +053015286 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
15287 if ( NULL == pMsg )
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015288 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015289 smsLog(pMac, LOGE, FL("Failed to allocate mem for req"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015290 return eHAL_STATUS_FAILURE;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015291 }
15292 // need to initiate a stats request to PE
15293 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
15294 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
15295 pMsg->staId = staId;
15296 pMsg->rssiCallback = callback;
15297 pMsg->pDevContext = pContext;
15298 pMsg->pVosContext = pVosContext;
15299 status = palSendMBMessage(pMac->hHdd, pMsg );
15300 if(!HAL_STATUS_SUCCESS(status))
15301 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015302 smsLog(pMac, LOGE, FL(" Failed to send down get rssi req"));
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070015303 //pMsg is freed by palSendMBMessage
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015304 status = eHAL_STATUS_FAILURE;
15305 }
15306 return status;
15307}
15308#endif
15309
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015310
15311
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015312#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015313eHalStatus csrGetTsmStats(tpAniSirGlobal pMac,
15314 tCsrTsmStatsCallback callback,
15315 tANI_U8 staId,
15316 tCsrBssid bssId,
15317 void *pContext,
15318 void* pVosContext,
15319 tANI_U8 tid)
15320{
15321 eHalStatus status = eHAL_STATUS_SUCCESS;
15322 tAniGetTsmStatsReq *pMsg = NULL;
15323
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015324 pMsg = (tAniGetTsmStatsReq*)vos_mem_malloc(sizeof(tAniGetTsmStatsReq));
15325 if (NULL == pMsg)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015326 {
15327 smsLog(pMac, LOGE, "csrGetTsmStats: failed to allocate mem for req");
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015328 return eHAL_STATUS_FAILED_ALLOC;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015329 }
15330 // need to initiate a stats request to PE
15331 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_TSM_STATS_REQ);
15332 pMsg->msgLen = (tANI_U16)sizeof(tAniGetTsmStatsReq);
15333 pMsg->staId = staId;
15334 pMsg->tid = tid;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015335 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015336 pMsg->tsmStatsCallback = callback;
15337 pMsg->pDevContext = pContext;
15338 pMsg->pVosContext = pVosContext;
15339 status = palSendMBMessage(pMac->hHdd, pMsg );
15340 if(!HAL_STATUS_SUCCESS(status))
15341 {
15342 smsLog(pMac, LOG1, " csrGetTsmStats: failed to send down the rssi req");
15343 //pMsg is freed by palSendMBMessage
15344 status = eHAL_STATUS_FAILURE;
15345 }
15346 return status;
15347}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015348#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015349
15350
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053015351/* ---------------------------------------------------------------------------
15352 \fn csrGetTLSTAState
15353 \helper function to get teh TL STA State whenever the function is called.
15354
15355 \param staId - The staID to be passed to the TL
15356 to get the relevant TL STA State
15357 \return the state as tANI_U16
15358 ---------------------------------------------------------------------------*/
15359tANI_U16 csrGetTLSTAState(tpAniSirGlobal pMac, tANI_U8 staId)
15360{
15361 WLANTL_STAStateType tlSTAState;
15362 tlSTAState = WLANTL_STA_INIT;
15363
15364 //request TL for STA State
15365 if ( !VOS_IS_STATUS_SUCCESS(WLANTL_GetSTAState(pMac->roam.gVosContext, staId, &tlSTAState)) )
15366 {
15367 smsLog(pMac, LOGE, FL("csrGetTLSTAState:couldn't get the STA state from TL"));
15368 }
15369
15370 return tlSTAState;
15371}
15372
Jeff Johnson295189b2012-06-20 16:38:30 -070015373eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
15374 tANI_U32 statsMask,
15375 tCsrStatsCallback callback,
15376 tANI_U32 periodicity, tANI_BOOLEAN cache,
15377 tANI_U8 staId, void *pContext)
15378{
15379 tCsrStatsClientReqInfo staEntry;
15380 tCsrStatsClientReqInfo *pStaEntry = NULL;
15381 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
15382 tListElem *pEntry = NULL;
15383 tANI_BOOLEAN found = FALSE;
15384 eHalStatus status = eHAL_STATUS_SUCCESS;
15385 tANI_BOOLEAN insertInClientList = FALSE;
15386 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070015387 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070015388
15389 if( csrIsAllSessionDisconnected(pMac) )
15390 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015391 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070015392 return eHAL_STATUS_FAILURE;
15393 }
Hanumantha Reddy Pothula449aadf2014-02-07 13:53:35 +053015394
15395 if (csrNeighborMiddleOfRoaming((tHalHandle)pMac))
15396 {
15397 smsLog(pMac, LOG1, FL("in the middle of roaming states"));
15398 return eHAL_STATUS_FAILURE;
15399 }
15400
Jeff Johnson295189b2012-06-20 16:38:30 -070015401 if((!statsMask) && (!callback))
15402 {
15403 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015404 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070015405 return eHAL_STATUS_FAILURE;
15406 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015407 //for the search list method for deregister
15408 staEntry.requesterId = requesterId;
15409 staEntry.statsMask = statsMask;
15410 //requester wants to deregister or just an error
15411 if((statsMask) && (!callback))
15412 {
15413 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
15414 if(!pEntry)
15415 {
15416 //msg
15417 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015418 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015419 return eHAL_STATUS_FAILURE;
15420 }
15421 else
15422 {
15423 //clean up & return
15424 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070015425 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015426 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015427 pStaEntry->pPeStaEntry->numClient--;
15428 //check if we need to delete the entry from peStatsReqList too
15429 if(!pStaEntry->pPeStaEntry->numClient)
15430 {
15431 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
15432 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015433 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070015434
Jeff Johnson295189b2012-06-20 16:38:30 -070015435 //check if we need to stop the tl stats timer too
15436 pMac->roam.tlStatsReqInfo.numClient--;
15437 if(!pMac->roam.tlStatsReqInfo.numClient)
15438 {
15439 if(pMac->roam.tlStatsReqInfo.timerRunning)
15440 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015441 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
15442 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015443 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015444 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015445 return eHAL_STATUS_FAILURE;
15446 }
15447 }
15448 pMac->roam.tlStatsReqInfo.periodicity = 0;
15449 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
15450 }
15451 vos_timer_stop( &pStaEntry->timer );
Jeff Johnson295189b2012-06-20 16:38:30 -070015452 // Destroy the vos timer...
15453 vosStatus = vos_timer_destroy( &pStaEntry->timer );
15454 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15455 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015456 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to destroy Client req timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015457 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015458 csrRoamRemoveStatListEntry(pMac, pEntry);
15459 pStaEntry = NULL;
15460 return eHAL_STATUS_SUCCESS;
15461 }
15462 }
15463
15464 if(cache && !periodicity)
15465 {
15466 //return the cached stats
15467 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15468 }
15469 else
15470 {
15471 //add the request in the client req list
15472 staEntry.callback = callback;
15473 staEntry.pContext = pContext;
15474 staEntry.periodicity = periodicity;
15475 staEntry.pPeStaEntry = NULL;
15476 staEntry.staId = staId;
15477 staEntry.pMac = pMac;
15478 staEntry.timerExpired = FALSE;
15479
15480
Jeff Johnson295189b2012-06-20 16:38:30 -070015481 //if periodic report requested with non cached result from PE/TL
15482 if(periodicity)
15483 {
15484
15485 //if looking for stats from PE
15486 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15487 {
15488
15489 //check if same request made already & waiting for rsp
15490 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
15491 periodicity, &found, staId);
15492 if(!pPeStaEntry)
15493 {
15494 //bail out, maxed out on number of req for PE
15495 return eHAL_STATUS_FAILURE;
15496 }
15497 else
15498 {
15499 staEntry.pPeStaEntry = pPeStaEntry;
15500 }
15501
15502 }
15503 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
15504 if(statsMask & (1 << eCsrGlobalClassDStats))
15505 {
15506 if(cache && pMac->roam.tlStatsReqInfo.numClient)
15507 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015508 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015509 }
15510 else
15511 {
15512
15513 //update periodicity
15514 if(pMac->roam.tlStatsReqInfo.periodicity)
15515 {
15516 pMac->roam.tlStatsReqInfo.periodicity =
15517 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
15518 }
15519 else
15520 {
15521 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
15522 }
15523 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
15524 {
15525 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
15526 }
15527
15528 if(!pMac->roam.tlStatsReqInfo.timerRunning)
15529 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015530 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015531 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015532 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015533 //req TL for class D stats
15534 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
15535 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015536 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015537 }
15538 else
15539 {
15540 //save in SME
15541 csrRoamSaveStatsFromTl(pMac, pTlStats);
15542 }
15543 vos_mem_free(pTlStats);
15544 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015545 }
15546 else
15547 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015548 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015549 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015550
Jeff Johnson295189b2012-06-20 16:38:30 -070015551 if(pMac->roam.tlStatsReqInfo.periodicity)
15552 {
15553 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015554 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
15555 pMac->roam.tlStatsReqInfo.periodicity);
15556 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015557 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015558 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015559 return eHAL_STATUS_FAILURE;
15560 }
15561 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
15562 }
15563 }
15564 }
15565 pMac->roam.tlStatsReqInfo.numClient++;
15566 }
15567
15568 insertInClientList = TRUE;
15569 }
15570 //if one time report requested with non cached result from PE/TL
15571 else if(!cache && !periodicity)
15572 {
15573 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15574 {
15575 //send down a req
15576 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
15577 if(!HAL_STATUS_SUCCESS(status))
15578 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015579 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015580 }
15581 //so that when the stats rsp comes back from PE we respond to upper layer
15582 //right away
15583 staEntry.timerExpired = TRUE;
15584 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015585 }
15586 if(statsMask & (1 << eCsrGlobalClassDStats))
15587 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015588 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015589 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015590 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015591 //req TL for class D stats
15592 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
15593 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015594 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015595 }
15596 else
15597 {
15598 //save in SME
15599 csrRoamSaveStatsFromTl(pMac, pTlStats);
15600 }
15601 vos_mem_free(pTlStats);
15602 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015603 }
15604 else
15605 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015606 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015607 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015608
15609 }
15610 //if looking for stats from TL only
15611 if(!insertInClientList)
15612 {
15613 //return the stats
15614 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15615 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015616 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015617 if(insertInClientList)
15618 {
15619 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
15620 if(!pStaEntry)
15621 {
15622 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015623 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015624 return eHAL_STATUS_FAILURE;
15625 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015626 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070015627 //Init & start timer if needed
15628 if(periodicity)
15629 {
15630 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
15631 csrRoamStatsClientTimerHandler, pStaEntry );
15632 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15633 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015634 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015635 return eHAL_STATUS_FAILURE;
15636 }
15637 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
15638 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15639 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015640 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015641 return eHAL_STATUS_FAILURE;
15642 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015643 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015644 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015645 }
15646 return eHAL_STATUS_SUCCESS;
15647}
15648
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015649#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
15650
15651static tSirRetStatus
15652csrRoamScanOffloadPopulateMacHeader(tpAniSirGlobal pMac,
15653 tANI_U8* pBD,
15654 tANI_U8 type,
15655 tANI_U8 subType,
15656 tSirMacAddr peerAddr,
15657 tSirMacAddr selfMacAddr)
15658{
15659 tSirRetStatus statusCode = eSIR_SUCCESS;
15660 tpSirMacMgmtHdr pMacHdr;
15661
15662 /* Prepare MAC management header */
15663 pMacHdr = (tpSirMacMgmtHdr) (pBD);
15664
15665 /* Prepare FC */
15666 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
15667 pMacHdr->fc.type = type;
15668 pMacHdr->fc.subType = subType;
15669
15670 /* Prepare Address 1 */
Kiet Lam64c1b492013-07-12 13:56:44 +053015671 vos_mem_copy((tANI_U8 *) pMacHdr->da, (tANI_U8 *) peerAddr,
15672 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015673
15674 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
15675
15676 /* Prepare Address 3 */
Kiet Lam64c1b492013-07-12 13:56:44 +053015677 vos_mem_copy((tANI_U8 *) pMacHdr->bssId, (tANI_U8 *) peerAddr,
15678 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015679 return statusCode;
15680} /*** csrRoamScanOffloadPopulateMacHeader() ***/
15681
15682static tSirRetStatus
15683csrRoamScanOffloadPrepareProbeReqTemplate(tpAniSirGlobal pMac,
15684 tANI_U8 nChannelNum,
15685 tANI_U32 dot11mode,
15686 tSirMacAddr selfMacAddr,
15687 tANI_U8 *pFrame,
15688 tANI_U16 *pusLen)
15689{
15690 tDot11fProbeRequest pr;
15691 tANI_U32 nStatus, nBytes, nPayload;
15692 tSirRetStatus nSirStatus;
15693 /*Bcast tx*/
15694 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
15695 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
15696
15697
Kiet Lam64c1b492013-07-12 13:56:44 +053015698 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015699
15700 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
15701
15702 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
15703 {
15704 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
15705 }
15706
15707
15708 if (IS_DOT11_MODE_HT(dot11mode))
15709 {
15710 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
15711 }
15712
15713
15714 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
15715 if ( DOT11F_FAILED( nStatus ) )
15716 {
15717 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15718 "Failed to calculate the packed size f"
15719 "or a Probe Request (0x%08x).\n", nStatus );
15720
15721
15722 nPayload = sizeof( tDot11fProbeRequest );
15723 }
15724 else if ( DOT11F_WARNED( nStatus ) )
15725 {
15726 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15727 "There were warnings while calculating"
15728 "the packed size for a Probe Request ("
15729 "0x%08x).\n", nStatus );
15730 }
15731
15732 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
15733
15734 /* Prepare outgoing frame*/
Kiet Lam64c1b492013-07-12 13:56:44 +053015735 vos_mem_set(pFrame, nBytes , 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015736
15737
15738 nSirStatus = csrRoamScanOffloadPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015739 SIR_MAC_MGMT_PROBE_REQ, bssId,selfMacAddr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015740
15741 if ( eSIR_SUCCESS != nSirStatus )
15742 {
15743 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15744 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
15745 nSirStatus );
15746 return nSirStatus;
15747 }
15748
15749
15750 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
15751 sizeof( tSirMacMgmtHdr ),
15752 nPayload, &nPayload );
15753 if ( DOT11F_FAILED( nStatus ) )
15754 {
15755 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15756 "Failed to pack a Probe Request (0x%08x).\n", nStatus );
15757 return eSIR_FAILURE;
15758 }
15759 else if ( DOT11F_WARNED( nStatus ) )
15760 {
15761 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce8ad512013-10-30 12:34:42 -070015762 "There were warnings while packing a Probe Request (0x%08x).\n",
15763 nStatus );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015764 }
15765
15766 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
15767 return eSIR_SUCCESS;
15768}
15769
15770eHalStatus csrRoamOffloadScan(tpAniSirGlobal pMac, tANI_U8 command, tANI_U8 reason)
15771{
15772 vos_msg_t msg;
15773 tSirRoamOffloadScanReq *pRequestBuf;
15774 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
15775 tCsrRoamSession *pSession;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015776 tANI_U8 i,j,num_channels = 0, ucDot11Mode;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015777 tANI_U8 *ChannelList = NULL;
15778 tANI_U32 sessionId;
15779 eHalStatus status = eHAL_STATUS_SUCCESS;
15780 tpCsrChannelInfo currChannelListInfo;
Srinivas Girigowda56076852013-08-20 14:00:50 -070015781 tANI_U32 host_channels = 0;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015782 tANI_U8 ChannelCacheStr[128] = {0};
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015783 eCsrBand eBand;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015784 tSirBssDescription *pBssDesc = NULL;
15785 tDot11fBeaconIEs *pIes = NULL;
15786 tANI_U8 minRate = 0, dataRate;
Varun Reddy Yeturu52231ea2014-02-06 12:00:56 -080015787 tANI_U8 operationChannel = 0;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015788
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015789 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
15790
Srinivas Girigowda830bbd02013-06-13 19:44:16 -070015791 if (0 == csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015792 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015793 smsLog( pMac, LOGE,"isRoamOffloadScanEnabled not set");
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015794 return eHAL_STATUS_FAILURE;
15795 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015796
15797 if ((VOS_TRUE == bRoamScanOffloadStarted) && (ROAM_SCAN_OFFLOAD_START == command))
15798 {
15799 smsLog( pMac, LOGE,"Roam Scan Offload is already started");
15800 return eHAL_STATUS_FAILURE;
15801 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015802 status = csrRoamGetSessionIdFromBSSID(pMac,
15803 (tCsrBssid *)pNeighborRoamInfo->currAPbssid,
15804 &sessionId);
15805 /*The Dynamic Config Items Update may happen even if the state is in INIT.
15806 * It is important to ensure that the command is passed down to the FW only
15807 * if the Infra Station is in a connected state.A connected station could also be
15808 * in a PREAUTH or REASSOC states.So, consider not sending the command down in INIT state.
15809 * We also have to ensure that if there is a STOP command we always have to inform Riva,
15810 * irrespective of whichever state we are in.*/
15811 if ((pMac->roam.neighborRoamInfo.neighborRoamState == eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
15812 (command != ROAM_SCAN_OFFLOAD_STOP))
15813 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053015814 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
15815 FL("Scan Command not sent to FW with state = %s and cmd=%d\n"),
15816 macTraceGetNeighbourRoamState(
15817 pMac->roam.neighborRoamInfo.neighborRoamState), command);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015818 return eHAL_STATUS_FAILURE;
15819 }
15820
15821 if ( !HAL_STATUS_SUCCESS( status ) )
15822 {
15823 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to find the sessionId for Roam Offload scan request", __func__);
15824 return eHAL_STATUS_FAILURE;
15825 }
15826 pSession = CSR_GET_SESSION( pMac, sessionId );
krunal soni587bf012014-02-04 12:35:11 -080015827 if (NULL == pSession)
15828 {
15829 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15830 "%s:pSession is null", __func__);
15831 return eHAL_STATUS_FAILURE;
15832 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015833 pBssDesc = pSession->pConnectBssDesc;
15834 if (pBssDesc == NULL)
15835 {
15836 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: pBssDesc not found for current session", __func__);
15837 return eHAL_STATUS_FAILURE;
15838 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015839 pRequestBuf = vos_mem_malloc(sizeof(tSirRoamOffloadScanReq));
15840 if (NULL == pRequestBuf)
15841 {
15842 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to allocate memory for Roam Offload scan request", __func__);
15843 return eHAL_STATUS_FAILED_ALLOC;
15844 }
15845
Kiet Lam64c1b492013-07-12 13:56:44 +053015846 vos_mem_zero(pRequestBuf, sizeof(tSirRoamOffloadScanReq));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015847 /* If command is STOP, then pass down ScanOffloadEnabled as Zero.This will handle the case of
15848 * host driver reloads, but Riva still up and running*/
Mukul Sharma90506b42014-04-24 13:24:12 +053015849 pRequestBuf->Command = command;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015850 if(command == ROAM_SCAN_OFFLOAD_STOP)
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015851 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015852 pRequestBuf->RoamScanOffloadEnabled = 0;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015853 /*For a STOP Command, there is no need to
15854 * go through filling up all the below parameters
15855 * since they are not required for the STOP command*/
15856 goto send_roam_scan_offload_cmd;
15857 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015858 else
15859 pRequestBuf->RoamScanOffloadEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
Kiet Lam64c1b492013-07-12 13:56:44 +053015860 vos_mem_copy(pRequestBuf->ConnectedNetwork.currAPbssid,
15861 pNeighborRoamInfo->currAPbssid,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015862 sizeof(tCsrBssid));
15863 pRequestBuf->ConnectedNetwork.ssId.length =
15864 pMac->roam.roamSession[sessionId].connectedProfile.SSID.length;
15865 vos_mem_copy(pRequestBuf->ConnectedNetwork.ssId.ssId,
15866 pMac->roam.roamSession[sessionId].connectedProfile.SSID.ssId,
15867 pRequestBuf->ConnectedNetwork.ssId.length);
15868 pRequestBuf->ConnectedNetwork.authentication =
15869 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
15870 pRequestBuf->ConnectedNetwork.encryption =
15871 pMac->roam.roamSession[sessionId].connectedProfile.EncryptionType;
15872 pRequestBuf->ConnectedNetwork.mcencryption =
15873 pMac->roam.roamSession[sessionId].connectedProfile.mcEncryptionType;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015874 if (pNeighborRoamInfo->cfgParams.neighborLookupThreshold)
15875 {
15876 pRequestBuf->LookupThreshold =
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015877 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborLookupThreshold * (-1);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015878 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
15879 }
15880 else
15881 {
15882 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Calculate Adaptive Threshold");
15883 operationChannel = pSession->connectedProfile.operationChannel;
15884
15885 if (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
15886 {
15887 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15888 "%s: csrGetParsedBssDescriptionIEs failed", __func__);
15889 vos_mem_free(pRequestBuf);
15890 return eHAL_STATUS_FAILURE;
15891 }
Kaushik, Sushant5874d032014-02-20 17:22:36 +053015892 if(NULL == pIes)
15893 {
15894 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15895 "%s : pIes is Null", __func__);
15896 return eHAL_STATUS_FAILURE;
15897 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015898 if (pIes->SuppRates.present)
15899 {
15900 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Number \t Rate");
15901 /*Check for both basic rates and extended rates.*/
15902 for (i = 0; i < pIes->SuppRates.num_rates; i++)
15903 {
15904 /*Check if the Rate is Mandatory or Not*/
15905 if (csrRatesIsDot11RateSupported(pMac, pIes->SuppRates.rates[i])
15906 && (pIes->SuppRates.rates[i] & 0x80))
15907 {
15908 /*Retrieve the actual data rate*/
15909 dataRate = (pIes->SuppRates.rates[i] & 0x7F)/2;
15910 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
15911 if (minRate == 0)
15912 minRate = dataRate;
15913 else
15914 minRate = (minRate < dataRate) ? minRate:dataRate;
15915 }
15916 }
15917
15918 if (pIes->ExtSuppRates.present)
15919 {
15920 for (i = 0; i < pIes->ExtSuppRates.num_rates; i++)
15921 {
15922 /*Check if the Rate is Mandatory or Not*/
15923 if (csrRatesIsDot11RateSupported(pMac, pIes->ExtSuppRates.rates[i])
15924 && (pIes->ExtSuppRates.rates[i] & 0x80))
15925 {
15926 /*Retrieve the actual data rate*/
15927 dataRate = (pIes->ExtSuppRates.rates[i] & 0x7F)/2;
15928 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
15929 if (minRate == 0)
15930 minRate = dataRate;
15931 else
15932 minRate = (minRate < dataRate) ? minRate:dataRate;
15933 }
15934 }
15935 }
15936 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "MinRate = %d", minRate);
15937 }
15938 else
15939 {
15940 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15941 "%s: Supp Rates not present in pIes", __func__);
15942 vos_mem_free(pRequestBuf);
15943 return eHAL_STATUS_FAILURE;
15944 }
15945 if (NULL != pIes)
15946 {
15947 vos_mem_free(pIes);
15948 pIes = NULL;
15949 }
15950 switch (minRate)
15951 {
15952 case 1:
15953 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_1MBPS;
15954 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_1MBPS;
15955 break;
15956 case 2:
15957 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_2MBPS;
15958 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_2MBPS;
15959 break;
15960 case 5:
15961 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_5_5MBPS;
15962 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_5_5MBPS;
15963 break;
15964 case 6:
15965 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
15966 {
15967 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_2G;
15968 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_2G;
15969 }
15970 else
15971 {
15972 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_5G;
15973 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_5G;
15974 }
15975 break;
15976 case 11:
15977 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_11MBPS;
15978 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_11MBPS;
15979 break;
15980 case 12:
15981 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
15982 {
15983 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_2G;
15984 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_2G;
15985 }
15986 else
15987 {
15988 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_5G;
15989 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_5G;
15990 }
15991 break;
15992 case 24:
15993 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
15994 {
15995 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_2G;
15996 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_2G;
15997 }
15998 else
15999 {
16000 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_5G;
16001 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_5G;
16002 }
16003 break;
16004 default:
16005 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_DEFAULT;
16006 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
16007 break;
16008 }
16009 }
16010 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
16011 "Chnl=%d,MinRate=%d,RxSenThr=%d,LookupThr=%d",
16012 operationChannel, minRate,
16013 pRequestBuf->RxSensitivityThreshold,
16014 pRequestBuf->LookupThreshold);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016015 pRequestBuf->RoamRssiDiff =
16016 pMac->roam.configParam.RoamRssiDiff;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016017 pRequestBuf->StartScanReason = reason;
16018 pRequestBuf->NeighborScanTimerPeriod =
16019 pNeighborRoamInfo->cfgParams.neighborScanPeriod;
16020 pRequestBuf->NeighborRoamScanRefreshPeriod =
16021 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod;
16022 pRequestBuf->NeighborScanChannelMinTime =
16023 pNeighborRoamInfo->cfgParams.minChannelScanTime;
16024 pRequestBuf->NeighborScanChannelMaxTime =
16025 pNeighborRoamInfo->cfgParams.maxChannelScanTime;
16026 pRequestBuf->EmptyRefreshScanPeriod =
16027 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -080016028 /* MAWC feature */
16029 pRequestBuf->MAWCEnabled =
16030 pMac->roam.configParam.MAWCEnabled;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016031#ifdef FEATURE_WLAN_ESE
16032 pRequestBuf->IsESEEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016033#endif
16034 if (
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016035#ifdef FEATURE_WLAN_ESE
16036 ((pNeighborRoamInfo->isESEAssoc) &&
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016037 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived ==
16038 eANI_BOOLEAN_FALSE)) ||
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016039 (pNeighborRoamInfo->isESEAssoc == eANI_BOOLEAN_FALSE) ||
16040#endif // ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016041 currChannelListInfo->numOfChannels == 0)
16042 {
16043
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016044 /*Retrieve the Channel Cache either from ini or from the Occupied Channels list.
16045 * Give Preference to INI Channels.*/
16046 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
16047 {
16048 ChannelList = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
16049 /*The INI channels need to be filtered with respect to the current
16050 * band that is supported.*/
16051 eBand = pMac->roam.configParam.bandCapability;
16052 if ((eCSR_BAND_24 != eBand) && (eCSR_BAND_5G != eBand) && (eCSR_BAND_ALL != eBand))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016053 {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016054 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16055 "Invalid band, No operation carried out (Band %d)", eBand);
16056 vos_mem_free(pRequestBuf);
16057 return eHAL_STATUS_FAILURE;
16058 }
16059 for (i=0; i<pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels; i++)
16060 {
16061 if(((eCSR_BAND_24 == eBand) && CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
16062 ((eCSR_BAND_5G == eBand) && CSR_IS_CHANNEL_5GHZ(*ChannelList)) ||
16063 (eCSR_BAND_ALL == eBand))
16064 {
16065 if(!CSR_IS_CHANNEL_DFS(*ChannelList) &&
16066 csrRoamIsChannelValid(pMac, *ChannelList) &&
16067 *ChannelList && (num_channels < SIR_ROAM_MAX_CHANNELS))
16068 {
16069 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
16070 }
16071 }
16072 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016073 }
16074 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16075 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016076 }
16077 else
16078 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016079 ChannelList = pMac->scan.occupiedChannels.channelList;
16080 for(i=0; i<pMac->scan.occupiedChannels.numChannels; i++)
16081 {
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053016082 /*Allow DFS channels only if the DFS channel roam flag is enabled */
16083 if(((pMac->roam.configParam.allowDFSChannelRoam) ||
16084 (!CSR_IS_CHANNEL_DFS(*ChannelList))) &&
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016085 *ChannelList && (num_channels < SIR_ROAM_MAX_CHANNELS))
16086 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016087 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016088 }
16089 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016090 }
16091 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16092 /* If the profile changes as to what it was earlier, inform the FW through
16093 * FLUSH as ChannelCacheType in which case, the FW will flush the occupied channels
16094 * for the earlier profile and try to learn them afresh.*/
16095 if (reason == REASON_FLUSH_CHANNEL_LIST)
16096 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
16097 else {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016098 if (csrNeighborRoamIsNewConnectedProfile(pMac))
16099 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
16100 else
16101 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016102 }
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016103 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016104 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016105#ifdef FEATURE_WLAN_ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016106 else
16107 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016108 /* If ESE is enabled, and a neighbor Report is received,then
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016109 * Ignore the INI Channels or the Occupied Channel List. Consider
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016110 * the channels in the neighbor list sent by the ESE AP.*/
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016111 if (currChannelListInfo->numOfChannels != 0)
16112 {
16113 ChannelList = currChannelListInfo->ChannelList;
16114 for (i=0;i<currChannelListInfo->numOfChannels;i++)
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016115 {
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053016116 if(((pMac->roam.configParam.allowDFSChannelRoam) ||
16117 (!CSR_IS_CHANNEL_DFS(*ChannelList))) && *ChannelList)
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016118 {
16119 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
16120 }
16121 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016122 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016123 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16124 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
16125 }
16126 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016127#endif
Kaushik, Sushant5ed8ab62014-03-05 11:21:11 +053016128 for (i = 0, j = 0;j < (sizeof(ChannelCacheStr)/sizeof(ChannelCacheStr[0])) && i < pRequestBuf->ConnectedNetwork.ChannelCount; i++)
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016129 {
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053016130 if (j < sizeof(ChannelCacheStr))
16131 {
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016132 j += snprintf(ChannelCacheStr + j, sizeof(ChannelCacheStr) - j," %d",
16133 pRequestBuf->ConnectedNetwork.ChannelCache[i]);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053016134 }
16135 else
16136 {
16137 break;
16138 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016139 }
16140 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
16141 "ChnlCacheType:%d, No of Chnls:%d,Channels: %s",
16142 pRequestBuf->ChannelCacheType,
16143 pRequestBuf->ConnectedNetwork.ChannelCount,
16144 ChannelCacheStr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016145 num_channels = 0;
16146 ChannelList = NULL;
16147
16148 /* Maintain the Valid Channels List*/
Srinivas Girigowda56076852013-08-20 14:00:50 -070016149 host_channels = sizeof(pMac->roam.validChannelList);
16150 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &host_channels)))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016151 {
Srinivas Girigowda56076852013-08-20 14:00:50 -070016152 ChannelList = pMac->roam.validChannelList;
16153 pMac->roam.numValidChannels = host_channels;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016154 }
Srinivas Girigowda56076852013-08-20 14:00:50 -070016155 else
16156 {
16157 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16158 "%s:Failed to get the valid channel list", __func__);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -070016159 vos_mem_free(pRequestBuf);
Srinivas Girigowda56076852013-08-20 14:00:50 -070016160 return eHAL_STATUS_FAILURE;
16161 }
16162 for(i=0; i<pMac->roam.numValidChannels; i++)
16163 {
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053016164 if(((pMac->roam.configParam.allowDFSChannelRoam) ||
16165 (!CSR_IS_CHANNEL_DFS(*ChannelList))) && *ChannelList)
Srinivas Girigowda56076852013-08-20 14:00:50 -070016166 {
16167 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
16168 }
16169 ChannelList++;
16170 }
16171 pRequestBuf->ValidChannelCount = num_channels;
16172
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016173 pRequestBuf->MDID.mdiePresent =
16174 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent;
16175 pRequestBuf->MDID.mobilityDomain =
16176 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mobilityDomain;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016177 pRequestBuf->nProbes = pMac->roam.configParam.nProbes;
16178
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016179 pRequestBuf->HomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016180 /* Home Away Time should be at least equal to (MaxDwell time + (2*RFS)),
16181 * where RFS is the RF Switching time. It is twice RFS to consider the
16182 * time to go off channel and return to the home channel. */
16183 if (pRequestBuf->HomeAwayTime < (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)))
16184 {
16185 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
16186 "%s: Invalid config, Home away time(%d) is less than (twice RF switching time + channel max time)(%d)"
16187 " Hence enforcing home away time to disable (0)",
16188 __func__, pRequestBuf->HomeAwayTime,
16189 (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)));
16190 pRequestBuf->HomeAwayTime = 0;
16191 }
16192 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,"HomeAwayTime:%d",pRequestBuf->HomeAwayTime);
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070016193
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016194 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
16195 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
16196 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
16197 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_24G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
16198 pRequestBuf->p24GProbeTemplate, &pRequestBuf->us24GProbeTemplateLen);
16199
16200 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_5G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
16201 pRequestBuf->p5GProbeTemplate, &pRequestBuf->us5GProbeTemplateLen);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016202send_roam_scan_offload_cmd:
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016203 msg.type = WDA_ROAM_SCAN_OFFLOAD_REQ;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016204 msg.reserved = 0;
16205 msg.bodyptr = pRequestBuf;
16206 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
16207 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016208 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_ROAM_SCAN_OFFLOAD_REQ message to WDA", __func__);
16209 vos_mem_free(pRequestBuf);
16210 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016211 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016212 else
16213 {
16214 if (ROAM_SCAN_OFFLOAD_START == command)
16215 bRoamScanOffloadStarted = VOS_TRUE;
16216 else if (ROAM_SCAN_OFFLOAD_STOP == command)
16217 bRoamScanOffloadStarted = VOS_FALSE;
16218 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016219
16220 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Roam Scan Offload Command %d, Reason %d", command, reason);
16221 return status;
16222}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016223
16224eHalStatus csrRoamOffloadScanRspHdlr(tpAniSirGlobal pMac, tANI_U8 reason)
16225{
16226 switch(reason)
16227 {
16228 case 0:
16229 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with failure status");
16230 break;
16231 case REASON_OS_REQUESTED_ROAMING_NOW:
16232 csrNeighborRoamProceedWithHandoffReq(pMac);
16233 break;
16234 default:
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -070016235 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 -070016236 }
16237 return eHAL_STATUS_SUCCESS;
16238}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016239#endif
16240
Jeff Johnson295189b2012-06-20 16:38:30 -070016241tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
16242 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
16243{
16244 tANI_BOOLEAN found = FALSE;
16245 eHalStatus status = eHAL_STATUS_SUCCESS;
16246 tCsrPeStatsReqInfo staEntry;
16247 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
16248 tListElem *pStaEntry = NULL;
16249 VOS_STATUS vosStatus;
16250 tPmcPowerState powerState;
16251 *pFound = FALSE;
16252
16253 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
16254 if(pStaEntry)
16255 {
16256 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
16257 if(pTempStaEntry->periodicity)
16258 {
16259 pTempStaEntry->periodicity =
16260 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
16261 }
16262 else
16263 {
16264 pTempStaEntry->periodicity = periodicity;
16265 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016266 pTempStaEntry->numClient++;
16267 found = TRUE;
16268 }
16269 else
16270 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016271 vos_mem_set(&staEntry, sizeof(tCsrPeStatsReqInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016272 staEntry.numClient = 1;
16273 staEntry.periodicity = periodicity;
16274 staEntry.pMac = pMac;
16275 staEntry.rspPending = FALSE;
16276 staEntry.staId = staId;
16277 staEntry.statsMask = statsMask;
16278 staEntry.timerRunning = FALSE;
16279 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
16280 if(!pTempStaEntry)
16281 {
16282 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016283 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070016284 return NULL;
16285 }
16286 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016287 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
16288 if(ePMC_FULL_POWER == powerState)
16289 {
16290 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
16291 {
16292 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
16293 }
16294 }
16295 else
16296 {
16297 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
16298 {
16299 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
16300 }
16301 }
16302 if(!pTempStaEntry->timerRunning)
16303 {
16304 //send down a req in case of one time req, for periodic ones wait for timer to expire
16305 if(!pTempStaEntry->rspPending &&
16306 !pTempStaEntry->periodicity)
16307 {
16308 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
16309 if(!HAL_STATUS_SUCCESS(status))
16310 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016311 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016312 }
16313 else
16314 {
16315 pTempStaEntry->rspPending = TRUE;
16316 }
16317 }
16318 if(pTempStaEntry->periodicity)
16319 {
16320 if(!found)
16321 {
16322
16323 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
16324 csrRoamPeStatsTimerHandler, pTempStaEntry );
16325 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16326 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016327 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016328 return NULL;
16329 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016330 }
16331 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016332 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070016333 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
16334 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16335 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016336 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016337 return NULL;
16338 }
16339 pTempStaEntry->timerRunning = TRUE;
16340 }
16341 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016342 *pFound = found;
16343 return pTempStaEntry;
16344}
16345
Jeff Johnson295189b2012-06-20 16:38:30 -070016346/*
16347 pStaEntry is no longer invalid upon the return of this function.
16348*/
16349static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
16350{
16351 if(pEntry)
16352 {
16353 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
16354 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016355 vos_mem_free(GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070016356 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016357 }
16358 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016359
16360void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
16361{
16362 tListElem *pEntry;
16363 tCsrPeStatsReqInfo *pTempStaEntry;
16364 VOS_STATUS vosStatus;
16365 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016366 if(!pEntry)
16367 {
16368 //list empty
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016369 smsLog(pMac, LOGE, FL(" List empty, no stats req for PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016370 return;
16371 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016372 while( pEntry )
16373 {
16374 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016375 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
16376 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016377 smsLog(pMac, LOGW, FL("Match found"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016378 if(pTempStaEntry->timerRunning)
16379 {
16380 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
16381 /* If we are not able to stop the timer here, just remove
16382 * the entry from the linked list. Destroy the timer object
16383 * and free the memory in the timer CB
16384 */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016385 if ( vosStatus == VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -070016386 {
16387 /* the timer is successfully stopped */
16388 pTempStaEntry->timerRunning = FALSE;
16389
16390 /* Destroy the timer */
16391 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
16392 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16393 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016394 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016395 }
16396 }
16397 else
16398 {
16399 // the timer could not be stopped. Hence destroy and free the
16400 // memory for the PE stat entry in the timer CB.
16401 pTempStaEntry->timerStopFailed = TRUE;
16402 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016403 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016404
16405 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
16406 {
16407 // Only free the memory if we could stop the timer successfully
16408 if(!pTempStaEntry->timerStopFailed)
16409 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016410 vos_mem_free(pTempStaEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070016411 pTempStaEntry = NULL;
16412 }
16413 break;
16414 }
16415
16416 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
16417 }
16418 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016419 return;
16420}
16421
16422
Jeff Johnsone7245742012-09-05 17:12:55 -070016423void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070016424{
16425
Jeff Johnsone7245742012-09-05 17:12:55 -070016426 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
16427 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
16428 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
16429 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
16430 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
16431 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
16432 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070016433 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070016434 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
16435 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
16436 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
16437 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
16438 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
16439 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070016440 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070016441 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
16442 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070016443
16444}
16445
Jeff Johnson295189b2012-06-20 16:38:30 -070016446void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
16447 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
16448{
16449 tANI_U8 stats[500];
16450 tANI_U8 *pStats = NULL;
16451 tANI_U32 tempMask = 0;
16452 tANI_U8 counter = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016453 if(!callback)
16454 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016455 smsLog(pMac, LOGE, FL("Cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016456 return;
16457 }
16458 if(!statsMask)
16459 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016460 smsLog(pMac, LOGE, FL("Cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016461 return;
16462 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016463 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070016464 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070016465 while(tempMask)
16466 {
16467 if(tempMask & 1)
16468 {
16469 //new stats info from PE, fill up the stats strucutres in PMAC
16470 switch(counter)
16471 {
16472 case eCsrSummaryStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016473 smsLog( pMac, LOG2, FL("Summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016474 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
16475 sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016476 pStats += sizeof(tCsrSummaryStatsInfo);
16477 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016478 case eCsrGlobalClassAStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016479 smsLog( pMac, LOG2, FL("ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016480 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
16481 sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016482 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016483 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016484 case eCsrGlobalClassBStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016485 smsLog( pMac, LOG2, FL("ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016486 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
16487 sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016488 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016489 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016490 case eCsrGlobalClassCStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016491 smsLog( pMac, LOG2, FL("ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016492 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
16493 sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016494 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016495 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016496 case eCsrGlobalClassDStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016497 smsLog( pMac, LOG2, FL("ClassD stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016498 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
16499 sizeof(tCsrGlobalClassDStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016500 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016501 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016502 case eCsrPerStaStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016503 smsLog( pMac, LOG2, FL("PerSta stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016504 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
16505 sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016506 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016507 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016508 default:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016509 smsLog( pMac, LOGE, FL("Unknown stats type and counter %d"), counter);
Jeff Johnson295189b2012-06-20 16:38:30 -070016510 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016511 }
16512 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016513 tempMask >>=1;
16514 counter++;
16515 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016516 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070016517}
16518
Jeff Johnson295189b2012-06-20 16:38:30 -070016519eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
16520{
16521 tListElem *pEntry = NULL;
16522 tListElem *pPrevEntry = NULL;
16523 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
16524 eHalStatus status = eHAL_STATUS_SUCCESS;
16525 VOS_STATUS vosStatus;
16526 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016527 if(!pEntry)
16528 {
16529 //list empty
16530 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016531 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070016532 return status;
16533 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016534 while( pEntry )
16535 {
16536 if(pPrevEntry)
16537 {
16538 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16539 //send up the stats report
16540 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16541 pTempStaEntry->staId, pTempStaEntry->pContext);
16542 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16543 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016544 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016545 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
16546 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016547 pTempStaEntry->pPeStaEntry->numClient--;
16548 //check if we need to delete the entry from peStatsReqList too
16549 if(!pTempStaEntry->pPeStaEntry->numClient)
16550 {
16551 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
16552 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016553 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016554 //check if we need to stop the tl stats timer too
16555 pMac->roam.tlStatsReqInfo.numClient--;
16556 if(!pMac->roam.tlStatsReqInfo.numClient)
16557 {
16558 if(pMac->roam.tlStatsReqInfo.timerRunning)
16559 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016560 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
16561 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016562 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016563 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016564 //we will continue
16565 }
16566 }
16567 pMac->roam.tlStatsReqInfo.periodicity = 0;
16568 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
16569 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016570 if (pTempStaEntry->periodicity)
16571 {
16572 //While creating StaEntry in csrGetStatistics,
16573 //Initializing and starting timer only when periodicity is set.
16574 //So Stop and Destroy timer only when periodicity is set.
16575
Jeff Johnsone7245742012-09-05 17:12:55 -070016576 vos_timer_stop( &pTempStaEntry->timer );
16577 // Destroy the vos timer...
16578 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
16579 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16580 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016581 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070016582 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016583 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016584
Jeff Johnson295189b2012-06-20 16:38:30 -070016585
16586 pPrevEntry = pEntry;
16587 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
16588 }
16589 //the last one
16590 if(pPrevEntry)
16591 {
16592 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16593 //send up the stats report
16594 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16595 pTempStaEntry->staId, pTempStaEntry->pContext);
16596 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16597 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016598 return status;
16599
16600}
16601
Jeff Johnson295189b2012-06-20 16:38:30 -070016602eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
16603 tRequestFullPowerReason *pReason,
16604 tANI_BOOLEAN *pfNeedPower )
16605{
16606 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
16607 tRequestFullPowerReason reason = eSME_REASON_OTHER;
16608 tPmcState pmcState;
16609 eHalStatus status = eHAL_STATUS_SUCCESS;
16610 // TODO : Session info unavailable
16611 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016612 if( pfNeedPower )
16613 {
16614 *pfNeedPower = eANI_BOOLEAN_FALSE;
16615 }
16616 //We only handle CSR commands
16617 if( !(eSmeCsrCommandMask & pCommand->command) )
16618 {
16619 return eHAL_STATUS_SUCCESS;
16620 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016621 //Check PMC state first
16622 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070016623 switch( pmcState )
16624 {
16625 case REQUEST_IMPS:
16626 case IMPS:
16627 if( eSmeCommandScan == pCommand->command )
16628 {
16629 switch( pCommand->u.scanCmd.reason )
16630 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016631#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
16632 case eCsrScanGetLfrResult:
16633#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016634 case eCsrScanGetResult:
16635 case eCsrScanBGScanAbort:
16636 case eCsrScanBGScanEnable:
16637 case eCsrScanGetScanChnInfo:
16638 //Internal process, no need for full power
16639 fNeedFullPower = eANI_BOOLEAN_FALSE;
16640 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016641 default:
16642 //Other scans are real scan, ask for power
16643 fNeedFullPower = eANI_BOOLEAN_TRUE;
16644 break;
16645 } //switch
16646 }
16647 else
16648 {
16649 //ask for power for roam and status change
16650 fNeedFullPower = eANI_BOOLEAN_TRUE;
16651 }
16652 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016653 case REQUEST_BMPS:
16654 case BMPS:
16655 case REQUEST_START_UAPSD:
16656 case UAPSD:
16657 //We treat WOWL same as BMPS
16658 case REQUEST_ENTER_WOWL:
16659 case WOWL:
16660 if( eSmeCommandRoam == pCommand->command )
16661 {
16662 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
16663 tCsrScanResult *pScanResult;
16664 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070016665 switch ( pCommand->u.roamCmd.roamReason )
16666 {
16667 case eCsrForcedDisassoc:
16668 case eCsrForcedDisassocMICFailure:
16669 reason = eSME_LINK_DISCONNECTED_BY_HDD;
16670 fNeedFullPower = eANI_BOOLEAN_TRUE;
16671 break;
16672 case eCsrSmeIssuedDisassocForHandoff:
16673 case eCsrForcedDeauth:
16674 case eCsrHddIssuedReassocToSameAP:
16675 case eCsrSmeIssuedReassocToSameAP:
16676 fNeedFullPower = eANI_BOOLEAN_TRUE;
16677 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016678 case eCsrCapsChange:
16679 fNeedFullPower = eANI_BOOLEAN_TRUE;
16680 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016681 default:
16682 //Check whether the profile is already connected. If so, no need for full power
16683 //Note: IBSS is ignored for now because we don't support powersave in IBSS
16684 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
16685 {
16686 //Only need to check the first one
16687 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
16688 if( pEntry )
16689 {
16690 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
16691#if 0
16692 // TODO : Session Specific info pConnectBssDesc
16693 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
16694 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
16695 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
16696 {
16697 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
16698 // with Authenticating first. To force this, stop the current association (Disassociate) and
16699 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
16700 // a new Association.
16701 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
16702 {
16703 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
16704 {
16705 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
16706 //No need for full power
16707 //Set the flag so the code later can avoid to do the above
16708 //check again.
16709 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
16710 break;
16711 }
16712 }
16713 }
16714#endif
16715 }
16716 }
16717 //If we are here, full power is needed
16718 fNeedFullPower = eANI_BOOLEAN_TRUE;
16719 break;
16720 }
16721 }
16722 else if( eSmeCommandWmStatusChange == pCommand->command )
16723 {
16724 //need full power for all
16725 fNeedFullPower = eANI_BOOLEAN_TRUE;
16726 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
16727 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016728#ifdef FEATURE_WLAN_TDLS
16729 else if( eSmeCommandTdlsAddPeer == pCommand->command )
16730 {
16731 //TDLS link is getting established. need full power
16732 fNeedFullPower = eANI_BOOLEAN_TRUE;
16733 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
16734 }
16735#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016736 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016737 case REQUEST_STOP_UAPSD:
16738 case REQUEST_EXIT_WOWL:
16739 if( eSmeCommandRoam == pCommand->command )
16740 {
16741 fNeedFullPower = eANI_BOOLEAN_TRUE;
16742 switch ( pCommand->u.roamCmd.roamReason )
16743 {
16744 case eCsrForcedDisassoc:
16745 case eCsrForcedDisassocMICFailure:
16746 reason = eSME_LINK_DISCONNECTED_BY_HDD;
16747 break;
16748 default:
16749 break;
16750 }
16751 }
16752 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016753 case STOPPED:
16754 case REQUEST_STANDBY:
16755 case STANDBY:
16756 case LOW_POWER:
16757 //We are not supposed to do anything
Sushant Kaushike0d2cce2014-04-10 14:36:07 +053016758 smsLog( pMac, LOGE, FL( "cannot process because PMC is in"
16759 " stopped/standby state %s (%d)" ),
16760 sme_PmcStatetoString(pmcState), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070016761 status = eHAL_STATUS_FAILURE;
16762 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016763 case FULL_POWER:
16764 case REQUEST_FULL_POWER:
16765 default:
16766 //No need to ask for full power. This has to be FULL_POWER state
16767 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016768 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070016769 if( pReason )
16770 {
16771 *pReason = reason;
16772 }
16773 if( pfNeedPower )
16774 {
16775 *pfNeedPower = fNeedFullPower;
16776 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016777 return ( status );
16778}
16779
Jeff Johnson295189b2012-06-20 16:38:30 -070016780static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
16781{
16782 eHalStatus status = eHAL_STATUS_SUCCESS;
16783 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
16784 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070016785 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070016786 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
16787 {
16788 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
16789 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016790 return ( status );
16791}
16792
Jeff Johnson295189b2012-06-20 16:38:30 -070016793tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
16794{
16795 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070016796 if( pCmd )
16797 {
16798 pMac->roam.sPendingCommands++;
16799 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016800 return ( pCmd );
16801}
16802
Jeff Johnson295189b2012-06-20 16:38:30 -070016803void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
16804{
16805 if (pMac->roam.sPendingCommands > 0)
16806 {
16807 //All command allocated through csrGetCommandBuffer need to
16808 //decrement the pending count when releasing.
16809 pMac->roam.sPendingCommands--;
16810 smeReleaseCommand( pMac, pCommand );
16811 }
16812 else
16813 {
16814 smsLog(pMac, LOGE, FL( "no pending commands"));
16815 VOS_ASSERT(0);
16816 }
16817}
16818
Jeff Johnson295189b2012-06-20 16:38:30 -070016819//Return SUCCESS is the command is queued, failed
16820eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
16821{
16822 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016823 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
16824 {
16825 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
16826 pCommand->u.scanCmd.reason);
16827 return eHAL_STATUS_CSR_WRONG_STATE;
16828 }
16829
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016830 if ((pMac->fScanOffload) && (pCommand->command == eSmeCommandScan))
16831 {
16832 csrLLInsertTail(&pMac->sme.smeScanCmdPendingList,
16833 &pCommand->Link, LL_ACCESS_LOCK);
16834 // process the command queue...
16835 smeProcessPendingQueue(pMac);
16836 status = eHAL_STATUS_SUCCESS;
16837 goto end;
16838 }
16839
Jeff Johnson295189b2012-06-20 16:38:30 -070016840 //We can call request full power first before putting the command into pending Q
16841 //because we are holding SME lock at this point.
16842 status = csrRequestFullPower( pMac, pCommand );
16843 if( HAL_STATUS_SUCCESS( status ) )
16844 {
16845 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070016846 //make sure roamCmdPendingList is not empty first
16847 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
16848 if( fNoCmdPending )
16849 {
16850 smePushCommand( pMac, pCommand, fHighPriority );
16851 }
16852 else
16853 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016854 //Other commands are waiting for PMC callback, queue the new command to the pending Q
Jeff Johnson295189b2012-06-20 16:38:30 -070016855 //no list lock is needed since SME lock is held
16856 if( !fHighPriority )
16857 {
16858 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16859 }
16860 else {
16861 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16862 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016863 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016864 }
16865 else if( eHAL_STATUS_PMC_PENDING == status )
16866 {
16867 //no list lock is needed since SME lock is held
16868 if( !fHighPriority )
16869 {
16870 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16871 }
16872 else {
16873 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16874 }
16875 //Let caller know the command is queue
16876 status = eHAL_STATUS_SUCCESS;
16877 }
16878 else
16879 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016880 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
Jeff Johnson295189b2012-06-20 16:38:30 -070016881 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016882 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070016883 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016884end:
Jeff Johnson295189b2012-06-20 16:38:30 -070016885 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070016886}
Jeff Johnson295189b2012-06-20 16:38:30 -070016887eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
16888{
16889 eHalStatus status = eHAL_STATUS_SUCCESS;
16890 tSirUpdateAPWPSIEsReq *pMsg;
16891 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
16892
16893 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16894 if (NULL == pSession)
16895 {
16896 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
16897 return eHAL_STATUS_FAILURE;
16898 }
16899
Jeff Johnson295189b2012-06-20 16:38:30 -070016900 do
16901 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016902 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
16903 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
16904 vos_mem_set(pMsg, sizeof(tSirUpdateAPWPSIEsReq), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016905 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
16906
16907 pBuf = (tANI_U8 *)&pMsg->transactionId;
lukez3c809222013-05-03 10:23:02 -070016908 VOS_ASSERT(pBuf);
16909
Jeff Johnson295189b2012-06-20 16:38:30 -070016910 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070016911 // transactionId
16912 *pBuf = 0;
16913 *( pBuf + 1 ) = 0;
16914 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070016915 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053016916 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
16917 sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070016918 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070016919 //sessionId
16920 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070016921 // APWPSIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053016922 vos_mem_copy((tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
Jeff Johnson295189b2012-06-20 16:38:30 -070016923 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070016924 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070016925 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016926 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070016927 return ( status );
16928}
Jeff Johnson295189b2012-06-20 16:38:30 -070016929eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
16930{
16931 eHalStatus status = eHAL_STATUS_SUCCESS;
16932 tSirUpdateAPWPARSNIEsReq *pMsg;
16933 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016934 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16935 if (NULL == pSession)
16936 {
16937 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
16938 return eHAL_STATUS_FAILURE;
16939 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016940 do
16941 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016942 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPARSNIEsReq));
16943 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
16944 vos_mem_set(pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016945 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070016946 pBuf = (tANI_U8 *)&pMsg->transactionId;
16947 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070016948 // transactionId
16949 *pBuf = 0;
16950 *( pBuf + 1 ) = 0;
16951 pBuf += sizeof(tANI_U16);
lukez3c809222013-05-03 10:23:02 -070016952 VOS_ASSERT(pBuf);
16953
Jeff Johnson295189b2012-06-20 16:38:30 -070016954 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053016955 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
16956 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070016957 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070016958 // sessionId
16959 *pBuf++ = (tANI_U8)sessionId;
16960
16961 // APWPARSNIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053016962 vos_mem_copy((tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070016963 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070016964 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070016965 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016966 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070016967 return ( status );
16968}
Jeff Johnson295189b2012-06-20 16:38:30 -070016969
16970#ifdef WLAN_FEATURE_VOWIFI_11R
16971//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
16972eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
16973{
16974 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
16975 tpSirFTPreAuthReq pftPreAuthReq;
16976 tANI_U16 auth_req_len = 0;
16977 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070016978 auth_req_len = sizeof(tSirFTPreAuthReq);
16979 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
Kiet Lam64c1b492013-07-12 13:56:44 +053016980 if (NULL == pftPreAuthReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070016981 {
16982 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
16983 return eHAL_STATUS_RESOURCES;
16984 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016985 // Save the SME Session ID here. We need it while processing the preauth response
16986 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070016987 vos_mem_zero(pftPreAuthReq, auth_req_len);
16988
16989 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
16990 sizeof(pBssDescription->length) + pBssDescription->length);
16991
16992 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
16993
16994 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
16995
Kiet Lam64c1b492013-07-12 13:56:44 +053016996 vos_mem_copy((void *)&pftPreAuthReq->currbssId,
16997 (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
16998 vos_mem_copy((void *)&pftPreAuthReq->preAuthbssId,
16999 (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070017000
Jeff Johnson295189b2012-06-20 16:38:30 -070017001#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080017002 if (csrRoamIs11rAssoc(pMac) &&
17003 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070017004 {
17005 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
Kiet Lam64c1b492013-07-12 13:56:44 +053017006 vos_mem_copy(pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
17007 pMac->ft.ftSmeContext.auth_ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -070017008 }
17009 else
17010#endif
17011 {
17012 pftPreAuthReq->ft_ies_length = 0;
17013 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070017014 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
17015 sizeof(pBssDescription->length) + pBssDescription->length);
17016 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070017017 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
17018}
Jeff Johnson295189b2012-06-20 16:38:30 -070017019/*--------------------------------------------------------------------------
17020 * This will receive and process the FT Pre Auth Rsp from the current
17021 * associated ap.
17022 *
17023 * This will invoke the hdd call back. This is so that hdd can now
17024 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
17025 ------------------------------------------------------------------------*/
17026void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
17027{
17028 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
17029 eHalStatus status = eHAL_STATUS_SUCCESS;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017030#if defined(FEATURE_WLAN_LFR) || defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017031 tCsrRoamInfo roamInfo;
17032#endif
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053017033 eCsrAuthType conn_Auth_type;
Jeff Johnson295189b2012-06-20 16:38:30 -070017034
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070017035#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080017036 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070017037 if (status != eHAL_STATUS_SUCCESS) {
17038 /*
17039 * Bail out if pre-auth was not even processed.
17040 */
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017041 smsLog(pMac, LOGE,FL("Preauth was not processed: %d SessionID: %d"),
17042 status, pFTPreAuthRsp->smeSessionId);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070017043 return;
17044 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017045#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017046 /* The below function calls/timers should be invoked only if the pre-auth is successful */
17047 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
17048 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070017049 // Implies a success
17050 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070017051 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
17052 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
Sandeep Puligilla0c486ca2014-05-24 02:40:49 +053017053 /* No need to notify qos module if this is a non 11r & ESE roam*/
17054 if (csrRoamIs11rAssoc(pMac)
17055#if defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
17056 || csrRoamIsESEAssoc(pMac)
17057#endif
17058 )
Tushnim Bhattacharyya8436d772013-06-26 23:03:29 -070017059 {
17060 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
17061 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017062 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
17063 * actual transition from the current to handoff AP is triggered */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017064 status = vos_timer_start(&pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
17065 60);
Jeff Johnson295189b2012-06-20 16:38:30 -070017066 if (eHAL_STATUS_SUCCESS != status)
17067 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017068 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070017069 return;
17070 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017071 // Save the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053017072 vos_mem_copy((void *)&pMac->ft.ftSmeContext.preAuthbssId,
17073 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070017074 if (csrRoamIs11rAssoc(pMac))
17075 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
17076 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
17077
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017078#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
17079 if (csrRoamIsESEAssoc(pMac))
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017080 {
17081 /* read TSF */
17082 csrRoamReadTSF(pMac, (tANI_U8 *)roamInfo.timestamp);
17083
17084 // Save the bssid from the received response
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080017085 vos_mem_copy((void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017086 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_CCKM_PREAUTH_NOTIFY, 0);
17087 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017088#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017089#ifdef FEATURE_WLAN_LFR
17090 // If Legacy Fast Roaming is enabled, signal the supplicant
17091 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053017092 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017093 {
17094 // Save the bssid from the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053017095 vos_mem_copy((void *)&roamInfo.bssid,
17096 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017097 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
17098 }
17099
17100#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017101
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053017102 // If its an Open Auth, FT IEs are not provided by supplicant
17103 // Hence populate them here
17104 conn_Auth_type = pMac->roam.roamSession[pMac->ft.ftSmeContext.smeSessionId].connectedProfile.AuthType;
17105 pMac->ft.ftSmeContext.addMDIE = FALSE;
17106 if( csrRoamIs11rAssoc(pMac) &&
17107 (conn_Auth_type == eCSR_AUTH_TYPE_OPEN_SYSTEM))
17108 {
17109 tANI_U16 ft_ies_length;
17110 ft_ies_length = pFTPreAuthRsp->ric_ies_length;
17111
17112 if ( (pMac->ft.ftSmeContext.reassoc_ft_ies) &&
17113 (pMac->ft.ftSmeContext.reassoc_ft_ies_length))
17114 {
17115 vos_mem_free(pMac->ft.ftSmeContext.reassoc_ft_ies);
17116 pMac->ft.ftSmeContext.reassoc_ft_ies_length = 0;
17117 }
17118
17119 pMac->ft.ftSmeContext.reassoc_ft_ies = vos_mem_malloc(ft_ies_length);
17120 if ( NULL == pMac->ft.ftSmeContext.reassoc_ft_ies )
17121 {
17122 smsLog( pMac, LOGE, FL("Memory allocation failed for ft_ies"));
17123 }
17124 else
17125 {
17126 // Copy the RIC IEs to reassoc IEs
17127 vos_mem_copy(((tANI_U8 *)pMac->ft.ftSmeContext.reassoc_ft_ies),
17128 (tANI_U8 *)pFTPreAuthRsp->ric_ies,
17129 pFTPreAuthRsp->ric_ies_length);
17130 pMac->ft.ftSmeContext.reassoc_ft_ies_length = ft_ies_length;
17131 pMac->ft.ftSmeContext.addMDIE = TRUE;
17132 }
17133 }
17134
Jeff Johnson295189b2012-06-20 16:38:30 -070017135 // Done with it, init it.
17136 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
17137}
17138#endif
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053017139
Jeff Johnson295189b2012-06-20 16:38:30 -070017140#ifdef FEATURE_WLAN_BTAMP_UT_RF
17141void csrRoamJoinRetryTimerHandler(void *pv)
17142{
17143 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
17144 tpAniSirGlobal pMac = pInfo->pMac;
17145 tANI_U32 sessionId = pInfo->sessionId;
17146 tCsrRoamSession *pSession;
17147
17148 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
17149 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017150 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070017151 pSession = CSR_GET_SESSION( pMac, sessionId );
17152 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
17153 {
17154 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
17155 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017156 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070017157 }
17158 }
17159 }
17160}
Jeff Johnson295189b2012-06-20 16:38:30 -070017161eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
17162{
17163 eHalStatus status = eHAL_STATUS_FAILURE;
17164 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
17165
17166 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
17167 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017168 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070017169 pSession->maxRetryCount--;
17170 pSession->joinRetryTimerInfo.pMac = pMac;
17171 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017172 status = vos_timer_start(&pSession->hTimerJoinRetry, interval/PAL_TIMER_TO_MS_UNIT);
17173 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070017174 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017175 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070017176 }
17177 }
17178 else
17179 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017180 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070017181 pSession->maxRetryCount);
17182 }
17183
17184 return (status);
17185}
Jeff Johnson295189b2012-06-20 16:38:30 -070017186eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
17187{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017188 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070017189 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
17190 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017191 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerJoinRetry));
Jeff Johnson295189b2012-06-20 16:38:30 -070017192 }
17193
17194 return eHAL_STATUS_SUCCESS;
17195}
17196#endif
17197
17198
17199/*
17200 pBuf points to the beginning of the message
17201 LIM packs disassoc rsp as below,
17202 messageType - 2 bytes
17203 messageLength - 2 bytes
17204 sessionId - 1 byte
17205 transactionId - 2 bytes (tANI_U16)
17206 reasonCode - 4 bytes (sizeof(tSirResultCodes))
17207 peerMacAddr - 6 bytes
17208 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
17209*/
17210static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
17211{
17212 if(pBuf && pRsp)
17213 {
17214 pBuf += 4; //skip type and length
17215 pRsp->sessionId = *pBuf++;
17216 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
17217 pBuf += 2;
17218 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
17219 pBuf += 4;
17220 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
17221 }
17222}
17223
Jeff Johnsond13512a2012-07-17 11:42:19 -070017224eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
17225{
17226 static uNvTables nvTables;
17227 eHalStatus status = eHAL_STATUS_SUCCESS;
17228 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
17229
17230 /* read the country code from NV and use it */
17231 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
17232 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017233 vos_mem_copy(pCountry, nvTables.defaultCountryTable.countryCode,
17234 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017235 return status;
17236 }
17237 else
17238 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017239 vos_mem_copy(pCountry, "XXX", WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017240 status = eHAL_STATUS_FAILURE;
17241 return status;
17242 }
17243}
17244
17245eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
17246{
Kiet Lam64c1b492013-07-12 13:56:44 +053017247 vos_mem_copy(pCountry, pMac->scan.countryCode11d, WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017248 return eHAL_STATUS_SUCCESS;
17249}
schang86c22c42013-03-13 18:41:24 -070017250
17251eHalStatus csrSetTxPower(tpAniSirGlobal pMac, v_U8_t sessionId, v_U8_t mW)
17252{
17253 tSirSetTxPowerReq *pMsg = NULL;
17254 eHalStatus status = eHAL_STATUS_SUCCESS;
17255 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17256
17257 if (!pSession)
17258 {
17259 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17260 return eHAL_STATUS_FAILURE;
17261 }
17262
Kiet Lam64c1b492013-07-12 13:56:44 +053017263 pMsg = vos_mem_malloc(sizeof(tSirSetTxPowerReq));
17264 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
17265 vos_mem_set((void *)pMsg, sizeof(tSirSetTxPowerReq), 0);
17266 pMsg->messageType = eWNI_SME_SET_TX_POWER_REQ;
17267 pMsg->length = sizeof(tSirSetTxPowerReq);
17268 pMsg->mwPower = mW;
17269 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
17270 sizeof(tSirMacAddr));
17271 status = palSendMBMessage(pMac->hHdd, pMsg);
17272 if (!HAL_STATUS_SUCCESS(status))
schang86c22c42013-03-13 18:41:24 -070017273 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017274 smsLog(pMac, LOGE, FL(" csr set TX Power Post MSG Fail %d "), status);
17275 //pMsg is freed by palSendMBMessage
schang86c22c42013-03-13 18:41:24 -070017276 }
17277 return status;
17278}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017279
Sandeep Puligilla332ea912014-02-04 00:16:24 +053017280eHalStatus csrHT40StopOBSSScan(tpAniSirGlobal pMac, v_U8_t sessionId)
17281{
17282 tSirSmeHT40OBSSStopScanInd *pMsg = NULL;
17283 eHalStatus status = eHAL_STATUS_SUCCESS;
17284 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17285
17286 if (!pSession)
17287 {
17288 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17289 return eHAL_STATUS_FAILURE;
17290 }
17291 if(IS_HT40_OBSS_SCAN_FEATURE_ENABLE)
17292 {
17293 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSStopScanInd));
Abhishek Singh11aa2902014-05-05 11:52:52 +053017294
17295 if( NULL == pMsg )
17296 {
17297 smsLog(pMac, LOGE, FL("PMsg is NULL "));
17298 return eHAL_STATUS_FAILURE;
17299 }
Sandeep Puligilla332ea912014-02-04 00:16:24 +053017300 vos_mem_zero((void *)pMsg, sizeof(tSirSmeHT40OBSSStopScanInd));
17301 pMsg->messageType = eWNI_SME_HT40_STOP_OBSS_SCAN_IND;
17302 pMsg->length = sizeof(tANI_U8);
17303 pMsg->seesionId = sessionId;
17304 status = palSendMBMessage(pMac->hHdd, pMsg);
17305 if (!HAL_STATUS_SUCCESS(status))
17306 {
17307 smsLog(pMac, LOGE, FL(" csr STOP OBSS SCAN Fail %d "), status);
17308 //pMsg is freed by palSendMBMessage
17309 }
17310 }
17311 else
17312 {
17313 smsLog(pMac, LOGE, FL(" OBSS STOP OBSS SCAN is not supported"));
17314 status = eHAL_STATUS_FAILURE;
17315 }
17316 return status;
17317}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017318/* Returns whether a session is in VOS_STA_MODE...or not */
17319tANI_BOOLEAN csrRoamIsStaMode(tpAniSirGlobal pMac, tANI_U32 sessionId)
17320{
17321 tCsrRoamSession *pSession = NULL;
17322 pSession = CSR_GET_SESSION ( pMac, sessionId );
17323 if(!pSession)
17324 {
17325 smsLog(pMac, LOGE, FL(" %s: session %d not found "), __func__, sessionId);
17326 return eANI_BOOLEAN_FALSE;
17327 }
17328 if ( !CSR_IS_SESSION_VALID ( pMac, sessionId ) )
17329 {
17330 smsLog(pMac, LOGE, FL(" %s: Inactive session"), __func__);
17331 return eANI_BOOLEAN_FALSE;
17332 }
17333 if ( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
17334 {
17335 return eANI_BOOLEAN_FALSE;
17336 }
17337 /* There is a possibility that the above check may fail,because
17338 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
17339 * when it is connected.So,we may sneak through the above check even
17340 * if we are not a STA mode INFRA station. So, if we sneak through
17341 * the above condition, we can use the following check if we are
17342 * really in STA Mode.*/
17343
17344 if ( NULL != pSession->pCurRoamProfile )
17345 {
17346 if ( pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE )
17347 {
17348 return eANI_BOOLEAN_TRUE;
17349 } else {
17350 smsLog(pMac, LOGE, FL(" %s: pCurRoamProfile is NULL\n"), __func__);
17351 return eANI_BOOLEAN_FALSE;
17352 }
17353 }
17354
17355 return eANI_BOOLEAN_FALSE;
17356}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017357
17358#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
17359eHalStatus csrHandoffRequest(tpAniSirGlobal pMac,
17360 tCsrHandoffRequest *pHandoffInfo)
17361{
17362 eHalStatus status = eHAL_STATUS_SUCCESS;
17363 vos_msg_t msg;
17364
17365 tAniHandoffReq *pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053017366 pMsg = vos_mem_malloc(sizeof(tAniHandoffReq));
17367 if ( NULL == pMsg )
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017368 {
17369 smsLog(pMac, LOGE, " csrHandoffRequest: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053017370 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017371 }
17372 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_HANDOFF_REQ);
17373 pMsg->msgLen = (tANI_U16)sizeof(tAniHandoffReq);
17374 pMsg->sessionId = pMac->roam.neighborRoamInfo.csrSessionId;
17375 pMsg->channel = pHandoffInfo->channel;
Kiet Lam64c1b492013-07-12 13:56:44 +053017376 vos_mem_copy(pMsg->bssid,
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017377 pHandoffInfo->bssid,
17378 6);
17379 msg.type = eWNI_SME_HANDOFF_REQ;
17380 msg.bodyptr = pMsg;
17381 msg.reserved = 0;
17382 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
17383 {
17384 smsLog(pMac, LOGE, " csrHandoffRequest failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053017385 vos_mem_free((void *)pMsg);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017386 status = eHAL_STATUS_FAILURE;
17387 }
17388 return status;
17389}
17390#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017391
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017392
17393#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017394/* ---------------------------------------------------------------------------
17395 \fn csrSetCCKMIe
17396 \brief This function stores the CCKM IE passed by the supplicant in a place holder
17397 data structure and this IE will be packed inside reassociation request
17398 \param pMac - pMac global structure
17399 \param sessionId - Current session id
17400 \param pCckmIe - pointer to CCKM IE data
17401 \param ccKmIeLen - length of the CCKM IE
17402 \- return Success or failure
17403 -------------------------------------------------------------------------*/
17404VOS_STATUS csrSetCCKMIe(tpAniSirGlobal pMac, const tANI_U8 sessionId,
17405 const tANI_U8 *pCckmIe,
17406 const tANI_U8 ccKmIeLen)
17407{
17408 eHalStatus status = eHAL_STATUS_SUCCESS;
17409 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17410
17411 if (!pSession)
17412 {
17413 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17414 return eHAL_STATUS_FAILURE;
17415 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053017416 vos_mem_copy(pSession->suppCckmIeInfo.cckmIe, pCckmIe, ccKmIeLen);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017417 pSession->suppCckmIeInfo.cckmIeLen = ccKmIeLen;
17418 return status;
17419}
17420
17421/* ---------------------------------------------------------------------------
17422 \fn csrRoamReadTSF
17423 \brief This function reads the TSF; and also add the time elapsed since last beacon or
17424 probe response reception from the hand off AP to arrive at the latest TSF value.
17425 \param pMac - pMac global structure
17426 \param pTimestamp - output TSF timestamp
17427 \- return Success or failure
17428 -------------------------------------------------------------------------*/
17429VOS_STATUS csrRoamReadTSF(tpAniSirGlobal pMac, tANI_U8 *pTimestamp)
17430{
17431 eHalStatus status = eHAL_STATUS_SUCCESS;
17432 tCsrNeighborRoamBSSInfo handoffNode;
17433 tANI_U32 timer_diff = 0;
17434 tANI_U32 timeStamp[2];
17435 tpSirBssDescription pBssDescription = NULL;
17436
17437 csrNeighborRoamGetHandoffAPInfo(pMac, &handoffNode);
17438 pBssDescription = handoffNode.pBssDescription;
17439
17440 // Get the time diff in milli seconds
17441 timer_diff = vos_timer_get_system_time() - pBssDescription->scanSysTimeMsec;
17442 // Convert msec to micro sec timer
17443 timer_diff = (tANI_U32)(timer_diff * SYSTEM_TIME_MSEC_TO_USEC);
17444
17445 timeStamp[0] = pBssDescription->timeStamp[0];
17446 timeStamp[1] = pBssDescription->timeStamp[1];
17447
17448 UpdateCCKMTSF(&(timeStamp[0]), &(timeStamp[1]), &timer_diff);
17449
Kiet Lamf2f201e2013-11-16 21:24:16 +053017450 vos_mem_copy(pTimestamp, (void *) &timeStamp[0],
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017451 sizeof (tANI_U32) * 2);
17452 return status;
17453}
17454
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017455#endif /*FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017456