blob: 10fd6f15c7e2404e1efde8ec82b1e5d53e8ad42b [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);
352
353 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;
366 v_REGDOMAIN_t regId;
367
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
385 if (!('0' == pMac->scan.countryCodeDefault[0] &&
386 '0' == pMac->scan.countryCodeDefault[1]))
387 {
388 csrGetRegulatoryDomainForCountry(pMac, pMac->scan.countryCodeDefault,
389 &regId, COUNTRY_NV);
390 }
391 else
392 {
393 regId = REGDOMAIN_WORLD;
394 }
395
396 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
397 pMac->scan.domainIdDefault = regId;
398 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
399 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
400 WNI_CFG_COUNTRY_CODE_LEN);
401 status = csrInitGetChannels( pMac );
402
403 return status;
404}
405
Jeff Johnson295189b2012-06-20 16:38:30 -0700406eHalStatus csrSetRegInfo(tHalHandle hHal, tANI_U8 *apCntryCode)
407{
408 eHalStatus status = eHAL_STATUS_SUCCESS;
409 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
410 v_REGDOMAIN_t regId;
411 v_U8_t cntryCodeLength;
Jeff Johnson295189b2012-06-20 16:38:30 -0700412 if(NULL == apCntryCode)
413 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +0530414 smsLog( pMac, LOGE, FL(" Invalid country Code Pointer") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700415 return eHAL_STATUS_FAILURE;
416 }
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +0530417 smsLog( pMac, LOG1, FL(" country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700418 /* To get correct Regulatory domain from NV table
419 * 2 character Country code should be used
420 * 3rd charater is optional for indoor/outdoor setting */
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700421 cntryCodeLength = WNI_CFG_COUNTRY_CODE_LEN;
422/*
Jeff Johnson295189b2012-06-20 16:38:30 -0700423 cntryCodeLength = strlen(apCntryCode);
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700424
425 if (cntryCodeLength > WNI_CFG_COUNTRY_CODE_LEN)
426 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800427 smsLog( pMac, LOGW, FL(" Invalid Country Code Length") );
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700428 return eHAL_STATUS_FAILURE;
429 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700430*/
Kiet Lam6c583332013-10-14 05:37:09 +0530431 status = csrGetRegulatoryDomainForCountry(pMac, apCntryCode, &regId,
432 COUNTRY_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -0700433 if (status != eHAL_STATUS_SUCCESS)
434 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700435 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700436 return status;
437 }
Abhishek Singha306a442013-11-07 18:39:01 +0530438 status = WDA_SetRegDomain(hHal, regId, eSIR_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700439 if (status != eHAL_STATUS_SUCCESS)
440 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700441 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700442 return status;
443 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700444 pMac->scan.domainIdDefault = regId;
445 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Jeff Johnson295189b2012-06-20 16:38:30 -0700446 /* Clear CC field */
Kiet Lam64c1b492013-07-12 13:56:44 +0530447 vos_mem_set(pMac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN, 0);
448
Jeff Johnson295189b2012-06-20 16:38:30 -0700449 /* Copy 2 or 3 bytes country code */
Kiet Lam64c1b492013-07-12 13:56:44 +0530450 vos_mem_copy(pMac->scan.countryCodeDefault, apCntryCode, cntryCodeLength);
451
Jeff Johnson295189b2012-06-20 16:38:30 -0700452 /* If 2 bytes country code, 3rd byte must be filled with space */
453 if((WNI_CFG_COUNTRY_CODE_LEN - 1) == cntryCodeLength)
454 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530455 vos_mem_set(pMac->scan.countryCodeDefault + 2, 1, 0x20);
Jeff Johnson295189b2012-06-20 16:38:30 -0700456 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530457 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
458 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700459 status = csrInitGetChannels( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -0700460 return status;
461}
Jeff Johnson295189b2012-06-20 16:38:30 -0700462eHalStatus csrSetChannels(tHalHandle hHal, tCsrConfigParam *pParam )
463{
464 eHalStatus status = eHAL_STATUS_SUCCESS;
465 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
466 tANI_U8 index = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +0530467 vos_mem_copy(pParam->Csr11dinfo.countryCode, pMac->scan.countryCodeCurrent,
468 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700469 for ( index = 0; index < pMac->scan.base20MHzChannels.numChannels ; index++)
470 {
471 pParam->Csr11dinfo.Channels.channelList[index] = pMac->scan.base20MHzChannels.channelList[ index ];
472 pParam->Csr11dinfo.ChnPower[index].firstChannel = pMac->scan.base20MHzChannels.channelList[ index ];
473 pParam->Csr11dinfo.ChnPower[index].numChannels = 1;
474 pParam->Csr11dinfo.ChnPower[index].maxtxPower = pMac->scan.defaultPowerTable[index].pwr;
475 }
476 pParam->Csr11dinfo.Channels.numChannels = pMac->scan.base20MHzChannels.numChannels;
477
478 return status;
479}
Jeff Johnson295189b2012-06-20 16:38:30 -0700480eHalStatus csrClose(tpAniSirGlobal pMac)
481{
482 eHalStatus status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800483
Jeff Johnson295189b2012-06-20 16:38:30 -0700484 csrRoamClose(pMac);
485 csrScanClose(pMac);
486 csrLLClose(&pMac->roam.statsClientReqList);
487 csrLLClose(&pMac->roam.peStatsReqList);
488 csrLLClose(&pMac->roam.roamCmdPendingList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700489 /* DeInit Globals */
490 csrRoamDeInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700491 return (status);
492}
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530493
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800494eHalStatus csrUpdateChannelList(tpAniSirGlobal pMac)
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530495{
496 tSirUpdateChanList *pChanList;
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800497 tCsrScanStruct *pScan = &pMac->scan;
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530498 tANI_U8 numChan = pScan->base20MHzChannels.numChannels;
499 tANI_U32 bufLen = sizeof(tSirUpdateChanList) +
500 (sizeof(tSirUpdateChanParam) * (numChan - 1));
501 vos_msg_t msg;
502 tANI_U8 i;
503
504 pChanList = (tSirUpdateChanList *) vos_mem_malloc(bufLen);
505 if (!pChanList)
506 {
507 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
508 "Failed to allocate memory for tSirUpdateChanList");
509 return eHAL_STATUS_FAILED_ALLOC;
510 }
511
512 msg.type = WDA_UPDATE_CHAN_LIST_REQ;
513 msg.reserved = 0;
514 msg.bodyptr = pChanList;
515 pChanList->numChan = numChan;
516 for (i = 0; i < pChanList->numChan; i++)
517 {
518 pChanList->chanParam[i].chanId = pScan->defaultPowerTable[i].chanId;
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800519 pChanList->chanParam[i].pwr = cfgGetRegulatoryMaxTransmitPower(pMac,
520 pScan->defaultPowerTable[i].chanId);
521 if (vos_nv_getChannelEnabledState(pChanList->chanParam[i].chanId) ==
522 NV_CHANNEL_DFS)
523 pChanList->chanParam[i].dfsSet = VOS_TRUE;
524 else
525 pChanList->chanParam[i].dfsSet = VOS_FALSE;
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530526 }
527
528 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
529 {
530 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
531 "%s: Failed to post msg to WDA", __func__);
532 vos_mem_free(pChanList);
533 return eHAL_STATUS_FAILURE;
534 }
535
536 return eHAL_STATUS_SUCCESS;
537}
538
Jeff Johnson295189b2012-06-20 16:38:30 -0700539eHalStatus csrStart(tpAniSirGlobal pMac)
540{
541 eHalStatus status = eHAL_STATUS_SUCCESS;
542 tANI_U32 i;
543
544 do
545 {
546 //save the global vos context
547 pMac->roam.gVosContext = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
548 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
549 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, i );
550
551 status = csrRoamStart(pMac);
552 if(!HAL_STATUS_SUCCESS(status)) break;
553 pMac->scan.f11dInfoApplied = eANI_BOOLEAN_FALSE;
554 status = pmcRegisterPowerSaveCheck(pMac, csrCheckPSReady, pMac);
555 if(!HAL_STATUS_SUCCESS(status)) break;
556 pMac->roam.sPendingCommands = 0;
557 csrScanEnable(pMac);
558#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
559 status = csrNeighborRoamInit(pMac);
560#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
561 pMac->roam.tlStatsReqInfo.numClient = 0;
562 pMac->roam.tlStatsReqInfo.periodicity = 0;
563 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
564 //init the link quality indication also
565 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_MIN_IND;
566 if(!HAL_STATUS_SUCCESS(status))
567 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800568 smsLog(pMac, LOGW, " csrStart: Couldn't Init HO control blk ");
Jeff Johnson295189b2012-06-20 16:38:30 -0700569 break;
570 }
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800571#ifdef QCA_WIFI_2_0
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530572 if (pMac->fScanOffload)
573 {
574 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
575 "Scan offload is enabled, update default chan list");
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800576 status = csrUpdateChannelList(pMac);
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530577 }
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800578#else
579 status = csrUpdateChannelList(pMac);
580#endif
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530581
Jeff Johnson295189b2012-06-20 16:38:30 -0700582 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700583#if defined(ANI_LOGDUMP)
584 csrDumpInit(pMac);
585#endif //#if defined(ANI_LOGDUMP)
Jeff Johnson295189b2012-06-20 16:38:30 -0700586 return (status);
587}
588
Kiet Lama72a2322013-11-15 11:18:11 +0530589eHalStatus csrStop(tpAniSirGlobal pMac, tHalStopType stopType)
Jeff Johnson295189b2012-06-20 16:38:30 -0700590{
591 tANI_U32 sessionId;
592 tANI_U32 i;
593
594 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
595 {
596 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
597 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700598 csrScanDisable(pMac);
599 pMac->scan.fCancelIdleScan = eANI_BOOLEAN_FALSE;
600 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700601 csrLLPurge( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_TRUE );
602
603#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
604 csrNeighborRoamClose(pMac);
605#endif
606 csrScanFlushResult(pMac); //Do we want to do this?
Jeff Johnson295189b2012-06-20 16:38:30 -0700607 // deregister from PMC since we register during csrStart()
608 // (ignore status since there is nothing we can do if it fails)
609 (void) pmcDeregisterPowerSaveCheck(pMac, csrCheckPSReady);
Jeff Johnson295189b2012-06-20 16:38:30 -0700610 //Reset the domain back to the deault
611 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800612 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700613
614 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
615 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530616 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i );
Jeff Johnson295189b2012-06-20 16:38:30 -0700617 pMac->roam.curSubState[i] = eCSR_ROAM_SUBSTATE_NONE;
618 }
619
Kiet Lama72a2322013-11-15 11:18:11 +0530620#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
621 /* When HAL resets all the context information
622 * in HAL is lost, so we might need to send the
623 * scan offload request again when it comes
624 * out of reset for scan offload to be functional
625 */
626 if (HAL_STOP_TYPE_SYS_RESET == stopType)
627 {
628 bRoamScanOffloadStarted = VOS_FALSE;
629 }
630#endif
631
Jeff Johnson295189b2012-06-20 16:38:30 -0700632 return (eHAL_STATUS_SUCCESS);
633}
634
Jeff Johnson295189b2012-06-20 16:38:30 -0700635eHalStatus csrReady(tpAniSirGlobal pMac)
636{
637 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700638 csrScanGetSupportedChannels( pMac );
639 //WNI_CFG_VALID_CHANNEL_LIST should be set by this time
640 //use it to init the background scan list
641 csrInitBGScanChannelList(pMac);
642 /* HDD issues the init scan */
643 csrScanStartResultAgingTimer(pMac);
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -0800644 /* If the gScanAgingTime is set to '0' then scan results aging timeout
645 based on timer feature is not enabled*/
646 if(0 != pMac->scan.scanResultCfgAgingTime )
647 {
648 csrScanStartResultCfgAgingTimer(pMac);
649 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700650 //Store the AC weights in TL for later use
651 WLANTL_GetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
Jeff Johnson295189b2012-06-20 16:38:30 -0700652 status = csrInitChannelList( pMac );
653 if ( ! HAL_STATUS_SUCCESS( status ) )
654 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800655 smsLog( pMac, LOGE, "csrInitChannelList failed during csrReady with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700656 status );
657 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700658 return (status);
659}
Jeff Johnson295189b2012-06-20 16:38:30 -0700660void csrSetDefaultDot11Mode( tpAniSirGlobal pMac )
661{
662 v_U32_t wniDot11mode = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700663 wniDot11mode = csrTranslateToWNICfgDot11Mode(pMac,pMac->roam.configParam.uCfgDot11Mode);
664 ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, wniDot11mode, NULL, eANI_BOOLEAN_FALSE);
665}
Jeff Johnson295189b2012-06-20 16:38:30 -0700666void csrSetGlobalCfgs( tpAniSirGlobal pMac )
667{
Jeff Johnsone7245742012-09-05 17:12:55 -0700668
Jeff Johnson295189b2012-06-20 16:38:30 -0700669 ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
670 ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
671 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
672 ((pMac->roam.configParam.Is11hSupportEnabled) ? pMac->roam.configParam.Is11dSupportEnabled : pMac->roam.configParam.Is11dSupportEnabled),
673 NULL, eANI_BOOLEAN_FALSE);
674 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnsone7245742012-09-05 17:12:55 -0700675 /* 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
676 * Once session is established we will use the session related params stored in PE session for CB mode
677 */
678 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, !!(pMac->roam.configParam.channelBondingMode5GHz), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700679 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, pMac->roam.configParam.HeartbeatThresh24, NULL, eANI_BOOLEAN_FALSE);
680
681 //Update the operating mode to configured value during initialization,
682 //So that client can advertise full capabilities in Probe request frame.
683 csrSetDefaultDot11Mode( pMac );
684}
685
Jeff Johnson295189b2012-06-20 16:38:30 -0700686eHalStatus csrRoamOpen(tpAniSirGlobal pMac)
687{
688 eHalStatus status = eHAL_STATUS_SUCCESS;
689 tANI_U32 i;
690 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700691 do
692 {
693 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
694 {
695 pSession = CSR_GET_SESSION( pMac, i );
696 pSession->roamingTimerInfo.pMac = pMac;
697 pSession->roamingTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
698 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700699 pMac->roam.WaitForKeyTimerInfo.pMac = pMac;
700 pMac->roam.WaitForKeyTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530701 status = vos_timer_init(&pMac->roam.hTimerWaitForKey, VOS_TIMER_TYPE_SW,
702 csrRoamWaitForKeyTimeOutHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -0700703 &pMac->roam.WaitForKeyTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530704 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700705 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800706 smsLog(pMac, LOGE, FL("cannot allocate memory for WaitForKey time out timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700707 break;
708 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530709 status = vos_timer_init(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
710 VOS_TIMER_TYPE_SW, csrRoamTlStatsTimerHandler, pMac);
711 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700712 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800713 smsLog(pMac, LOGE, FL("cannot allocate memory for summary Statistics timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700714 return eHAL_STATUS_FAILURE;
715 }
716 }while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700717 return (status);
718}
719
Jeff Johnson295189b2012-06-20 16:38:30 -0700720eHalStatus csrRoamClose(tpAniSirGlobal pMac)
721{
722 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700723 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
724 {
725 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
726 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530727 vos_timer_stop(&pMac->roam.hTimerWaitForKey);
728 vos_timer_destroy(&pMac->roam.hTimerWaitForKey);
729 vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
730 vos_timer_destroy(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -0700731 return (eHAL_STATUS_SUCCESS);
732}
733
Jeff Johnson295189b2012-06-20 16:38:30 -0700734eHalStatus csrRoamStart(tpAniSirGlobal pMac)
735{
736 (void)pMac;
Jeff Johnson295189b2012-06-20 16:38:30 -0700737 return (eHAL_STATUS_SUCCESS);
738}
739
Jeff Johnson295189b2012-06-20 16:38:30 -0700740void csrRoamStop(tpAniSirGlobal pMac, tANI_U32 sessionId)
741{
742 csrRoamStopRoamingTimer(pMac, sessionId);
743 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
744 csrRoamDeregStatisticsReq(pMac);
745}
Jeff Johnson295189b2012-06-20 16:38:30 -0700746eHalStatus csrRoamGetConnectState(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrConnectState *pState)
747{
748 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Srinivas Girigowdac84c57c2013-02-19 17:41:56 -0800749 if ( CSR_IS_SESSION_VALID(pMac, sessionId) && (NULL != pState) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700750 {
751 status = eHAL_STATUS_SUCCESS;
752 *pState = pMac->roam.roamSession[sessionId].connectState;
753 }
754 return (status);
755}
756
Jeff Johnson295189b2012-06-20 16:38:30 -0700757eHalStatus csrRoamCopyConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
758{
759 eHalStatus status = eHAL_STATUS_FAILURE;
760 tANI_U32 size = 0;
761 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -0700762
763 if(!pSession)
764 {
765 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
766 return eHAL_STATUS_FAILURE;
767 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700768
769 if(pProfile)
770 {
771 if(pSession->pConnectBssDesc)
772 {
773 do
774 {
775 size = pSession->pConnectBssDesc->length + sizeof(pSession->pConnectBssDesc->length);
776 if(size)
777 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530778 pProfile->pBssDesc = vos_mem_malloc(size);
779 if ( NULL != pProfile->pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -0700780 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530781 vos_mem_copy(pProfile->pBssDesc,
782 pSession->pConnectBssDesc, size);
783 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700784 }
785 else
786 break;
787 }
788 else
789 {
790 pProfile->pBssDesc = NULL;
791 }
792 pProfile->AuthType = pSession->connectedProfile.AuthType;
793 pProfile->EncryptionType = pSession->connectedProfile.EncryptionType;
794 pProfile->mcEncryptionType = pSession->connectedProfile.mcEncryptionType;
795 pProfile->BSSType = pSession->connectedProfile.BSSType;
796 pProfile->operationChannel = pSession->connectedProfile.operationChannel;
797 pProfile->CBMode = pSession->connectedProfile.CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +0530798 vos_mem_copy(&pProfile->bssid, &pSession->connectedProfile.bssid,
799 sizeof(tCsrBssid));
800 vos_mem_copy(&pProfile->SSID, &pSession->connectedProfile.SSID,
801 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -0700802#ifdef WLAN_FEATURE_VOWIFI_11R
803 if (pSession->connectedProfile.MDID.mdiePresent)
804 {
805 pProfile->MDID.mdiePresent = 1;
806 pProfile->MDID.mobilityDomain = pSession->connectedProfile.MDID.mobilityDomain;
807 }
808 else
809 {
810 pProfile->MDID.mdiePresent = 0;
811 pProfile->MDID.mobilityDomain = 0;
812 }
813#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800814#ifdef FEATURE_WLAN_ESE
815 pProfile->isESEAssoc = pSession->connectedProfile.isESEAssoc;
816 if (csrIsAuthTypeESE(pSession->connectedProfile.AuthType))
Jeff Johnson295189b2012-06-20 16:38:30 -0700817 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800818 vos_mem_copy (pProfile->eseCckmInfo.krk,
819 pSession->connectedProfile.eseCckmInfo.krk,
Kiet Lam64c1b492013-07-12 13:56:44 +0530820 CSR_KRK_KEY_LEN);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800821 pProfile->eseCckmInfo.reassoc_req_num=
822 pSession->connectedProfile.eseCckmInfo.reassoc_req_num;
823 pProfile->eseCckmInfo.krk_plumbed =
824 pSession->connectedProfile.eseCckmInfo.krk_plumbed;
Jeff Johnson295189b2012-06-20 16:38:30 -0700825 }
826#endif
827 }while(0);
828 }
829 }
830
831 return (status);
832}
833
Jeff Johnson295189b2012-06-20 16:38:30 -0700834eHalStatus csrRoamGetConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
835{
836 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700837
838 if((csrIsConnStateConnected(pMac, sessionId)) ||
839 (csrIsConnStateIbss(pMac, sessionId)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700840 {
841 if(pProfile)
842 {
843 status = csrRoamCopyConnectProfile(pMac, sessionId, pProfile);
844 }
845 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700846 return (status);
847}
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700848
Jeff Johnson295189b2012-06-20 16:38:30 -0700849eHalStatus csrRoamFreeConnectProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile)
850{
851 eHalStatus status = eHAL_STATUS_SUCCESS;
852
Kiet Lam64c1b492013-07-12 13:56:44 +0530853 if (pProfile->pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -0700854 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530855 vos_mem_free(pProfile->pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700856 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530857 if (pProfile->pAddIEAssoc)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700858 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530859 vos_mem_free(pProfile->pAddIEAssoc);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700860 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530861 vos_mem_set(pProfile, sizeof(tCsrRoamConnectedProfile), 0);
862
Jeff Johnson295189b2012-06-20 16:38:30 -0700863 pProfile->AuthType = eCSR_AUTH_TYPE_UNKNOWN;
864 return (status);
865}
866
Jeff Johnson295189b2012-06-20 16:38:30 -0700867static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo )
868{
869 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700870 if( pConnectedInfo->pbFrames )
871 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530872 vos_mem_free(pConnectedInfo->pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -0700873 pConnectedInfo->pbFrames = NULL;
874 }
875 pConnectedInfo->nBeaconLength = 0;
876 pConnectedInfo->nAssocReqLength = 0;
877 pConnectedInfo->nAssocRspLength = 0;
878 pConnectedInfo->staId = 0;
879#ifdef WLAN_FEATURE_VOWIFI_11R
880 pConnectedInfo->nRICRspLength = 0;
881#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800882#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700883 pConnectedInfo->nTspecIeLength = 0;
884#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700885 return ( status );
886}
887
Jeff Johnson295189b2012-06-20 16:38:30 -0700888
889
Jeff Johnsone7245742012-09-05 17:12:55 -0700890
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700891void csrReleaseCommandPreauth(tpAniSirGlobal pMac, tSmeCmd *pCommand)
892{
893 csrReinitPreauthCmd(pMac, pCommand);
894 csrReleaseCommand( pMac, pCommand );
895}
896
Jeff Johnson295189b2012-06-20 16:38:30 -0700897void csrReleaseCommandRoam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
898{
899 csrReinitRoamCmd(pMac, pCommand);
900 csrReleaseCommand( pMac, pCommand );
901}
902
Jeff Johnson295189b2012-06-20 16:38:30 -0700903void csrReleaseCommandScan(tpAniSirGlobal pMac, tSmeCmd *pCommand)
904{
905 csrReinitScanCmd(pMac, pCommand);
906 csrReleaseCommand( pMac, pCommand );
907}
908
Jeff Johnson295189b2012-06-20 16:38:30 -0700909void csrReleaseCommandWmStatusChange(tpAniSirGlobal pMac, tSmeCmd *pCommand)
910{
911 csrReinitWmStatusChangeCmd(pMac, pCommand);
912 csrReleaseCommand( pMac, pCommand );
913}
914
Jeff Johnson295189b2012-06-20 16:38:30 -0700915void csrReinitSetKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
916{
Kiet Lam64c1b492013-07-12 13:56:44 +0530917 vos_mem_set(&pCommand->u.setKeyCmd, sizeof(tSetKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700918}
919
Jeff Johnson295189b2012-06-20 16:38:30 -0700920void csrReinitRemoveKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
921{
Kiet Lam64c1b492013-07-12 13:56:44 +0530922 vos_mem_set(&pCommand->u.removeKeyCmd, sizeof(tRemoveKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700923}
924
Jeff Johnson295189b2012-06-20 16:38:30 -0700925void csrReleaseCommandSetKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
926{
927 csrReinitSetKeyCmd(pMac, pCommand);
928 csrReleaseCommand( pMac, pCommand );
929}
Jeff Johnson295189b2012-06-20 16:38:30 -0700930void csrReleaseCommandRemoveKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
931{
932 csrReinitRemoveKeyCmd(pMac, pCommand);
933 csrReleaseCommand( pMac, pCommand );
934}
Jeff Johnson295189b2012-06-20 16:38:30 -0700935void csrAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping )
936{
937
938 if( eSmeCsrCommandMask & pCommand->command )
939 {
940 switch (pCommand->command)
941 {
942 case eSmeCommandScan:
Jeff Johnson1250df42012-12-10 14:31:52 -0800943 // We need to inform the requester before dropping the scan command
Jeff Johnsonc7c54b12013-11-17 11:49:03 -0800944 smsLog( pMac, LOGW, "%s: Drop scan reason %d callback %p",
945 __func__, pCommand->u.scanCmd.reason,
946 pCommand->u.scanCmd.callback);
Jeff Johnson295189b2012-06-20 16:38:30 -0700947 if (NULL != pCommand->u.scanCmd.callback)
948 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800949 smsLog( pMac, LOGW, "%s callback scan requester", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700950 csrScanCallCallback(pMac, pCommand, eCSR_SCAN_ABORT);
951 }
952 csrReleaseCommandScan( pMac, pCommand );
953 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700954 case eSmeCommandRoam:
955 csrReleaseCommandRoam( pMac, pCommand );
956 break;
957
958 case eSmeCommandWmStatusChange:
959 csrReleaseCommandWmStatusChange( pMac, pCommand );
960 break;
961
962 case eSmeCommandSetKey:
963 csrReleaseCommandSetKey( pMac, pCommand );
964 break;
965
966 case eSmeCommandRemoveKey:
967 csrReleaseCommandRemoveKey( pMac, pCommand );
968 break;
969
970 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800971 smsLog( pMac, LOGW, " CSR abort standard command %d", pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -0700972 csrReleaseCommand( pMac, pCommand );
973 break;
974 }
975 }
976}
977
Jeff Johnson295189b2012-06-20 16:38:30 -0700978void csrRoamSubstateChange( tpAniSirGlobal pMac, eCsrRoamSubState NewSubstate, tANI_U32 sessionId)
979{
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +0530980 smsLog(pMac, LOG1, FL("CSR RoamSubstate: [ %s <== %s ]"),
981 macTraceGetcsrRoamSubState(NewSubstate),
982 macTraceGetcsrRoamSubState(pMac->roam.curSubState[sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -0700983
Jeff Johnson295189b2012-06-20 16:38:30 -0700984 if(pMac->roam.curSubState[sessionId] == NewSubstate)
985 {
986 return;
Jeff Johnsone7245742012-09-05 17:12:55 -0700987 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700988 pMac->roam.curSubState[sessionId] = NewSubstate;
989}
990
Jeff Johnson295189b2012-06-20 16:38:30 -0700991eCsrRoamState csrRoamStateChange( tpAniSirGlobal pMac, eCsrRoamState NewRoamState, tANI_U8 sessionId)
992{
993 eCsrRoamState PreviousState;
994
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +0530995 smsLog(pMac, LOG1, FL("CSR RoamState[%hu]: [ %s <== %s ]"), sessionId,
996 macTraceGetcsrRoamState(NewRoamState),
997 macTraceGetcsrRoamState(pMac->roam.curState[sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -0700998
999 PreviousState = pMac->roam.curState[sessionId];
1000
1001 if ( NewRoamState != pMac->roam.curState[sessionId] )
1002 {
1003 // Whenever we transition OUT of the Roaming state, clear the Roaming substate...
1004 if ( CSR_IS_ROAM_JOINING(pMac, sessionId) )
1005 {
1006 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
1007 }
1008
1009 pMac->roam.curState[sessionId] = NewRoamState;
1010 }
1011 return( PreviousState );
1012}
1013
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001014void csrAssignRssiForCategory(tpAniSirGlobal pMac, tANI_S8 bestApRssi, tANI_U8 catOffset)
Jeff Johnson295189b2012-06-20 16:38:30 -07001015{
1016 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001017 if(catOffset)
1018 {
1019 pMac->roam.configParam.bCatRssiOffset = catOffset;
1020 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
1021 {
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001022 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 -07001023 }
1024 }
1025}
1026
Jeff Johnson295189b2012-06-20 16:38:30 -07001027static void initConfigParam(tpAniSirGlobal pMac)
1028{
1029 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001030 pMac->roam.configParam.agingCount = CSR_AGING_COUNT;
Sandeep Puligilla60342762014-01-30 21:05:37 +05301031 pMac->roam.configParam.channelBondingMode24GHz =
1032 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
1033 pMac->roam.configParam.channelBondingMode5GHz =
1034 WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001035 pMac->roam.configParam.phyMode = eCSR_DOT11_MODE_TAURUS;
1036 pMac->roam.configParam.eBand = eCSR_BAND_ALL;
1037 pMac->roam.configParam.uCfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
1038 pMac->roam.configParam.FragmentationThreshold = eCSR_DOT11_FRAG_THRESH_DEFAULT;
1039 pMac->roam.configParam.HeartbeatThresh24 = 40;
1040 pMac->roam.configParam.HeartbeatThresh50 = 40;
1041 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
1042 pMac->roam.configParam.Is11dSupportEnabledOriginal = eANI_BOOLEAN_FALSE;
1043 pMac->roam.configParam.Is11eSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001044 pMac->roam.configParam.Is11hSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001045 pMac->roam.configParam.RTSThreshold = 2346;
1046 pMac->roam.configParam.shortSlotTime = eANI_BOOLEAN_TRUE;
1047 pMac->roam.configParam.WMMSupportMode = eCsrRoamWmmAuto;
1048 pMac->roam.configParam.ProprietaryRatesEnabled = eANI_BOOLEAN_TRUE;
1049 pMac->roam.configParam.TxRate = eCSR_TX_RATE_AUTO;
1050 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1051 pMac->roam.configParam.scanAgeTimeNCNPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_NO_PS;
1052 pMac->roam.configParam.scanAgeTimeNCPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_W_PS;
1053 pMac->roam.configParam.scanAgeTimeCNPS = CSR_SCAN_AGING_TIME_CONNECT_NO_PS;
1054 pMac->roam.configParam.scanAgeTimeCPS = CSR_SCAN_AGING_TIME_CONNECT_W_PS;
1055 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
1056 {
1057 pMac->roam.configParam.BssPreferValue[i] = i;
1058 }
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001059 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, CSR_DEFAULT_RSSI_DB_GAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07001060 pMac->roam.configParam.nRoamingTime = CSR_DEFAULT_ROAMING_TIME;
1061 pMac->roam.configParam.fEnforce11dChannels = eANI_BOOLEAN_FALSE;
1062 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001063 pMac->roam.configParam.fEnforceCountryCodeMatch = eANI_BOOLEAN_FALSE;
1064 pMac->roam.configParam.fEnforceDefaultDomain = eANI_BOOLEAN_FALSE;
1065 pMac->roam.configParam.nActiveMaxChnTime = CSR_ACTIVE_MAX_CHANNEL_TIME;
1066 pMac->roam.configParam.nActiveMinChnTime = CSR_ACTIVE_MIN_CHANNEL_TIME;
1067 pMac->roam.configParam.nPassiveMaxChnTime = CSR_PASSIVE_MAX_CHANNEL_TIME;
1068 pMac->roam.configParam.nPassiveMinChnTime = CSR_PASSIVE_MIN_CHANNEL_TIME;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001069 pMac->roam.configParam.nActiveMaxChnTimeBtc = CSR_ACTIVE_MAX_CHANNEL_TIME_BTC;
1070 pMac->roam.configParam.nActiveMinChnTimeBtc = CSR_ACTIVE_MIN_CHANNEL_TIME_BTC;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001071 pMac->roam.configParam.disableAggWithBtc = eANI_BOOLEAN_TRUE;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001072#ifdef WLAN_AP_STA_CONCURRENCY
1073 pMac->roam.configParam.nActiveMaxChnTimeConc = CSR_ACTIVE_MAX_CHANNEL_TIME_CONC;
1074 pMac->roam.configParam.nActiveMinChnTimeConc = CSR_ACTIVE_MIN_CHANNEL_TIME_CONC;
1075 pMac->roam.configParam.nPassiveMaxChnTimeConc = CSR_PASSIVE_MAX_CHANNEL_TIME_CONC;
1076 pMac->roam.configParam.nPassiveMinChnTimeConc = CSR_PASSIVE_MIN_CHANNEL_TIME_CONC;
1077 pMac->roam.configParam.nRestTimeConc = CSR_REST_TIME_CONC;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001078 pMac->roam.configParam.nNumStaChanCombinedConc = CSR_NUM_STA_CHAN_COMBINED_CONC;
1079 pMac->roam.configParam.nNumP2PChanCombinedConc = CSR_NUM_P2P_CHAN_COMBINED_CONC;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001080#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001081 pMac->roam.configParam.IsIdleScanEnabled = TRUE; //enable the idle scan by default
1082 pMac->roam.configParam.nTxPowerCap = CSR_MAX_TX_POWER;
1083 pMac->roam.configParam.statsReqPeriodicity = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD;
1084 pMac->roam.configParam.statsReqPeriodicityInPS = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001085#ifdef WLAN_FEATURE_VOWIFI_11R
1086 pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported = 0;
1087#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001088#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1089 pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries = 3;
1090 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold = 120;
1091 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold = 125;
1092 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = 20;
1093 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = 40;
1094 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod = 200;
1095 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels = 3;
1096 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[0] = 1;
1097 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[1] = 6;
1098 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[2] = 11;
1099 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod = 20000; //20 seconds
Srinivas Girigowdade697412013-02-14 16:31:48 -08001100 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001101#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001102#ifdef WLAN_FEATURE_11AC
1103 pMac->roam.configParam.nVhtChannelWidth = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ + 1;
1104#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001105
1106 pMac->roam.configParam.addTSWhenACMIsOff = 0;
1107 pMac->roam.configParam.fScanTwice = eANI_BOOLEAN_FALSE;
Mohit Khanna349bc392012-09-11 17:24:52 -07001108
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001109 //Remove this code once SLM_Sessionization is supported
1110 //BMPS_WORKAROUND_NOT_NEEDED
Jeff Johnsone7245742012-09-05 17:12:55 -07001111 pMac->roam.configParam.doBMPSWorkaround = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001112
Jeff Johnsone7245742012-09-05 17:12:55 -07001113}
Jeff Johnson295189b2012-06-20 16:38:30 -07001114eCsrBand csrGetCurrentBand(tHalHandle hHal)
1115{
1116 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1117 return pMac->roam.configParam.bandCapability;
1118}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001119
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001120
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001121#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001122/*
1123 This function flushes the roam scan cache
1124*/
1125eHalStatus csrFlushRoamScanRoamChannelList(tpAniSirGlobal pMac)
1126{
1127 eHalStatus status = eHAL_STATUS_SUCCESS;
1128 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1129
1130 /* Free up the memory first (if required) */
1131 if (NULL != pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
1132 {
1133 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1134 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
1135 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
1136 }
1137 return status;
1138}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001139#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001140
1141
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001142#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001143/*
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001144 This function flushes the roam scan cache
Srinivas Girigowdade697412013-02-14 16:31:48 -08001145*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001146eHalStatus csrFlushCfgBgScanRoamChannelList(tpAniSirGlobal pMac)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001147{
1148 eHalStatus status = eHAL_STATUS_SUCCESS;
1149 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1150
1151 /* Free up the memory first (if required) */
1152 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1153 {
1154 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
1155 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001156 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001157 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001158 return status;
1159}
1160
1161
1162
1163/*
1164 This function flushes the roam scan cache and creates fresh cache
1165 based on the input channel list
1166*/
1167eHalStatus csrCreateBgScanRoamChannelList(tpAniSirGlobal pMac,
1168 const tANI_U8 *pChannelList,
1169 const tANI_U8 numChannels)
1170{
1171 eHalStatus status = eHAL_STATUS_SUCCESS;
1172 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1173
Srinivas Girigowdade697412013-02-14 16:31:48 -08001174 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = numChannels;
1175
1176 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
1177 vos_mem_malloc(pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1178
1179 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1180 {
1181 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
1182 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
1183 return eHAL_STATUS_RESOURCES;
1184 }
1185
1186 /* Update the roam global structure */
Kiet Lam64c1b492013-07-12 13:56:44 +05301187 vos_mem_copy(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
1188 pChannelList,
1189 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001190 return status;
1191}
1192
1193/* This function modifies the bgscan channel list set via config ini or
1194 runtime, whenever the band changes.
1195 if the band is auto, then no operation is performed on the channel list
1196 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1197 if the band is 5G, then make sure channel list contains only 5G valid channels
1198*/
1199eHalStatus csrUpdateBgScanConfigIniChannelList(tpAniSirGlobal pMac,
1200 eCsrBand eBand)
1201{
1202 eHalStatus status = eHAL_STATUS_SUCCESS;
1203 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1204 tANI_U8 outNumChannels = 0;
1205 tANI_U8 inNumChannels = 0;
1206 tANI_U8 *inPtr = NULL;
1207 tANI_U8 i = 0;
1208 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1209
1210 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1211
1212 {
1213 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1214 "No update required for channel list "
1215 "either cfg.ini channel list is not set up or "
1216 "auto band (Band %d)", eBand);
1217 return status;
1218 }
1219
1220 inNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
1221 inPtr = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
1222 if (eCSR_BAND_24 == eBand)
1223 {
1224 for (i = 0; i < inNumChannels; i++)
1225 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001226 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
Srinivas Girigowdade697412013-02-14 16:31:48 -08001227 {
1228 ChannelList[outNumChannels++] = inPtr[i];
1229 }
1230 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001231 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001232 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001233 }
1234 else if (eCSR_BAND_5G == eBand)
1235 {
1236 for (i = 0; i < inNumChannels; i++)
1237 {
1238 /* Add 5G Non-DFS channel */
1239 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
Srinivas Girigowda56076852013-08-20 14:00:50 -07001240 csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001241 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1242 {
1243 ChannelList[outNumChannels++] = inPtr[i];
1244 }
1245 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001246 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001247 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001248 }
1249 else if (eCSR_BAND_ALL == eBand)
1250 {
1251 for (i = 0; i < inNumChannels; i++)
1252 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001253 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001254 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1255 {
1256 ChannelList[outNumChannels++] = inPtr[i];
1257 }
1258 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001259 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001260 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001261 }
1262 else
1263 {
1264 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1265 "Invalid band, No operation carried out (Band %d)", eBand);
1266 status = eHAL_STATUS_INVALID_PARAMETER;
1267 }
1268
1269 return status;
1270}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001271#endif
1272
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001273#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001274/* This function modifies the roam scan channel list as per AP neighbor
1275 report; AP neighbor report may be empty or may include only other AP
1276 channels; in any case, we merge the channel list with the learned occupied
1277 channels list.
1278 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1279 if the band is 5G, then make sure channel list contains only 5G valid channels
1280*/
1281eHalStatus csrCreateRoamScanChannelList(tpAniSirGlobal pMac,
1282 tANI_U8 *pChannelList,
1283 tANI_U8 numChannels,
1284 const eCsrBand eBand)
1285{
1286 eHalStatus status = eHAL_STATUS_SUCCESS;
1287 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1288 tANI_U8 outNumChannels = 0;
1289 tANI_U8 inNumChannels = numChannels;
1290 tANI_U8 *inPtr = pChannelList;
1291 tANI_U8 i = 0;
1292 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1293 tANI_U8 tmpChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1294 tANI_U8 mergedOutputNumOfChannels = 0;
1295 tpCsrChannelInfo currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
1296
1297 /* Create a Union of occupied channel list learnt by the DUT along with the Neighbor
1298 * report Channels. This increases the chances of the DUT to get a candidate AP while
1299 * roaming even if the Neighbor Report is not able to provide sufficient information. */
1300 if (pMac->scan.occupiedChannels.numChannels)
1301 {
1302 csrNeighborRoamMergeChannelLists(pMac,
1303 &pMac->scan.occupiedChannels.channelList[0],
1304 pMac->scan.occupiedChannels.numChannels,
1305 inPtr,
1306 inNumChannels,
1307 &mergedOutputNumOfChannels);
1308 inNumChannels = mergedOutputNumOfChannels;
1309 }
1310
1311 if (eCSR_BAND_24 == eBand)
1312 {
1313 for (i = 0; i < inNumChannels; i++)
1314 {
1315 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
1316 {
1317 ChannelList[outNumChannels++] = inPtr[i];
1318 }
1319 }
1320 }
1321 else if (eCSR_BAND_5G == eBand)
1322 {
1323 for (i = 0; i < inNumChannels; i++)
1324 {
1325 /* Add 5G Non-DFS channel */
1326 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
1327 csrRoamIsChannelValid(pMac, inPtr[i]) &&
1328 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1329 {
1330 ChannelList[outNumChannels++] = inPtr[i];
1331 }
1332 }
1333 }
1334 else if (eCSR_BAND_ALL == eBand)
1335 {
1336 for (i = 0; i < inNumChannels; i++)
1337 {
1338 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
1339 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1340 {
1341 ChannelList[outNumChannels++] = inPtr[i];
1342 }
1343 }
1344 }
1345 else
1346 {
1347 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1348 "Invalid band, No operation carried out (Band %d)", eBand);
1349 return eHAL_STATUS_INVALID_PARAMETER;
1350 }
1351
1352 /* if roaming within band is enabled, then select only the
1353 in band channels .
1354 This is required only if the band capability is set to ALL,
1355 E.g., if band capability is only 2.4G then all the channels in the
1356 list are already filtered for 2.4G channels, hence ignore this check*/
1357
1358 if ((eCSR_BAND_ALL == eBand) && CSR_IS_ROAM_INTRA_BAND_ENABLED(pMac))
1359 {
1360 csrNeighborRoamChannelsFilterByCurrentBand(
1361 pMac,
1362 ChannelList,
1363 outNumChannels,
1364 tmpChannelList,
1365 &outNumChannels);
Kiet Lamf2f201e2013-11-16 21:24:16 +05301366 vos_mem_copy(ChannelList,
1367 tmpChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001368 }
1369
1370 /* Prepare final roam scan channel list */
1371 if(outNumChannels)
1372 {
1373 /* Clear the channel list first */
1374 if (NULL != currChannelListInfo->ChannelList)
1375 {
1376 vos_mem_free(currChannelListInfo->ChannelList);
1377 currChannelListInfo->ChannelList = NULL;
1378 currChannelListInfo->numOfChannels = 0;
1379 }
1380
1381 currChannelListInfo->ChannelList = vos_mem_malloc(outNumChannels * sizeof(tANI_U8));
1382 if (NULL == currChannelListInfo->ChannelList)
1383 {
1384 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
1385 "Failed to allocate memory for roam scan channel list");
1386 currChannelListInfo->numOfChannels = 0;
1387 return VOS_STATUS_E_RESOURCES;
1388 }
Kiet Lamf2f201e2013-11-16 21:24:16 +05301389 vos_mem_copy(currChannelListInfo->ChannelList,
1390 ChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001391 }
1392 return status;
1393}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001394#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001395
Jeff Johnson295189b2012-06-20 16:38:30 -07001396eHalStatus csrSetBand(tHalHandle hHal, eCsrBand eBand)
1397{
1398 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1399 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001400 if (CSR_IS_PHY_MODE_A_ONLY(pMac) &&
1401 (eBand == eCSR_BAND_24))
1402 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001403 /* DOT11 mode configured to 11a only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001404 request to change the band to 2.4 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001405 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001406 "failed to set band cfg80211 = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001407 pMac->roam.configParam.uCfgDot11Mode, eBand);
1408 return eHAL_STATUS_INVALID_PARAMETER;
1409 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001410 if ((CSR_IS_PHY_MODE_B_ONLY(pMac) ||
1411 CSR_IS_PHY_MODE_G_ONLY(pMac)) &&
1412 (eBand == eCSR_BAND_5G))
1413 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001414 /* DOT11 mode configured to 11b/11g only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001415 request to change the band to 5 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001416 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001417 "failed to set band dot11mode = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001418 pMac->roam.configParam.uCfgDot11Mode, eBand);
1419 return eHAL_STATUS_INVALID_PARAMETER;
1420 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001421 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001422 "Band changed to %u (0 - ALL, 1 - 2.4 GHZ, 2 - 5GHZ)", eBand);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001423 pMac->roam.configParam.eBand = eBand;
1424 pMac->roam.configParam.bandCapability = eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001425 csrScanGetSupportedChannels( pMac );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001426#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -08001427 if (!csrRoamIsRoamOffloadScanEnabled(pMac))
1428 csrUpdateBgScanConfigIniChannelList( pMac, eBand );
Srinivas Girigowdade697412013-02-14 16:31:48 -08001429#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001430 status = csrInitGetChannels( pMac );
1431 if (eHAL_STATUS_SUCCESS == status)
1432 csrInitChannelList( hHal );
1433 return status;
1434}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001435
1436
Jeff Johnsone7245742012-09-05 17:12:55 -07001437/* The funcns csrConvertCBIniValueToPhyCBState and csrConvertPhyCBStateToIniValue have been
1438 * introduced to convert the ini value to the ENUM used in csr and MAC for CB state
1439 * Ideally we should have kept the ini value and enum value same and representing the same
1440 * cb values as in 11n standard i.e.
1441 * Set to 1 (SCA) if the secondary channel is above the primary channel
1442 * Set to 3 (SCB) if the secondary channel is below the primary channel
1443 * Set to 0 (SCN) if no secondary channel is present
1444 * However, since our driver is already distributed we will keep the ini definition as it is which is:
1445 * 0 - secondary none
1446 * 1 - secondary LOW
1447 * 2 - secondary HIGH
1448 * and convert to enum value used within the driver in csrChangeDefaultConfigParam using this funcn
1449 * The enum values are as follows:
1450 * PHY_SINGLE_CHANNEL_CENTERED = 0
1451 * PHY_DOUBLE_CHANNEL_LOW_PRIMARY = 1
1452 * PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
1453 */
1454ePhyChanBondState csrConvertCBIniValueToPhyCBState(v_U32_t cbIniValue)
1455{
1456
1457 ePhyChanBondState phyCbState;
1458 switch (cbIniValue) {
1459 // secondary none
1460 case 0:
1461 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1462 break;
1463 // secondary LOW
1464 case 1:
1465 phyCbState = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1466 break;
1467 // secondary HIGH
1468 case 2:
1469 phyCbState = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1470 break;
1471#ifdef WLAN_FEATURE_11AC
1472 case 3:
1473 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
1474 break;
1475 case 4:
1476 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1477 break;
1478 case 5:
1479 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1480 break;
1481 case 6:
1482 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
1483 break;
1484 case 7:
1485 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
1486 break;
1487 case 8:
1488 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
1489 break;
1490 case 9:
1491 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
1492 break;
1493#endif
1494 default:
1495 // If an invalid value is passed, disable CHANNEL BONDING
1496 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1497 break;
1498 }
1499 return phyCbState;
1500}
1501
1502v_U32_t csrConvertPhyCBStateToIniValue(ePhyChanBondState phyCbState)
1503{
1504
1505 v_U32_t cbIniValue;
1506 switch (phyCbState) {
1507 // secondary none
1508 case PHY_SINGLE_CHANNEL_CENTERED:
1509 cbIniValue = 0;
1510 break;
1511 // secondary LOW
1512 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
1513 cbIniValue = 1;
1514 break;
1515 // secondary HIGH
1516 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
1517 cbIniValue = 2;
1518 break;
1519#ifdef WLAN_FEATURE_11AC
1520 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1521 cbIniValue = 3;
1522 break;
1523 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
1524 cbIniValue = 4;
1525 break;
1526 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1527 cbIniValue = 5;
1528 break;
1529 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
1530 cbIniValue = 6;
1531 break;
1532 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
1533 cbIniValue = 7;
1534 break;
1535 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
1536 cbIniValue = 8;
1537 break;
1538 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
1539 cbIniValue = 9;
1540 break;
1541#endif
1542 default:
1543 // return some invalid value
1544 cbIniValue = 10;
1545 break;
1546 }
1547 return cbIniValue;
1548}
Jeff Johnson295189b2012-06-20 16:38:30 -07001549
1550eHalStatus csrChangeDefaultConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1551{
1552 eHalStatus status = eHAL_STATUS_SUCCESS;
1553
1554 if(pParam)
1555 {
1556 pMac->roam.configParam.WMMSupportMode = pParam->WMMSupportMode;
1557 pMac->roam.configParam.Is11eSupportEnabled = pParam->Is11eSupportEnabled;
1558 pMac->roam.configParam.FragmentationThreshold = pParam->FragmentationThreshold;
1559 pMac->roam.configParam.Is11dSupportEnabled = pParam->Is11dSupportEnabled;
1560 pMac->roam.configParam.Is11dSupportEnabledOriginal = pParam->Is11dSupportEnabled;
1561 pMac->roam.configParam.Is11hSupportEnabled = pParam->Is11hSupportEnabled;
1562
1563 pMac->roam.configParam.fenableMCCMode = pParam->fEnableMCCMode;
Mohit Khanna7ed53f02012-09-11 17:52:10 -07001564 pMac->roam.configParam.fAllowMCCGODiffBI = pParam->fAllowMCCGODiffBI;
1565
Jeff Johnsone7245742012-09-05 17:12:55 -07001566 /* channelBondingMode5GHz plays a dual role right now
1567 * 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
1568 * This is how channelBondingMode5GHz works now and this is kept intact to avoid any cfg.ini change
1569 */
1570 if (pParam->channelBondingMode24GHz > MAX_CB_VALUE_IN_INI)
1571 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001572 smsLog( pMac, LOGW, "Invalid CB value from ini in 2.4GHz band %d, CB DISABLED", pParam->channelBondingMode24GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001573 }
1574 pMac->roam.configParam.channelBondingMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode24GHz);
1575 if (pParam->channelBondingMode5GHz > MAX_CB_VALUE_IN_INI)
1576 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001577 smsLog( pMac, LOGW, "Invalid CB value from ini in 5GHz band %d, CB DISABLED", pParam->channelBondingMode5GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001578 }
1579 pMac->roam.configParam.channelBondingMode5GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001580 pMac->roam.configParam.RTSThreshold = pParam->RTSThreshold;
1581 pMac->roam.configParam.phyMode = pParam->phyMode;
1582 pMac->roam.configParam.shortSlotTime = pParam->shortSlotTime;
1583 pMac->roam.configParam.HeartbeatThresh24 = pParam->HeartbeatThresh24;
1584 pMac->roam.configParam.HeartbeatThresh50 = pParam->HeartbeatThresh50;
1585 pMac->roam.configParam.ProprietaryRatesEnabled = pParam->ProprietaryRatesEnabled;
1586 pMac->roam.configParam.TxRate = pParam->TxRate;
1587 pMac->roam.configParam.AdHocChannel24 = pParam->AdHocChannel24;
1588 pMac->roam.configParam.AdHocChannel5G = pParam->AdHocChannel5G;
1589 pMac->roam.configParam.bandCapability = pParam->bandCapability;
1590 pMac->roam.configParam.cbChoice = pParam->cbChoice;
1591 pMac->roam.configParam.bgScanInterval = pParam->bgScanInterval;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001592 pMac->roam.configParam.disableAggWithBtc = pParam->disableAggWithBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001593 //if HDD passed down non zero values then only update,
1594 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001595 if (pParam->nActiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001596 {
1597 pMac->roam.configParam.nActiveMaxChnTime = pParam->nActiveMaxChnTime;
1598 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001599 if (pParam->nActiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001600 {
1601 pMac->roam.configParam.nActiveMinChnTime = pParam->nActiveMinChnTime;
1602 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001603 if (pParam->nPassiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001604 {
1605 pMac->roam.configParam.nPassiveMaxChnTime = pParam->nPassiveMaxChnTime;
1606 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001607 if (pParam->nPassiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001608 {
1609 pMac->roam.configParam.nPassiveMinChnTime = pParam->nPassiveMinChnTime;
1610 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001611 if (pParam->nActiveMaxChnTimeBtc)
1612 {
1613 pMac->roam.configParam.nActiveMaxChnTimeBtc = pParam->nActiveMaxChnTimeBtc;
1614 }
1615 if (pParam->nActiveMinChnTimeBtc)
1616 {
1617 pMac->roam.configParam.nActiveMinChnTimeBtc = pParam->nActiveMinChnTimeBtc;
1618 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001619#ifdef WLAN_AP_STA_CONCURRENCY
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001620 if (pParam->nActiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001621 {
1622 pMac->roam.configParam.nActiveMaxChnTimeConc = pParam->nActiveMaxChnTimeConc;
1623 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001624 if (pParam->nActiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001625 {
1626 pMac->roam.configParam.nActiveMinChnTimeConc = pParam->nActiveMinChnTimeConc;
1627 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001628 if (pParam->nPassiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001629 {
1630 pMac->roam.configParam.nPassiveMaxChnTimeConc = pParam->nPassiveMaxChnTimeConc;
1631 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001632 if (pParam->nPassiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001633 {
1634 pMac->roam.configParam.nPassiveMinChnTimeConc = pParam->nPassiveMinChnTimeConc;
1635 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001636 if (pParam->nRestTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001637 {
1638 pMac->roam.configParam.nRestTimeConc = pParam->nRestTimeConc;
1639 }
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001640 if (pParam->nNumStaChanCombinedConc)
Vinay Malekal05fdc812012-12-17 13:04:30 -08001641 {
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001642 pMac->roam.configParam.nNumStaChanCombinedConc = pParam->nNumStaChanCombinedConc;
1643 }
1644 if (pParam->nNumP2PChanCombinedConc)
1645 {
1646 pMac->roam.configParam.nNumP2PChanCombinedConc = pParam->nNumP2PChanCombinedConc;
Vinay Malekal05fdc812012-12-17 13:04:30 -08001647 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001648#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001649 //if upper layer wants to disable idle scan altogether set it to 0
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001650 if (pParam->impsSleepTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001651 {
1652 //Change the unit from second to microsecond
1653 tANI_U32 impsSleepTime = pParam->impsSleepTime * PAL_TIMER_TO_SEC_UNIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07001654 if(CSR_IDLE_SCAN_NO_PS_INTERVAL_MIN <= impsSleepTime)
1655 {
1656 pMac->roam.configParam.impsSleepTime = impsSleepTime;
1657 }
1658 else
1659 {
1660 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1661 }
1662 }
1663 else
1664 {
1665 pMac->roam.configParam.impsSleepTime = 0;
1666 }
1667 pMac->roam.configParam.eBand = pParam->eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001668 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(NULL, pMac->roam.configParam.phyMode,
1669 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07001670 //if HDD passed down non zero values for age params, then only update,
1671 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001672 if (pParam->nScanResultAgeCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07001673 {
1674 pMac->roam.configParam.agingCount = pParam->nScanResultAgeCount;
1675 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001676 if(pParam->scanAgeTimeNCNPS)
1677 {
1678 pMac->roam.configParam.scanAgeTimeNCNPS = pParam->scanAgeTimeNCNPS;
1679 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001680 if(pParam->scanAgeTimeNCPS)
1681 {
1682 pMac->roam.configParam.scanAgeTimeNCPS = pParam->scanAgeTimeNCPS;
1683 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001684 if(pParam->scanAgeTimeCNPS)
1685 {
1686 pMac->roam.configParam.scanAgeTimeCNPS = pParam->scanAgeTimeCNPS;
1687 }
1688 if(pParam->scanAgeTimeCPS)
1689 {
1690 pMac->roam.configParam.scanAgeTimeCPS = pParam->scanAgeTimeCPS;
1691 }
1692
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001693 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, pParam->bCatRssiOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07001694 pMac->roam.configParam.nRoamingTime = pParam->nRoamingTime;
1695 pMac->roam.configParam.fEnforce11dChannels = pParam->fEnforce11dChannels;
1696 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = pParam->fSupplicantCountryCodeHasPriority;
1697 pMac->roam.configParam.fEnforceCountryCodeMatch = pParam->fEnforceCountryCodeMatch;
1698 pMac->roam.configParam.fEnforceDefaultDomain = pParam->fEnforceDefaultDomain;
Jeff Johnson295189b2012-06-20 16:38:30 -07001699 pMac->roam.configParam.vccRssiThreshold = pParam->vccRssiThreshold;
1700 pMac->roam.configParam.vccUlMacLossThreshold = pParam->vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001701 pMac->roam.configParam.IsIdleScanEnabled = pParam->IsIdleScanEnabled;
1702 pMac->roam.configParam.statsReqPeriodicity = pParam->statsReqPeriodicity;
1703 pMac->roam.configParam.statsReqPeriodicityInPS = pParam->statsReqPeriodicityInPS;
1704 //Assign this before calling CsrInit11dInfo
1705 pMac->roam.configParam.nTxPowerCap = pParam->nTxPowerCap;
Jeff Johnson295189b2012-06-20 16:38:30 -07001706 if( csrIs11dSupported( pMac ) )
1707 {
1708 status = CsrInit11dInfo(pMac, &pParam->Csr11dinfo);
1709 }
1710 else
1711 {
1712 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
1713 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001714
1715 /* Initialize the power + channel information if 11h is enabled.
1716 If 11d is enabled this information has already been initialized */
1717 if( csrIs11hSupported( pMac ) && !csrIs11dSupported( pMac ) )
1718 {
1719 csrInitChannelPowerList(pMac, &pParam->Csr11dinfo);
1720 }
1721
1722
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05301723#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05301724 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
1725 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001726 smsLog( pMac, LOG1, "IsFTResourceReqSupp = %d", pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07001727#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001728#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001729 pMac->roam.configParam.isFastTransitionEnabled = pParam->isFastTransitionEnabled;
Jeff Johnson43971f52012-07-17 12:26:56 -07001730 pMac->roam.configParam.RoamRssiDiff = pParam->RoamRssiDiff;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001731 pMac->roam.configParam.nImmediateRoamRssiDiff = pParam->nImmediateRoamRssiDiff;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001732 smsLog( pMac, LOG1, "nImmediateRoamRssiDiff = %d",
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001733 pMac->roam.configParam.nImmediateRoamRssiDiff );
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08001734 pMac->roam.configParam.nRoamPrefer5GHz = pParam->nRoamPrefer5GHz;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07001735 pMac->roam.configParam.nRoamIntraBand = pParam->nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07001736 pMac->roam.configParam.isWESModeEnabled = pParam->isWESModeEnabled;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001737 pMac->roam.configParam.nProbes = pParam->nProbes;
1738 pMac->roam.configParam.nRoamScanHomeAwayTime = pParam->nRoamScanHomeAwayTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001739#endif
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001740#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1741 pMac->roam.configParam.isRoamOffloadScanEnabled = pParam->isRoamOffloadScanEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001742 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled = pParam->bFastRoamInConIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001743#endif
1744#ifdef FEATURE_WLAN_LFR
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001745 pMac->roam.configParam.isFastRoamIniFeatureEnabled = pParam->isFastRoamIniFeatureEnabled;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -08001746 pMac->roam.configParam.MAWCEnabled = pParam->MAWCEnabled;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001747#endif
1748
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001749#ifdef FEATURE_WLAN_ESE
1750 pMac->roam.configParam.isEseIniFeatureEnabled = pParam->isEseIniFeatureEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001751#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001752#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301753 vos_mem_copy(&pMac->roam.configParam.neighborRoamConfig,
1754 &pParam->neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001755 smsLog( pMac, LOG1, "nNeighborScanTimerPerioid = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod);
1756 smsLog( pMac, LOG1, "nNeighborReassocRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold);
1757 smsLog( pMac, LOG1, "nNeighborLookupRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold);
1758 smsLog( pMac, LOG1, "nNeighborScanMinChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime);
1759 smsLog( pMac, LOG1, "nNeighborScanMaxChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime);
1760 smsLog( pMac, LOG1, "nMaxNeighborRetries = %d", pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries);
1761 smsLog( pMac, LOG1, "nNeighborResultsRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod);
1762 smsLog( pMac, LOG1, "nEmptyScanRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07001763 {
1764 int i;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001765 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 -07001766 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1767 {
1768 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1769 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001770 }
1771#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001772 pMac->roam.configParam.addTSWhenACMIsOff = pParam->addTSWhenACMIsOff;
1773 pMac->scan.fValidateList = pParam->fValidateList;
1774 pMac->scan.fEnableBypass11d = pParam->fEnableBypass11d;
1775 pMac->scan.fEnableDFSChnlScan = pParam->fEnableDFSChnlScan;
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08001776 pMac->scan.scanResultCfgAgingTime = pParam->scanCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001777 pMac->roam.configParam.fScanTwice = pParam->fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001778 pMac->scan.fFirstScanOnly2GChnl = pParam->fFirstScanOnly2GChnl;
1779 /* This parameter is not available in cfg and not passed from upper layers. Instead it is initialized here
1780 * This paramtere is used in concurrency to determine if there are concurrent active sessions.
1781 * Is used as a temporary fix to disconnect all active sessions when BMPS enabled so the active session if Infra STA
1782 * will automatically connect back and resume BMPS since resume BMPS is not working when moving from concurrent to
1783 * single session
1784 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001785 //Remove this code once SLM_Sessionization is supported
1786 //BMPS_WORKAROUND_NOT_NEEDED
Mohit Khanna349bc392012-09-11 17:24:52 -07001787 pMac->roam.configParam.doBMPSWorkaround = 0;
1788
Jeff Johnsone7245742012-09-05 17:12:55 -07001789#ifdef WLAN_FEATURE_11AC
1790 pMac->roam.configParam.nVhtChannelWidth = pParam->nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001791 pMac->roam.configParam.txBFEnable= pParam->enableTxBF;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001792 pMac->roam.configParam.txBFCsnValue = pParam->txBFCsnValue;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07001793 pMac->roam.configParam.enableVhtFor24GHz = pParam->enableVhtFor24GHz;
Jeff Johnsone7245742012-09-05 17:12:55 -07001794#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08001795 pMac->roam.configParam.txLdpcEnable = pParam->enableTxLdpc;
krunal soni5afa96c2013-09-06 22:19:02 -07001796
1797 pMac->roam.configParam.isAmsduSupportInAMPDU = pParam->isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001798 pMac->roam.configParam.nSelect5GHzMargin = pParam->nSelect5GHzMargin;
krunal sonie9002db2013-11-25 14:24:17 -08001799 pMac->roam.configParam.isCoalesingInIBSSAllowed =
1800 pParam->isCoalesingInIBSSAllowed;
Jeff Johnson295189b2012-06-20 16:38:30 -07001801 }
1802
1803 return status;
1804}
1805
Jeff Johnson295189b2012-06-20 16:38:30 -07001806eHalStatus csrGetConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1807{
1808 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07001809 if(pParam)
1810 {
1811 pParam->WMMSupportMode = pMac->roam.configParam.WMMSupportMode;
1812 pParam->Is11eSupportEnabled = pMac->roam.configParam.Is11eSupportEnabled;
1813 pParam->FragmentationThreshold = pMac->roam.configParam.FragmentationThreshold;
1814 pParam->Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabled;
1815 pParam->Is11dSupportEnabledOriginal = pMac->roam.configParam.Is11dSupportEnabledOriginal;
1816 pParam->Is11hSupportEnabled = pMac->roam.configParam.Is11hSupportEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07001817 pParam->channelBondingMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode24GHz);
1818 pParam->channelBondingMode5GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001819 pParam->RTSThreshold = pMac->roam.configParam.RTSThreshold;
1820 pParam->phyMode = pMac->roam.configParam.phyMode;
1821 pParam->shortSlotTime = pMac->roam.configParam.shortSlotTime;
1822 pParam->HeartbeatThresh24 = pMac->roam.configParam.HeartbeatThresh24;
1823 pParam->HeartbeatThresh50 = pMac->roam.configParam.HeartbeatThresh50;
1824 pParam->ProprietaryRatesEnabled = pMac->roam.configParam.ProprietaryRatesEnabled;
1825 pParam->TxRate = pMac->roam.configParam.TxRate;
1826 pParam->AdHocChannel24 = pMac->roam.configParam.AdHocChannel24;
1827 pParam->AdHocChannel5G = pMac->roam.configParam.AdHocChannel5G;
1828 pParam->bandCapability = pMac->roam.configParam.bandCapability;
1829 pParam->cbChoice = pMac->roam.configParam.cbChoice;
1830 pParam->bgScanInterval = pMac->roam.configParam.bgScanInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07001831 pParam->nActiveMaxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
1832 pParam->nActiveMinChnTime = pMac->roam.configParam.nActiveMinChnTime;
1833 pParam->nPassiveMaxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
1834 pParam->nPassiveMinChnTime = pMac->roam.configParam.nPassiveMinChnTime;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001835 pParam->nActiveMaxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
1836 pParam->nActiveMinChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
1837 pParam->disableAggWithBtc = pMac->roam.configParam.disableAggWithBtc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001838#ifdef WLAN_AP_STA_CONCURRENCY
1839 pParam->nActiveMaxChnTimeConc = pMac->roam.configParam.nActiveMaxChnTimeConc;
1840 pParam->nActiveMinChnTimeConc = pMac->roam.configParam.nActiveMinChnTimeConc;
1841 pParam->nPassiveMaxChnTimeConc = pMac->roam.configParam.nPassiveMaxChnTimeConc;
1842 pParam->nPassiveMinChnTimeConc = pMac->roam.configParam.nPassiveMinChnTimeConc;
1843 pParam->nRestTimeConc = pMac->roam.configParam.nRestTimeConc;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001844 pParam->nNumStaChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc;
1845 pParam->nNumP2PChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001846#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001847 //Change the unit from microsecond to second
1848 pParam->impsSleepTime = pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_SEC_UNIT;
1849 pParam->eBand = pMac->roam.configParam.eBand;
1850 pParam->nScanResultAgeCount = pMac->roam.configParam.agingCount;
1851 pParam->scanAgeTimeNCNPS = pMac->roam.configParam.scanAgeTimeNCNPS;
1852 pParam->scanAgeTimeNCPS = pMac->roam.configParam.scanAgeTimeNCPS;
1853 pParam->scanAgeTimeCNPS = pMac->roam.configParam.scanAgeTimeCNPS;
1854 pParam->scanAgeTimeCPS = pMac->roam.configParam.scanAgeTimeCPS;
1855 pParam->bCatRssiOffset = pMac->roam.configParam.bCatRssiOffset;
1856 pParam->nRoamingTime = pMac->roam.configParam.nRoamingTime;
1857 pParam->fEnforce11dChannels = pMac->roam.configParam.fEnforce11dChannels;
1858 pParam->fSupplicantCountryCodeHasPriority = pMac->roam.configParam.fSupplicantCountryCodeHasPriority;
1859 pParam->fEnforceCountryCodeMatch = pMac->roam.configParam.fEnforceCountryCodeMatch;
1860 pParam->fEnforceDefaultDomain = pMac->roam.configParam.fEnforceDefaultDomain;
1861 pParam->vccRssiThreshold = pMac->roam.configParam.vccRssiThreshold;
1862 pParam->vccUlMacLossThreshold = pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001863 pParam->IsIdleScanEnabled = pMac->roam.configParam.IsIdleScanEnabled;
1864 pParam->nTxPowerCap = pMac->roam.configParam.nTxPowerCap;
1865 pParam->statsReqPeriodicity = pMac->roam.configParam.statsReqPeriodicity;
1866 pParam->statsReqPeriodicityInPS = pMac->roam.configParam.statsReqPeriodicityInPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001867 pParam->addTSWhenACMIsOff = pMac->roam.configParam.addTSWhenACMIsOff;
1868 pParam->fValidateList = pMac->roam.configParam.fValidateList;
1869 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
1870 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
1871 pParam->fScanTwice = pMac->roam.configParam.fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001872 pParam->fFirstScanOnly2GChnl = pMac->scan.fFirstScanOnly2GChnl;
Madan Mohan Koyyalamudied419512012-11-29 15:53:46 -08001873 pParam->fEnableMCCMode = pMac->roam.configParam.fenableMCCMode;
Madan Mohan Koyyalamudi057bd802012-11-29 16:02:39 -08001874 pParam->fAllowMCCGODiffBI = pMac->roam.configParam.fAllowMCCGODiffBI;
Sunil Ravi39b2e532013-01-20 23:45:53 -08001875 pParam->scanCfgAgingTime = pMac->scan.scanResultCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001876
1877#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301878 vos_mem_copy(&pParam->neighborRoamConfig,
1879 &pMac->roam.configParam.neighborRoamConfig,
1880 sizeof(tCsrNeighborRoamConfigParams));
Jeff Johnson295189b2012-06-20 16:38:30 -07001881#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001882#ifdef WLAN_FEATURE_11AC
1883 pParam->nVhtChannelWidth = pMac->roam.configParam.nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001884 pParam->enableTxBF = pMac->roam.configParam.txBFEnable;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001885 pParam->txBFCsnValue = pMac->roam.configParam.txBFCsnValue;
Ravi Joshiacc81822013-10-10 15:30:41 -07001886 pParam->enableVhtFor24GHz = pMac->roam.configParam.enableVhtFor24GHz;
Jeff Johnsone7245742012-09-05 17:12:55 -07001887#endif
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001888#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05301889 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
1890 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001891#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001892#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001893 pParam->isFastTransitionEnabled = pMac->roam.configParam.isFastTransitionEnabled;
1894 pParam->RoamRssiDiff = pMac->roam.configParam.RoamRssiDiff;
1895 pParam->nImmediateRoamRssiDiff = pMac->roam.configParam.nImmediateRoamRssiDiff;
1896 pParam->nRoamPrefer5GHz = pMac->roam.configParam.nRoamPrefer5GHz;
1897 pParam->nRoamIntraBand = pMac->roam.configParam.nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07001898 pParam->isWESModeEnabled = pMac->roam.configParam.isWESModeEnabled;
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -07001899 pParam->nProbes = pMac->roam.configParam.nProbes;
1900 pParam->nRoamScanHomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001901#endif
1902#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1903 pParam->isRoamOffloadScanEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
1904 pParam->bFastRoamInConIniFeatureEnabled = pMac->roam.configParam.bFastRoamInConIniFeatureEnabled;
1905#endif
1906#ifdef FEATURE_WLAN_LFR
1907 pParam->isFastRoamIniFeatureEnabled = pMac->roam.configParam.isFastRoamIniFeatureEnabled;
1908#endif
1909
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001910#ifdef FEATURE_WLAN_ESE
1911 pParam->isEseIniFeatureEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001912#endif
1913#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301914 vos_mem_copy(&pParam->neighborRoamConfig,
1915 &pMac->roam.configParam.neighborRoamConfig,
1916 sizeof(tCsrNeighborRoamConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001917 {
1918 int i;
1919 smsLog( pMac, LOG1, FL("Num of Channels in CFG Channel List: %d"), pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
1920 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1921 {
1922 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1923 }
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001924 }
1925#endif
1926
Venkata Prathyusha Kuntupallif2695c12013-04-17 15:41:23 -07001927 pParam->enableTxLdpc = pMac->roam.configParam.txLdpcEnable;
krunal soni4f087d22013-07-29 16:32:26 -07001928
krunal soni5afa96c2013-09-06 22:19:02 -07001929 pParam->isAmsduSupportInAMPDU = pMac->roam.configParam.isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001930 pParam->nSelect5GHzMargin = pMac->roam.configParam.nSelect5GHzMargin;
krunal soni5afa96c2013-09-06 22:19:02 -07001931
krunal sonie9002db2013-11-25 14:24:17 -08001932 pParam->isCoalesingInIBSSAllowed =
1933 pMac->roam.configParam.isCoalesingInIBSSAllowed;
1934
Jeff Johnson295189b2012-06-20 16:38:30 -07001935 csrSetChannels(pMac, pParam);
1936
1937 status = eHAL_STATUS_SUCCESS;
1938 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001939 return (status);
1940}
1941
Jeff Johnson295189b2012-06-20 16:38:30 -07001942eHalStatus csrSetPhyMode(tHalHandle hHal, tANI_U32 phyMode, eCsrBand eBand, tANI_BOOLEAN *pfRestartNeeded)
1943{
1944 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
1945 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1946 tANI_BOOLEAN fRestartNeeded = eANI_BOOLEAN_FALSE;
1947 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001948 do
1949 {
1950 if(eCSR_BAND_24 == eBand)
1951 {
1952 if(CSR_IS_RADIO_A_ONLY(pMac)) break;
1953 if((eCSR_DOT11_MODE_11a & phyMode) || (eCSR_DOT11_MODE_11a_ONLY & phyMode)) break;
1954 }
1955 if(eCSR_BAND_5G == eBand)
1956 {
1957 if(CSR_IS_RADIO_BG_ONLY(pMac)) break;
1958 if((eCSR_DOT11_MODE_11b & phyMode) || (eCSR_DOT11_MODE_11b_ONLY & phyMode) ||
1959 (eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11g_ONLY & phyMode)
1960 )
1961 {
1962 break;
1963 }
1964 }
1965 if((0 == phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
1966 {
1967 newPhyMode = eCSR_DOT11_MODE_TAURUS;
1968 }
1969 else if(eCSR_DOT11_MODE_AUTO & phyMode)
1970 {
1971 newPhyMode = eCSR_DOT11_MODE_AUTO;
1972 }
1973 else
1974 {
1975 //Check for dual band and higher capability first
1976 if(eCSR_DOT11_MODE_11n_ONLY & phyMode)
1977 {
1978 if(eCSR_DOT11_MODE_11n_ONLY != phyMode) break;
1979 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
1980 }
1981 else if(eCSR_DOT11_MODE_11a_ONLY & phyMode)
1982 {
1983 if(eCSR_DOT11_MODE_11a_ONLY != phyMode) break;
1984 if(eCSR_BAND_24 == eBand) break;
1985 newPhyMode = eCSR_DOT11_MODE_11a_ONLY;
1986 eBand = eCSR_BAND_5G;
1987 }
1988 else if(eCSR_DOT11_MODE_11g_ONLY & phyMode)
1989 {
1990 if(eCSR_DOT11_MODE_11g_ONLY != phyMode) break;
1991 if(eCSR_BAND_5G == eBand) break;
1992 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
1993 eBand = eCSR_BAND_24;
1994 }
1995 else if(eCSR_DOT11_MODE_11b_ONLY & phyMode)
1996 {
1997 if(eCSR_DOT11_MODE_11b_ONLY != phyMode) break;
1998 if(eCSR_BAND_5G == eBand) break;
1999 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
2000 eBand = eCSR_BAND_24;
2001 }
2002 else if(eCSR_DOT11_MODE_11n & phyMode)
2003 {
2004 newPhyMode = eCSR_DOT11_MODE_11n;
2005 }
2006 else if(eCSR_DOT11_MODE_abg & phyMode)
2007 {
2008 newPhyMode = eCSR_DOT11_MODE_abg;
2009 }
2010 else if(eCSR_DOT11_MODE_11a & phyMode)
2011 {
2012 if((eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11b & phyMode))
2013 {
2014 if(eCSR_BAND_ALL == eBand)
2015 {
2016 newPhyMode = eCSR_DOT11_MODE_abg;
2017 }
2018 else
2019 {
2020 //bad setting
2021 break;
2022 }
2023 }
2024 else
2025 {
2026 newPhyMode = eCSR_DOT11_MODE_11a;
2027 eBand = eCSR_BAND_5G;
2028 }
2029 }
2030 else if(eCSR_DOT11_MODE_11g & phyMode)
2031 {
2032 newPhyMode = eCSR_DOT11_MODE_11g;
2033 eBand = eCSR_BAND_24;
2034 }
2035 else if(eCSR_DOT11_MODE_11b & phyMode)
2036 {
2037 newPhyMode = eCSR_DOT11_MODE_11b;
2038 eBand = eCSR_BAND_24;
2039 }
2040 else
2041 {
2042 //We will never be here
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002043 smsLog( pMac, LOGE, FL(" cannot recognize the phy mode 0x%08X"), phyMode );
Jeff Johnson295189b2012-06-20 16:38:30 -07002044 newPhyMode = eCSR_DOT11_MODE_AUTO;
2045 }
2046 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002047 //Done validating
2048 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002049 //Now we need to check whether a restart is needed.
2050 if(eBand != pMac->roam.configParam.eBand)
2051 {
2052 fRestartNeeded = eANI_BOOLEAN_TRUE;
2053 break;
2054 }
2055 if(newPhyMode != pMac->roam.configParam.phyMode)
2056 {
2057 fRestartNeeded = eANI_BOOLEAN_TRUE;
2058 break;
2059 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002060 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002061 if(HAL_STATUS_SUCCESS(status))
2062 {
2063 pMac->roam.configParam.eBand = eBand;
2064 pMac->roam.configParam.phyMode = newPhyMode;
2065 if(pfRestartNeeded)
2066 {
2067 *pfRestartNeeded = fRestartNeeded;
2068 }
2069 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002070 return (status);
2071}
2072
Jeff Johnson295189b2012-06-20 16:38:30 -07002073void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList )
2074{
2075 tANI_U8 Index;
2076 tANI_U8 cChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07002077 // for dual band NICs, don't need to trim the channel list....
2078 if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) )
2079 {
2080 // 2.4 GHz band operation requires the channel list to be trimmed to
2081 // the 2.4 GHz channels only...
2082 if ( CSR_IS_24_BAND_ONLY( pMac ) )
2083 {
2084 for( Index = 0, cChannels = 0; Index < pChannelList->numChannels;
2085 Index++ )
2086 {
2087 if ( CSR_IS_CHANNEL_24GHZ(pChannelList->channelList[ Index ]) )
2088 {
2089 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2090 cChannels++;
2091 }
2092 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002093 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2094 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2095 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2096 // only if we need to.
2097 //
2098 // The amount of memory to clear is the number of channesl that we trimmed
2099 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2100
2101 if ( pChannelList->numChannels > cChannels )
2102 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302103 vos_mem_set(&pChannelList->channelList[ cChannels ],
2104 sizeof( pChannelList->channelList[ 0 ] ) *
2105 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002106 }
2107
2108 pChannelList->numChannels = cChannels;
2109 }
2110 else if ( CSR_IS_5G_BAND_ONLY( pMac ) )
2111 {
2112 for ( Index = 0, cChannels = 0; Index < pChannelList->numChannels; Index++ )
2113 {
2114 if ( CSR_IS_CHANNEL_5GHZ(pChannelList->channelList[ Index ]) )
2115 {
2116 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2117 cChannels++;
2118 }
2119 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002120 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2121 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2122 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2123 // only if we need to.
2124 //
2125 // The amount of memory to clear is the number of channesl that we trimmed
2126 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2127 if ( pChannelList->numChannels > cChannels )
2128 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302129 vos_mem_set(&pChannelList->channelList[ cChannels ],
2130 sizeof( pChannelList->channelList[ 0 ] ) *
2131 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002132 }
2133
2134 pChannelList->numChannels = cChannels;
2135 }
2136 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002137}
Jeff Johnson295189b2012-06-20 16:38:30 -07002138#define INFRA_AP_DEFAULT_CHANNEL 6
2139eHalStatus csrIsValidChannel(tpAniSirGlobal pMac, tANI_U8 chnNum)
2140{
2141 tANI_U8 index= 0;
2142 eHalStatus status = eHAL_STATUS_FAILURE;
2143 for (index=0; index < pMac->scan.base20MHzChannels.numChannels ;index++)
2144 {
2145 if(pMac->scan.base20MHzChannels.channelList[ index ] == chnNum){
2146 status = eHAL_STATUS_SUCCESS;
2147 break;
2148 }
2149 }
2150 return status;
2151}
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002152
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002153
Jeff Johnson295189b2012-06-20 16:38:30 -07002154eHalStatus csrInitGetChannels(tpAniSirGlobal pMac)
2155{
2156 eHalStatus status = eHAL_STATUS_SUCCESS;
2157 tANI_U8 num20MHzChannelsFound = 0;
2158 VOS_STATUS vosStatus;
2159 tANI_U8 Index = 0;
2160 tANI_U8 num40MHzChannelsFound = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002161
Jeff Johnson295189b2012-06-20 16:38:30 -07002162
2163 //TODO: this interface changed to include the 40MHz channel list
2164 // this needs to be tied into the adapter structure somehow and referenced appropriately for CB operation
2165 // Read the scan channel list (including the power limit) from EEPROM
2166 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
2167 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
2168 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
2169 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002170 smsLog( pMac, LOGE, FL("failed to get channels "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002171 status = eHAL_STATUS_FAILURE;
2172 }
2173 else
2174 {
2175 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
2176 {
2177 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2178 }
2179 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
2180 // Move the channel list to the global data
2181 // structure -- this will be used as the scan list
2182 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
2183 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002184 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[ Index ].chanId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002185 }
2186 pMac->scan.base20MHzChannels.numChannels = num20MHzChannelsFound;
2187 if(num40MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN)
2188 {
2189 num40MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2190 }
2191 for ( Index = 0; Index < num40MHzChannelsFound; Index++)
2192 {
2193 pMac->scan.base40MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable40MHz[ Index ].chanId;
2194 }
2195 pMac->scan.base40MHzChannels.numChannels = num40MHzChannelsFound;
2196 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002197 return (status);
2198}
2199
Jeff Johnson295189b2012-06-20 16:38:30 -07002200eHalStatus csrInitChannelList( tHalHandle hHal )
2201{
2202 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2203 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002204 csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels);
2205 csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels);
Kiran4a17ebe2013-01-31 10:43:43 -08002206 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE);
2207 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002208 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002209 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnson295189b2012-06-20 16:38:30 -07002210
2211 return (status);
2212}
Jeff Johnson295189b2012-06-20 16:38:30 -07002213eHalStatus csrChangeConfigParams(tpAniSirGlobal pMac,
2214 tCsrUpdateConfigParam *pUpdateConfigParam)
2215{
2216 eHalStatus status = eHAL_STATUS_FAILURE;
2217 tCsr11dinfo *ps11dinfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002218 ps11dinfo = &pUpdateConfigParam->Csr11dinfo;
2219 status = CsrInit11dInfo(pMac, ps11dinfo);
2220 return status;
2221}
2222
Jeff Johnson295189b2012-06-20 16:38:30 -07002223static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2224{
2225 eHalStatus status = eHAL_STATUS_FAILURE;
2226 tANI_U8 index;
2227 tANI_U32 count=0;
2228 tSirMacChanInfo *pChanInfo;
2229 tSirMacChanInfo *pChanInfoStart;
2230 tANI_BOOLEAN applyConfig = TRUE;
2231
Mihir Shetebc866f62014-02-13 16:08:53 +05302232 pMac->scan.currentCountryRSSI = -128;
2233
Jeff Johnson295189b2012-06-20 16:38:30 -07002234 if(!ps11dinfo)
2235 {
2236 return (status);
2237 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002238 if ( ps11dinfo->Channels.numChannels && ( WNI_CFG_VALID_CHANNEL_LIST_LEN >= ps11dinfo->Channels.numChannels ) )
2239 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302240 pMac->scan.base20MHzChannels.numChannels = ps11dinfo->Channels.numChannels;
2241 vos_mem_copy(pMac->scan.base20MHzChannels.channelList,
2242 ps11dinfo->Channels.channelList,
2243 ps11dinfo->Channels.numChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07002244 }
2245 else
2246 {
2247 //No change
2248 return (eHAL_STATUS_SUCCESS);
2249 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002250 //legacy maintenance
Kiet Lam64c1b492013-07-12 13:56:44 +05302251
2252 vos_mem_copy(pMac->scan.countryCodeDefault, ps11dinfo->countryCode,
2253 WNI_CFG_COUNTRY_CODE_LEN);
2254
2255
Jeff Johnson295189b2012-06-20 16:38:30 -07002256 //Tush: at csropen get this initialized with default, during csr reset if this
2257 // already set with some value no need initilaize with default again
2258 if(0 == pMac->scan.countryCodeCurrent[0])
2259 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302260 vos_mem_copy(pMac->scan.countryCodeCurrent, ps11dinfo->countryCode,
2261 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002262 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002263 // need to add the max power channel list
Kiet Lam64c1b492013-07-12 13:56:44 +05302264 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2265 if (pChanInfo != NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002266 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302267 vos_mem_set(pChanInfo,
2268 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN ,
2269 0);
2270
Jeff Johnson295189b2012-06-20 16:38:30 -07002271 pChanInfoStart = pChanInfo;
Jeff Johnsone7245742012-09-05 17:12:55 -07002272 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2273 {
2274 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2275 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2276 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2277 pChanInfo++;
2278 count++;
2279 }
2280 if(count)
2281 {
2282 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2283 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302284 vos_mem_free(pChanInfoStart);
Jeff Johnsone7245742012-09-05 17:12:55 -07002285 }
2286 //Only apply them to CFG when not in STOP state. Otherwise they will be applied later
2287 if( HAL_STATUS_SUCCESS(status) )
2288 {
2289 for( index = 0; index < CSR_ROAM_SESSION_MAX; index++ )
2290 {
2291 if((CSR_IS_SESSION_VALID(pMac, index)) && CSR_IS_ROAM_STOP(pMac, index))
2292 {
2293 applyConfig = FALSE;
2294 }
2295 }
2296
2297 if(TRUE == applyConfig)
2298 {
2299 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002300 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnsone7245742012-09-05 17:12:55 -07002301 }
2302
2303 }
2304 return (status);
2305}
2306/* Initialize the Channel + Power List in the local cache and in the CFG */
2307eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2308{
2309 tANI_U8 index;
2310 tANI_U32 count=0;
2311 tSirMacChanInfo *pChanInfo;
2312 tSirMacChanInfo *pChanInfoStart;
2313
2314 if(!ps11dinfo || !pMac)
2315 {
2316 return eHAL_STATUS_FAILURE;
2317 }
2318
Kiet Lam64c1b492013-07-12 13:56:44 +05302319 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2320 if (pChanInfo != NULL)
Jeff Johnsone7245742012-09-05 17:12:55 -07002321 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302322 vos_mem_set(pChanInfo,
2323 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN,
2324 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07002325 pChanInfoStart = pChanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002326
2327 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2328 {
2329 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2330 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2331 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2332 pChanInfo++;
2333 count++;
2334 }
2335 if(count)
2336 {
2337 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2338 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302339 vos_mem_free(pChanInfoStart);
Jeff Johnson295189b2012-06-20 16:38:30 -07002340 }
2341
Jeff Johnsone7245742012-09-05 17:12:55 -07002342 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002343}
2344
2345//pCommand may be NULL
2346//Pass in sessionId in case pCommand is NULL. sessionId is not used in case pCommand is not NULL.
2347void csrRoamRemoveDuplicateCommand(tpAniSirGlobal pMac, tANI_U32 sessionId, tSmeCmd *pCommand, eCsrRoamReason eRoamReason)
2348{
2349 tListElem *pEntry, *pNextEntry;
2350 tSmeCmd *pDupCommand;
2351 tDblLinkList localList;
2352
2353 vos_mem_zero(&localList, sizeof(tDblLinkList));
2354 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
2355 {
2356 smsLog(pMac, LOGE, FL(" failed to open list"));
2357 return;
2358 }
2359 csrLLLock( &pMac->sme.smeCmdPendingList );
2360 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK );
2361 while( pEntry )
2362 {
2363 pNextEntry = csrLLNext( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
2364 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07002365 // Remove the previous command if..
2366 // - the new roam command is for the same RoamReason...
2367 // - the new roam command is a NewProfileList.
2368 // - the new roam command is a Forced Dissoc
2369 // - the new roam command is from an 802.11 OID (OID_SSID or OID_BSSID).
2370 if (
2371 (pCommand && ( pCommand->sessionId == pDupCommand->sessionId ) &&
2372 ((pCommand->command == pDupCommand->command) &&
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08002373 /* This peermac check is requried for Softap/GO scenarios
2374 * For STA scenario below OR check will suffice as pCommand will
2375 * always be NULL for STA scenarios
2376 */
2377 (vos_mem_compare(pDupCommand->u.roamCmd.peerMac, pCommand->u.roamCmd.peerMac, sizeof(v_MACADDR_t))) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002378 (pCommand->u.roamCmd.roamReason == pDupCommand->u.roamCmd.roamReason ||
2379 eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason ||
2380 eCsrHddIssued == pCommand->u.roamCmd.roamReason)))
2381 ||
2382 //below the pCommand is NULL
Jeff Johnson43971f52012-07-17 12:26:56 -07002383 ( (sessionId == pDupCommand->sessionId) &&
2384 (eSmeCommandRoam == pDupCommand->command) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002385 ((eCsrForcedDisassoc == eRoamReason) ||
2386 (eCsrHddIssued == eRoamReason))
2387 )
2388 )
2389 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002390 smsLog(pMac, LOGW, FL(" roamReason = %d"), pDupCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07002391 // Remove the 'stale' roam command from the pending list...
2392 if(csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK ))
2393 {
2394 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
2395 }
2396 }
2397 pEntry = pNextEntry;
2398 }
2399 csrLLUnlock( &pMac->sme.smeCmdPendingList );
2400
2401 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
2402 {
2403 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
2404 //Tell caller that the command is cancelled
2405 csrRoamCallCallback(pMac, pDupCommand->sessionId, NULL, pDupCommand->u.roamCmd.roamId,
2406 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
2407 csrReleaseCommandRoam(pMac, pDupCommand);
2408 }
2409 csrLLClose(&localList);
2410}
Jeff Johnson295189b2012-06-20 16:38:30 -07002411eHalStatus csrRoamCallCallback(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo,
2412 tANI_U32 roamId, eRoamCmdStatus u1, eCsrRoamResult u2)
2413{
2414 eHalStatus status = eHAL_STATUS_SUCCESS;
2415#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2416 WLAN_VOS_DIAG_EVENT_DEF(connectionStatus, vos_event_wlan_status_payload_type);
2417#endif
2418 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07002419 if( CSR_IS_SESSION_VALID( pMac, sessionId) )
2420 {
2421 pSession = CSR_GET_SESSION( pMac, sessionId );
2422 }
2423 else
2424 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002425 smsLog(pMac, LOGE, "Session ID:%d is not valid", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002426 VOS_ASSERT(0);
2427 return eHAL_STATUS_FAILURE;
2428 }
krunal soni587bf012014-02-04 12:35:11 -08002429
2430 if (eANI_BOOLEAN_FALSE == pSession->sessionActive)
2431 {
2432 smsLog(pMac, LOG1, "%s Session is not Active", __func__);
2433 return eHAL_STATUS_FAILURE;
2434 }
krunal soni7f7d2c92014-02-06 15:08:43 -08002435
krunal soni587bf012014-02-04 12:35:11 -08002436 smsLog(pMac, LOG4, "Recieved RoamCmdStatus %d with Roam Result %d", u1, u2);
2437
krunal soni7f7d2c92014-02-06 15:08:43 -08002438 if(eCSR_ROAM_ASSOCIATION_COMPLETION == u1 && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002439 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002440 smsLog(pMac, LOGW, " Assoc complete result = %d statusCode = %d reasonCode = %d", u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002441 }
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07002442 if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED) && (pSession->bRefAssocStartCnt)) {
2443 /*
2444 * Decrement bRefAssocStartCnt for FT reassoc failure.
2445 * Reason: For FT reassoc failures, we first call
2446 * csrRoamCallCallback before notifying a failed roam
2447 * completion through csrRoamComplete. The latter in
2448 * turn calls csrRoamProcessResults which tries to
2449 * once again call csrRoamCallCallback if bRefAssocStartCnt
2450 * is non-zero. Since this is redundant for FT reassoc
2451 * failure, decrement bRefAssocStartCnt.
2452 */
2453 pSession->bRefAssocStartCnt--;
2454 }
2455
Jeff Johnson295189b2012-06-20 16:38:30 -07002456 if(NULL != pSession->callback)
2457 {
2458 if( pRoamInfo )
2459 {
2460 pRoamInfo->sessionId = (tANI_U8)sessionId;
2461 }
2462
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302463 /* avoid holding the global lock when making the roaming callback, original change came
2464 from a raised CR (CR304874). Since this callback is in HDD a potential deadlock
2465 is possible on other OS ports where the callback may need to take locks to protect
2466 HDD state
Jeff Johnson295189b2012-06-20 16:38:30 -07002467 UPDATE : revert this change but keep the comments here. Need to revisit as there are callbacks
2468 that may actually depend on the lock being held */
2469 // TODO: revisit: sme_ReleaseGlobalLock( &pMac->sme );
2470 status = pSession->callback(pSession->pContext, pRoamInfo, roamId, u1, u2);
2471 // TODO: revisit: sme_AcquireGlobalLock( &pMac->sme );
2472 }
2473 //EVENT_WLAN_STATUS: eCSR_ROAM_ASSOCIATION_COMPLETION,
2474 // eCSR_ROAM_LOSTLINK, eCSR_ROAM_DISASSOCIATED,
2475#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiet Lam64c1b492013-07-12 13:56:44 +05302476 vos_mem_set(&connectionStatus,
2477 sizeof(vos_event_wlan_status_payload_type), 0);
2478
krunal soni7f7d2c92014-02-06 15:08:43 -08002479 if((eCSR_ROAM_ASSOCIATION_COMPLETION == u1) && (eCSR_ROAM_RESULT_ASSOCIATED == u2) && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002480 {
2481 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
2482 connectionStatus.bssType = pRoamInfo->u.pConnectedProfile->BSSType;
2483 if(NULL != pRoamInfo->pBssDesc)
2484 {
2485 connectionStatus.rssi = pRoamInfo->pBssDesc->rssi * (-1);
2486 connectionStatus.channel = pRoamInfo->pBssDesc->channelId;
2487 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002488 connectionStatus.qosCapability = pRoamInfo->u.pConnectedProfile->qosConnection;
2489 connectionStatus.authType = (v_U8_t)diagAuthTypeFromCSRType(pRoamInfo->u.pConnectedProfile->AuthType);
2490 connectionStatus.encryptionType = (v_U8_t)diagEncTypeFromCSRType(pRoamInfo->u.pConnectedProfile->EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05302491 vos_mem_copy(connectionStatus.ssid,
2492 pRoamInfo->u.pConnectedProfile->SSID.ssId, 6);
2493
Jeff Johnson295189b2012-06-20 16:38:30 -07002494 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
2495 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2496 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002497 if((eCSR_ROAM_MIC_ERROR_IND == u1) || (eCSR_ROAM_RESULT_MIC_FAILURE == u2))
2498 {
2499 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2500 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
2501 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2502 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002503 if(eCSR_ROAM_RESULT_FORCED == u2)
2504 {
2505 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2506 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
2507 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2508 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002509 if(eCSR_ROAM_RESULT_DISASSOC_IND == u2)
2510 {
2511 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2512 connectionStatus.reason = eCSR_REASON_DISASSOC;
2513 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2514 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002515 if(eCSR_ROAM_RESULT_DEAUTH_IND == u2)
2516 {
2517 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2518 connectionStatus.reason = eCSR_REASON_DEAUTH;
2519 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2520 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002521#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
2522
2523 return (status);
2524}
Jeff Johnson295189b2012-06-20 16:38:30 -07002525// Returns whether handoff is currently in progress or not
2526tANI_BOOLEAN csrRoamIsHandoffInProgress(tpAniSirGlobal pMac)
2527{
2528#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2529 return csrNeighborRoamIsHandoffInProgress(pMac);
2530#else
2531 return eANI_BOOLEAN_FALSE;
2532#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002533}
Jeff Johnson295189b2012-06-20 16:38:30 -07002534eHalStatus csrRoamIssueDisassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
2535 eCsrRoamSubState NewSubstate, tANI_BOOLEAN fMICFailure )
2536{
2537 eHalStatus status = eHAL_STATUS_SUCCESS;
2538 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2539 tANI_U16 reasonCode;
2540 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002541
2542 if(!pSession)
2543 {
2544 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2545 return eHAL_STATUS_FAILURE;
2546 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002547
2548 //Restore AC weight in case we change it
2549 if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
2550 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07002551 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 -07002552 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
2553 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
2554 }
2555
2556 if ( fMICFailure )
2557 {
2558 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
2559 }
2560 else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)
2561 {
2562 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002563 }
2564 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002565 {
2566 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
2567 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002568#ifdef WLAN_FEATURE_VOWIFI_11R
2569 if ( (csrRoamIsHandoffInProgress(pMac)) &&
2570 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF))
2571 {
2572 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05302573 vos_mem_copy(&bssId,
2574 pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid,
2575 sizeof(tSirMacAddr));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002576 }
2577 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002578#endif
2579 if(pSession->pConnectBssDesc)
2580 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302581 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002582 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002583
Jeff Johnson295189b2012-06-20 16:38:30 -07002584
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05302585 smsLog(pMac, LOG2, FL("CSR Attempting to Disassociate Bssid="MAC_ADDRESS_STR
2586 " subState = %s reason=%d"),
2587 MAC_ADDR_ARRAY(bssId), macTraceGetcsrRoamSubState(NewSubstate),
2588 reasonCode);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08002589
Jeff Johnson295189b2012-06-20 16:38:30 -07002590 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2591
2592 status = csrSendMBDisassocReqMsg( pMac, sessionId, bssId, reasonCode );
2593
2594 if(HAL_STATUS_SUCCESS(status))
2595 {
2596 csrRoamLinkDown(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002597#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2598 //no need to tell QoS that we are disassociating, it will be taken care off in assoc req for HO
2599 if(eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate)
2600 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002601 //notify QoS module that disassoc happening
Jeff Johnson295189b2012-06-20 16:38:30 -07002602 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
2603 }
2604#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002605 }
2606 else
2607 {
2608 smsLog(pMac, LOGW, FL("csrSendMBDisassocReqMsg failed with status %d"), status);
2609 }
2610
Jeff Johnson295189b2012-06-20 16:38:30 -07002611 return (status);
2612}
Jeff Johnson295189b2012-06-20 16:38:30 -07002613
Jeff Johnson295189b2012-06-20 16:38:30 -07002614/* ---------------------------------------------------------------------------
2615 \fn csrRoamIssueDisassociateStaCmd
2616 \brief csr function that HDD calls to disassociate a associated station
2617 \param sessionId - session Id for Soft AP
2618 \param pPeerMacAddr - MAC of associated station to delete
2619 \param reason - reason code, be one of the tSirMacReasonCodes
2620 \return eHalStatus
2621 ---------------------------------------------------------------------------*/
2622eHalStatus csrRoamIssueDisassociateStaCmd( tpAniSirGlobal pMac,
2623 tANI_U32 sessionId,
2624 tANI_U8 *pPeerMacAddr,
2625 tANI_U32 reason)
2626{
2627 eHalStatus status = eHAL_STATUS_SUCCESS;
2628 tSmeCmd *pCommand;
2629
2630 do
2631 {
2632 pCommand = csrGetCommandBuffer( pMac );
2633 if ( !pCommand )
2634 {
2635 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2636 status = eHAL_STATUS_RESOURCES;
2637 break;
2638 }
2639 pCommand->command = eSmeCommandRoam;
2640 pCommand->sessionId = (tANI_U8)sessionId;
2641 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
2642 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2643 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2644 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2645 if( !HAL_STATUS_SUCCESS( status ) )
2646 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002647 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002648 csrReleaseCommandRoam( pMac, pCommand );
2649 }
2650 }while(0);
2651
2652 return status;
2653}
2654
2655
Jeff Johnson295189b2012-06-20 16:38:30 -07002656/* ---------------------------------------------------------------------------
2657 \fn csrRoamIssueDeauthSta
2658 \brief csr function that HDD calls to delete a associated station
2659 \param sessionId - session Id for Soft AP
2660 \param pPeerMacAddr - MAC of associated station to delete
2661 \param reason - reason code, be one of the tSirMacReasonCodes
2662 \return eHalStatus
2663 ---------------------------------------------------------------------------*/
2664eHalStatus csrRoamIssueDeauthStaCmd( tpAniSirGlobal pMac,
2665 tANI_U32 sessionId,
2666 tANI_U8 *pPeerMacAddr,
2667 tANI_U32 reason)
2668{
2669 eHalStatus status = eHAL_STATUS_SUCCESS;
2670 tSmeCmd *pCommand;
2671
2672 do
2673 {
2674 pCommand = csrGetCommandBuffer( pMac );
2675 if ( !pCommand )
2676 {
2677 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2678 status = eHAL_STATUS_RESOURCES;
2679 break;
2680 }
2681 pCommand->command = eSmeCommandRoam;
2682 pCommand->sessionId = (tANI_U8)sessionId;
2683 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
2684 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2685 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2686 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2687 if( !HAL_STATUS_SUCCESS( status ) )
2688 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002689 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002690 csrReleaseCommandRoam( pMac, pCommand );
2691 }
2692 }while(0);
2693
2694 return status;
2695}
Jeff Johnson295189b2012-06-20 16:38:30 -07002696eHalStatus
2697csrRoamIssueTkipCounterMeasures( tpAniSirGlobal pMac, tANI_U32 sessionId,
2698 tANI_BOOLEAN bEnable )
2699{
2700 eHalStatus status = eHAL_STATUS_FAILURE;
2701 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2702 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002703 if (!pSession)
2704 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002705 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002706 return (status);
2707 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002708 if (pSession->pConnectBssDesc)
2709 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302710 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002711 }
2712 else
2713 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002714 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002715 return (status);
2716 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002717 smsLog( pMac, LOG2, "CSR issuing tkip counter measures for Bssid = "MAC_ADDRESS_STR", Enable = %d",
2718 MAC_ADDR_ARRAY(bssId), bEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002719 status = csrSendMBTkipCounterMeasuresReqMsg( pMac, sessionId, bEnable, bssId );
2720 return (status);
2721}
Jeff Johnson295189b2012-06-20 16:38:30 -07002722eHalStatus
2723csrRoamGetAssociatedStas( tpAniSirGlobal pMac, tANI_U32 sessionId,
2724 VOS_MODULE_ID modId, void *pUsrContext,
2725 void *pfnSapEventCallback, v_U8_t *pAssocStasBuf )
2726{
2727 eHalStatus status = eHAL_STATUS_SUCCESS;
2728 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2729 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002730 if (!pSession)
2731 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002732 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002733 return (status);
2734 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002735 if(pSession->pConnectBssDesc)
2736 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302737 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002738 }
2739 else
2740 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002741 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002742 return (status);
2743 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002744 smsLog( pMac, LOG2, "CSR getting associated stations for Bssid = "MAC_ADDRESS_STR,
2745 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002746 status = csrSendMBGetAssociatedStasReqMsg( pMac, sessionId, modId, bssId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
2747 return (status);
2748}
Jeff Johnson295189b2012-06-20 16:38:30 -07002749eHalStatus
2750csrRoamGetWpsSessionOverlap( tpAniSirGlobal pMac, tANI_U32 sessionId,
2751 void *pUsrContext, void *pfnSapEventCallback, v_MACADDR_t pRemoveMac )
2752{
2753 eHalStatus status = eHAL_STATUS_SUCCESS;
2754 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2755 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2756
2757 if (!pSession)
2758 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002759 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002760 return (status);
2761 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002762 if(pSession->pConnectBssDesc)
2763 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302764 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002765 }
2766 else
2767 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002768 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002769 return (status);
2770 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002771 smsLog( pMac, LOG2, "CSR getting WPS Session Overlap for Bssid = "MAC_ADDRESS_STR,
2772 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002773
2774 status = csrSendMBGetWPSPBCSessions( pMac, sessionId, bssId, pUsrContext, pfnSapEventCallback, pRemoveMac);
2775
2776 return (status);
2777}
Jeff Johnson295189b2012-06-20 16:38:30 -07002778eHalStatus csrRoamIssueDeauth( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
2779{
2780 eHalStatus status = eHAL_STATUS_SUCCESS;
2781 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2782 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002783
2784 if (!pSession)
2785 {
2786 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2787 return eHAL_STATUS_FAILURE;
2788 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002789
2790 if(pSession->pConnectBssDesc)
2791 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302792 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002793 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002794 smsLog( pMac, LOG2, "CSR Attempting to Deauth Bssid= "MAC_ADDRESS_STR,
2795 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002796 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2797
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05302798 status = csrSendMBDeauthReqMsg( pMac, sessionId, bssId, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002799 if(!HAL_STATUS_SUCCESS(status))
2800 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05302801 smsLog(pMac, LOGE, FL("csrSendMBDeauthReqMsg failed with status %d Session ID: %d"
2802 MAC_ADDRESS_STR ), status, sessionId, MAC_ADDR_ARRAY(bssId));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002803 }
2804
Jeff Johnson295189b2012-06-20 16:38:30 -07002805 return (status);
2806}
2807
Jeff Johnson295189b2012-06-20 16:38:30 -07002808eHalStatus csrRoamSaveConnectedBssDesc( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDesc )
2809{
2810 eHalStatus status = eHAL_STATUS_SUCCESS;
2811 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2812 tANI_U32 size;
Jeff Johnson32d95a32012-09-10 13:15:23 -07002813
2814 if(!pSession)
2815 {
2816 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2817 return eHAL_STATUS_FAILURE;
2818 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002819
2820 // If no BSS description was found in this connection (happens with start IBSS), then
2821 // nix the BSS description that we keep around for the connected BSS) and get out...
2822 if(NULL == pBssDesc)
2823 {
2824 csrFreeConnectBssDesc(pMac, sessionId);
2825 }
2826 else
2827 {
2828 size = pBssDesc->length + sizeof( pBssDesc->length );
2829 if(NULL != pSession->pConnectBssDesc)
2830 {
2831 if(((pSession->pConnectBssDesc->length) + sizeof(pSession->pConnectBssDesc->length)) < size)
2832 {
2833 //not enough room for the new BSS, pMac->roam.pConnectBssDesc is freed inside
2834 csrFreeConnectBssDesc(pMac, sessionId);
2835 }
2836 }
2837 if(NULL == pSession->pConnectBssDesc)
2838 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302839 pSession->pConnectBssDesc = vos_mem_malloc(size);
Jeff Johnson295189b2012-06-20 16:38:30 -07002840 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302841 if (NULL == pSession->pConnectBssDesc)
2842 status = eHAL_STATUS_FAILURE;
2843 else
2844 vos_mem_copy(pSession->pConnectBssDesc, pBssDesc, size);
2845 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002846 return (status);
2847}
2848
Jeff Johnson295189b2012-06-20 16:38:30 -07002849eHalStatus csrRoamPrepareBssConfig(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2850 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
2851 tDot11fBeaconIEs *pIes)
2852{
2853 eHalStatus status = eHAL_STATUS_SUCCESS;
2854 eCsrCfgDot11Mode cfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002855 VOS_ASSERT( pIes != NULL );
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +05302856 if (pIes == NULL)
2857 return eHAL_STATUS_FAILURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002858
Jeff Johnson295189b2012-06-20 16:38:30 -07002859 do
2860 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302861 vos_mem_copy(&pBssConfig->BssCap, &pBssDesc->capabilityInfo,
2862 sizeof(tSirMacCapabilityInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07002863 //get qos
2864 pBssConfig->qosType = csrGetQoSFromBssDesc(pMac, pBssDesc, pIes);
2865 //get SSID
2866 if(pIes->SSID.present)
2867 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302868 vos_mem_copy(&pBssConfig->SSID.ssId, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07002869 pBssConfig->SSID.length = pIes->SSID.num_ssid;
2870 }
2871 else
2872 pBssConfig->SSID.length = 0;
2873 if(csrIsNULLSSID(pBssConfig->SSID.ssId, pBssConfig->SSID.length))
2874 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002875 smsLog(pMac, LOGW, " BSS desc SSID is a wildcard");
Jeff Johnson295189b2012-06-20 16:38:30 -07002876 //Return failed if profile doesn't have an SSID either.
2877 if(pProfile->SSIDs.numOfSSIDs == 0)
2878 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002879 smsLog(pMac, LOGW, " Both BSS desc and profile doesn't have SSID");
Jeff Johnson295189b2012-06-20 16:38:30 -07002880 status = eHAL_STATUS_FAILURE;
2881 break;
2882 }
2883 }
2884 if(CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
2885 {
2886 pBssConfig->eBand = eCSR_BAND_5G;
2887 }
2888 else
2889 {
2890 pBssConfig->eBand = eCSR_BAND_24;
2891 }
2892 //phymode
2893 if(csrIsPhyModeMatch( pMac, pProfile->phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes ))
2894 {
2895 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
2896 }
2897 else
2898 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002899 smsLog(pMac, LOGW, " Can not find match phy mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07002900 //force it
2901 if(eCSR_BAND_24 == pBssConfig->eBand)
2902 {
2903 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2904 }
2905 else
2906 {
2907 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2908 }
2909 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002910 //Qos
2911 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
2912 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos))
2913 {
2914 //Joining BSS is not 11n capable and WMM is disabled on client.
2915 //Disable QoS and WMM
2916 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2917 }
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302918
2919 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
Pratik Bhalgat8d461642012-11-22 16:55:42 +05302920 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC)) &&
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302921 ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP) ||
2922 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF) ||
2923 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF) ))
2924 {
2925 //Joining BSS is 11n capable and WMM is disabled on AP.
2926 //Assume all HT AP's are QOS AP's and enable WMM
2927 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2928 }
2929
Jeff Johnson295189b2012-06-20 16:38:30 -07002930 //auth type
2931 switch( pProfile->negotiatedAuthType )
2932 {
2933 default:
2934 case eCSR_AUTH_TYPE_WPA:
2935 case eCSR_AUTH_TYPE_WPA_PSK:
2936 case eCSR_AUTH_TYPE_WPA_NONE:
2937 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2938 pBssConfig->authType = eSIR_OPEN_SYSTEM;
2939 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002940 case eCSR_AUTH_TYPE_SHARED_KEY:
2941 pBssConfig->authType = eSIR_SHARED_KEY;
2942 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002943 case eCSR_AUTH_TYPE_AUTOSWITCH:
2944 pBssConfig->authType = eSIR_AUTO_SWITCH;
2945 break;
2946 }
2947 //short slot time
2948 if( eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode )
2949 {
2950 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
2951 }
2952 else
2953 {
2954 pBssConfig->uShortSlotTime = 0;
2955 }
2956 if(pBssConfig->BssCap.ibss)
2957 {
2958 //We don't support 11h on IBSS
2959 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
2960 }
2961 else
2962 {
2963 pBssConfig->f11hSupport = pMac->roam.configParam.Is11hSupportEnabled;
2964 }
2965 //power constraint
2966 pBssConfig->uPowerLimit = csrGet11hPowerConstraint(pMac, &pIes->PowerConstraints);
2967 //heartbeat
2968 if ( CSR_IS_11A_BSS( pBssDesc ) )
2969 {
2970 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
2971 }
2972 else
2973 {
2974 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
2975 }
2976 //Join timeout
2977 // if we find a BeaconInterval in the BssDescription, then set the Join Timeout to
Jeff Johnsone7245742012-09-05 17:12:55 -07002978 // be 10 x the BeaconInterval.
Jeff Johnson295189b2012-06-20 16:38:30 -07002979 if ( pBssDesc->beaconInterval )
2980 {
2981 //Make sure it is bigger than the minimal
Jeff Johnsone7245742012-09-05 17:12:55 -07002982 pBssConfig->uJoinTimeOut = CSR_ROAM_MAX(10 * pBssDesc->beaconInterval, CSR_JOIN_FAILURE_TIMEOUT_MIN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002983 }
2984 else
2985 {
2986 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
2987 }
2988 //validate CB
2989 pBssConfig->cbMode = csrGetCBModeFromIes(pMac, pBssDesc->channelId, pIes);
Sandeep Puligilla60342762014-01-30 21:05:37 +05302990
Jeff Johnson295189b2012-06-20 16:38:30 -07002991 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002992 return (status);
2993}
2994
Jeff Johnson295189b2012-06-20 16:38:30 -07002995static eHalStatus csrRoamPrepareBssConfigFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2996 tBssConfigParam *pBssConfig, tSirBssDescription *pBssDesc)
2997{
2998 eHalStatus status = eHAL_STATUS_SUCCESS;
2999 tANI_U8 operationChannel = 0;
3000 tANI_U8 qAPisEnabled = FALSE;
3001 //SSID
3002 pBssConfig->SSID.length = 0;
3003 if(pProfile->SSIDs.numOfSSIDs)
3004 {
3005 //only use the first one
Kiet Lam64c1b492013-07-12 13:56:44 +05303006 vos_mem_copy(&pBssConfig->SSID, &pProfile->SSIDs.SSIDList[0].SSID,
3007 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003008 }
3009 else
3010 {
3011 //SSID must present
3012 return eHAL_STATUS_FAILURE;
3013 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003014 //Settomg up the capabilities
3015 if( csrIsBssTypeIBSS(pProfile->BSSType) )
3016 {
3017 pBssConfig->BssCap.ibss = 1;
3018 }
3019 else
3020 {
3021 pBssConfig->BssCap.ess = 1;
3022 }
3023 if( eCSR_ENCRYPT_TYPE_NONE != pProfile->EncryptionType.encryptionType[0] )
3024 {
3025 pBssConfig->BssCap.privacy = 1;
3026 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003027 pBssConfig->eBand = pMac->roam.configParam.eBand;
3028 //phymode
3029 if(pProfile->ChannelInfo.ChannelList)
3030 {
3031 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3032 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003033 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, operationChannel,
3034 &pBssConfig->eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07003035 //QOS
3036 //Is this correct to always set to this //***
Jeff Johnson295189b2012-06-20 16:38:30 -07003037 if ( pBssConfig->BssCap.ess == 1 )
3038 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003039 /*For Softap case enable WMM*/
3040 if(CSR_IS_INFRA_AP(pProfile) && (eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode )){
3041 qAPisEnabled = TRUE;
3042 }
3043 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003044 if (csrRoamGetQosInfoFromBss(pMac, pBssDesc) == eHAL_STATUS_SUCCESS) {
3045 qAPisEnabled = TRUE;
3046 } else {
3047 qAPisEnabled = FALSE;
3048 }
3049 } else {
3050 qAPisEnabled = TRUE;
3051 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003052 if (( eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode && qAPisEnabled) ||
3053 (( eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode && qAPisEnabled) ||
3054 ( eCSR_CFG_DOT11_MODE_TAURUS == pBssConfig->uCfgDot11Mode ) ) //For 11n, need QoS
3055 )
3056 {
3057 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3058 } else {
3059 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3060 }
3061
3062 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08003063 switch( pProfile->AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07003064 {
3065 default:
3066 case eCSR_AUTH_TYPE_WPA:
3067 case eCSR_AUTH_TYPE_WPA_PSK:
3068 case eCSR_AUTH_TYPE_WPA_NONE:
3069 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3070 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3071 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003072 case eCSR_AUTH_TYPE_SHARED_KEY:
3073 pBssConfig->authType = eSIR_SHARED_KEY;
3074 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003075 case eCSR_AUTH_TYPE_AUTOSWITCH:
3076 pBssConfig->authType = eSIR_AUTO_SWITCH;
3077 break;
3078 }
3079 //short slot time
3080 if( WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode )
3081 {
3082 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3083 }
3084 else
3085 {
3086 pBssConfig->uShortSlotTime = 0;
3087 }
3088 //power constraint. We don't support 11h on IBSS
3089 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3090 pBssConfig->uPowerLimit = 0;
3091 //heartbeat
3092 if ( eCSR_BAND_5G == pBssConfig->eBand )
3093 {
3094 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3095 }
3096 else
3097 {
3098 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3099 }
3100 //Join timeout
3101 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07003102
Jeff Johnson295189b2012-06-20 16:38:30 -07003103 return (status);
3104}
Jeff Johnson295189b2012-06-20 16:38:30 -07003105static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc)
3106{
3107 eHalStatus status = eHAL_STATUS_FAILURE;
3108 tDot11fBeaconIEs *pIes = NULL;
3109
3110 do
3111 {
3112 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
3113 {
3114 //err msg
3115 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003116 "csrRoamGetQosInfoFromBss() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07003117 break;
3118 }
3119 //check if the AP is QAP & it supports APSD
3120 if( CSR_IS_QOS_BSS(pIes) )
3121 {
Kiet Lamb537cfb2013-11-07 12:56:49 +05303122 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07003123 }
3124 } while (0);
Kiet Lamb537cfb2013-11-07 12:56:49 +05303125
3126 if (NULL != pIes)
3127 {
3128 vos_mem_free(pIes);
3129 }
3130
Jeff Johnson295189b2012-06-20 16:38:30 -07003131 return status;
3132}
3133
Jeff Johnson295189b2012-06-20 16:38:30 -07003134void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
3135{
Jeff Johnson295189b2012-06-20 16:38:30 -07003136 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
3137 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
3138 // See !!Note: below in this function...
3139 tANI_U32 PrivacyEnabled = 0;
3140 tANI_U32 RsnEnabled = 0;
3141 tANI_U32 WepDefaultKeyId = 0;
3142 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
3143 tANI_U32 Key0Length = 0;
3144 tANI_U32 Key1Length = 0;
3145 tANI_U32 Key2Length = 0;
3146 tANI_U32 Key3Length = 0;
3147
3148 // Reserve for the biggest key
3149 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
3150 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
3151 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
3152 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
3153
3154 switch ( pProfile->negotiatedUCEncryptionType )
3155 {
3156 case eCSR_ENCRYPT_TYPE_NONE:
3157
3158 // for NO encryption, turn off Privacy and Rsn.
3159 PrivacyEnabled = 0;
3160 RsnEnabled = 0;
3161
3162 // WEP key length and Wep Default Key ID don't matter in this case....
3163
3164 // clear out the WEP keys that may be hanging around.
3165 Key0Length = 0;
3166 Key1Length = 0;
3167 Key2Length = 0;
3168 Key3Length = 0;
3169
3170 break;
3171
3172 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303173 case eCSR_ENCRYPT_TYPE_WEP40:
Jeff Johnson295189b2012-06-20 16:38:30 -07003174
3175 // Privacy is ON. NO RSN for Wep40 static key.
3176 PrivacyEnabled = 1;
3177 RsnEnabled = 0;
3178
3179 // Set the Wep default key ID.
3180 WepDefaultKeyId = pProfile->Keys.defaultIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07003181 // Wep key size if 5 bytes (40 bits).
3182 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
3183
3184 // set encryption keys in the CFG database or clear those that are not present in this profile.
3185 if ( pProfile->Keys.KeyLength[0] )
3186 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303187 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[0],
3188 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003189 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
3190 }
3191 else
3192 {
3193 Key0Length = 0;
3194 }
3195
3196 if ( pProfile->Keys.KeyLength[1] )
3197 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303198 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[1],
3199 WNI_CFG_WEP_KEY_LENGTH_5);
3200 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
Jeff Johnson295189b2012-06-20 16:38:30 -07003201 }
3202 else
3203 {
3204 Key1Length = 0;
3205 }
3206
3207 if ( pProfile->Keys.KeyLength[2] )
3208 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303209 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[2],
3210 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003211 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
3212 }
3213 else
3214 {
3215 Key2Length = 0;
3216 }
3217
3218 if ( pProfile->Keys.KeyLength[3] )
3219 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303220 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[3],
3221 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003222 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
3223 }
3224 else
3225 {
3226 Key3Length = 0;
3227 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003228 break;
3229
3230 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303231 case eCSR_ENCRYPT_TYPE_WEP104:
Jeff Johnson295189b2012-06-20 16:38:30 -07003232
3233 // Privacy is ON. NO RSN for Wep40 static key.
3234 PrivacyEnabled = 1;
3235 RsnEnabled = 0;
3236
3237 // Set the Wep default key ID.
3238 WepDefaultKeyId = pProfile->Keys.defaultIndex;
3239
3240 // Wep key size if 13 bytes (104 bits).
3241 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
3242
3243 // set encryption keys in the CFG database or clear those that are not present in this profile.
3244 if ( pProfile->Keys.KeyLength[0] )
3245 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303246 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[ 0 ],
3247 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003248 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
3249 }
3250 else
3251 {
3252 Key0Length = 0;
3253 }
3254
3255 if ( pProfile->Keys.KeyLength[1] )
3256 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303257 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[ 1 ],
3258 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003259 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
3260 }
3261 else
3262 {
3263 Key1Length = 0;
3264 }
3265
3266 if ( pProfile->Keys.KeyLength[2] )
3267 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303268 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[ 2 ],
3269 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003270 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
3271 }
3272 else
3273 {
3274 Key2Length = 0;
3275 }
3276
3277 if ( pProfile->Keys.KeyLength[3] )
3278 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303279 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[ 3 ],
3280 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003281 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
3282 }
3283 else
3284 {
3285 Key3Length = 0;
3286 }
3287
3288 break;
3289
Jeff Johnson295189b2012-06-20 16:38:30 -07003290 case eCSR_ENCRYPT_TYPE_TKIP:
3291 case eCSR_ENCRYPT_TYPE_AES:
3292#ifdef FEATURE_WLAN_WAPI
3293 case eCSR_ENCRYPT_TYPE_WPI:
3294#endif /* FEATURE_WLAN_WAPI */
3295 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
3296 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
3297 PrivacyEnabled = (0 != fPrivacy);
3298
3299 // turn on RSN enabled for WPA associations
3300 RsnEnabled = 1;
3301
3302 // WEP key length and Wep Default Key ID don't matter in this case....
3303
3304 // clear out the static WEP keys that may be hanging around.
3305 Key0Length = 0;
3306 Key1Length = 0;
3307 Key2Length = 0;
3308 Key3Length = 0;
3309
3310 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003311 default:
3312 PrivacyEnabled = 0;
3313 RsnEnabled = 0;
3314 break;
3315 }
3316
3317 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
3318 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
3319 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
3320 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
3321 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
3322 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
3323 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
3324 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
3325}
3326
Jeff Johnson295189b2012-06-20 16:38:30 -07003327static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
3328{
3329 tANI_U32 len = 0;
3330 if(pSSID->length <= WNI_CFG_SSID_LEN)
3331 {
3332 len = pSSID->length;
3333 }
3334 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
3335}
3336
Jeff Johnson295189b2012-06-20 16:38:30 -07003337eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
3338{
3339 eHalStatus status = eHAL_STATUS_SUCCESS;
3340 tANI_U32 QoSEnabled;
3341 tANI_U32 WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003342 // set the CFG enable/disable variables based on the qosType being configured...
3343 switch( qosType )
3344 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003345 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
3346 QoSEnabled = FALSE;
3347 WmeEnabled = TRUE;
3348 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003349 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
3350 QoSEnabled = FALSE;
3351 WmeEnabled = TRUE;
3352 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003353 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
3354 QoSEnabled = FALSE;
3355 WmeEnabled = TRUE;
3356 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003357 case eCSR_MEDIUM_ACCESS_11e_eDCF:
3358 QoSEnabled = TRUE;
3359 WmeEnabled = FALSE;
3360 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003361 case eCSR_MEDIUM_ACCESS_11e_HCF:
3362 QoSEnabled = TRUE;
3363 WmeEnabled = FALSE;
3364 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003365 default:
3366 case eCSR_MEDIUM_ACCESS_DCF:
3367 QoSEnabled = FALSE;
3368 WmeEnabled = FALSE;
3369 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003370 }
3371 //save the WMM setting for later use
3372 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
Sandeep Puligillaaea98a22013-12-04 13:36:32 +05303373 pMac->roam.roamSession[sessionId].fQOSConnection = (tANI_BOOLEAN)QoSEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003374 return (status);
3375}
Jeff Johnson295189b2012-06-20 16:38:30 -07003376static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
3377 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet)
3378{
3379 eHalStatus status = eHAL_STATUS_FAILURE;
3380 int i;
3381 eCsrCfgDot11Mode cfgDot11Mode;
3382 tANI_U8 *pDstRate;
Kiet Lam64c1b492013-07-12 13:56:44 +05303383 vos_mem_set(pOpRateSet, sizeof(tSirMacRateSet), 0);
3384 vos_mem_set(pExRateSet, sizeof(tSirMacRateSet), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003385 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003386
3387 if( NULL != pIes )
3388 {
3389 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003390 // Originally, we thought that for 11a networks, the 11a rates are always
3391 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3392 // appear in the Operational Rate set. Consequently, in either case, we
3393 // would blindly put the rates we support into our Operational Rate set
3394 // (including the basic rates, which we have already verified are
3395 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003396 // However, it turns out that this is not always the case. Some AP's
3397 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3398 // too. Now, we're a little more careful:
3399 pDstRate = pOpRateSet->rate;
3400 if(pIes->SuppRates.present)
3401 {
3402 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3403 {
3404 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
3405 {
3406 *pDstRate++ = pIes->SuppRates.rates[ i ];
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003407 pOpRateSet->numRates++;
Jeff Johnson295189b2012-06-20 16:38:30 -07003408 }
3409 }
3410 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003411 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3412 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3413 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3414 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3415 {
3416 // If there are Extended Rates in the beacon, we will reflect those
3417 // extended rates that we support in out Extended Operational Rate
3418 // set:
3419 pDstRate = pExRateSet->rate;
3420 if(pIes->ExtSuppRates.present)
3421 {
3422 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3423 {
3424 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) )
3425 {
3426 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3427 pExRateSet->numRates++;
3428 }
3429 }
3430 }
3431 }
3432 }//Parsing BSSDesc
3433 else
3434 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003435 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003436 }
3437 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
3438 return status;
3439}
3440
3441static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
3442 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3443{
3444 int i;
3445 tANI_U8 *pDstRate;
3446 eCsrCfgDot11Mode cfgDot11Mode;
3447 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3448 tANI_U32 OperationalRatesLength = 0;
3449 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3450 tANI_U32 ExtendedOperationalRatesLength = 0;
3451 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3452 tANI_U32 ProprietaryOperationalRatesLength = 0;
3453 tANI_U32 PropRatesEnable = 0;
3454 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
3455 tANI_U32 MCSRateLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003456 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003457 if( NULL != pIes )
3458 {
3459 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003460 // Originally, we thought that for 11a networks, the 11a rates are always
3461 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3462 // appear in the Operational Rate set. Consequently, in either case, we
3463 // would blindly put the rates we support into our Operational Rate set
3464 // (including the basic rates, which we have already verified are
3465 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003466 // However, it turns out that this is not always the case. Some AP's
3467 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3468 // too. Now, we're a little more careful:
3469 pDstRate = OperationalRates;
3470 if(pIes->SuppRates.present)
3471 {
3472 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3473 {
3474 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
3475 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
3476 {
3477 *pDstRate++ = pIes->SuppRates.rates[ i ];
3478 OperationalRatesLength++;
3479 }
3480 }
3481 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003482 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3483 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3484 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3485 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3486 {
3487 // If there are Extended Rates in the beacon, we will reflect those
3488 // extended rates that we support in out Extended Operational Rate
3489 // set:
3490 pDstRate = ExtendedOperationalRates;
3491 if(pIes->ExtSuppRates.present)
3492 {
3493 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3494 {
3495 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
3496 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
3497 {
3498 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3499 ExtendedOperationalRatesLength++;
3500 }
3501 }
3502 }
3503 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003504 // Enable proprietary MAC features if peer node is Airgo node and STA
3505 // user wants to use them
3506 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
3507 {
3508 PropRatesEnable = 1;
3509 }
3510 else
3511 {
3512 PropRatesEnable = 0;
3513 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003514 // For ANI network companions, we need to populate the proprietary rate
3515 // set with any proprietary rates we found in the beacon, only if user
3516 // allows them...
3517 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
3518 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
3519 {
3520 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
3521 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
3522 {
3523 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
3524 }
Kiet Lam64c1b492013-07-12 13:56:44 +05303525 vos_mem_copy(ProprietaryOperationalRates,
3526 pIes->Airgo.PropSuppRates.rates,
3527 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003528 }
3529 else {
3530 // No proprietary modes...
3531 ProprietaryOperationalRatesLength = 0;
3532 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003533 /* Get MCS Rate */
3534 pDstRate = MCSRateIdxSet;
3535 if ( pIes->HTCaps.present )
3536 {
3537 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
3538 {
3539 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
3540 {
3541 MCSRateLength++;
3542 *pDstRate++ = i;
3543 }
3544 }
3545 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003546 // Set the operational rate set CFG variables...
3547 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3548 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3549 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3550 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3551 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3552 ProprietaryOperationalRates,
3553 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3554 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
3555 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
3556 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
3557 }//Parsing BSSDesc
3558 else
3559 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003560 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003561 }
3562}
3563
Jeff Johnson295189b2012-06-20 16:38:30 -07003564static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
3565 tCsrRoamProfile *pProfile )
3566{
3567 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
3568 { 8,
3569 { SIR_MAC_RATE_6,
3570 SIR_MAC_RATE_9,
3571 SIR_MAC_RATE_12,
3572 SIR_MAC_RATE_18,
3573 SIR_MAC_RATE_24,
3574 SIR_MAC_RATE_36,
3575 SIR_MAC_RATE_48,
3576 SIR_MAC_RATE_54 } } };
Jeff Johnson295189b2012-06-20 16:38:30 -07003577 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
3578 { 4,
3579 { SIR_MAC_RATE_1,
3580 SIR_MAC_RATE_2,
3581 SIR_MAC_RATE_5_5,
3582 SIR_MAC_RATE_11 } } };
3583
3584
3585 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
3586 { SIR_MAC_RATE_72,
3587 SIR_MAC_RATE_96,
3588 SIR_MAC_RATE_108 } };
3589 eCsrCfgDot11Mode cfgDot11Mode;
3590 eCsrBand eBand;
3591 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3592 tANI_U32 OperationalRatesLength = 0;
3593 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3594 tANI_U32 ExtendedOperationalRatesLength = 0;
3595 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3596 tANI_U32 ProprietaryOperationalRatesLength = 0;
3597 tANI_U32 PropRatesEnable = 0;
3598 tANI_U8 operationChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003599 if(pProfile->ChannelInfo.ChannelList)
3600 {
3601 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3602 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003603 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -07003604 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
3605 // networks, the 11b rates appear in the Operational Rate set. In either case,
3606 // we can blindly put the rates we support into our Operational Rate set
3607 // (including the basic rates, which we have already verified are supported
3608 // earlier in the roaming decision).
3609 if ( eCSR_BAND_5G == eBand )
3610 {
3611 // 11a rates into the Operational Rate Set.
3612 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3613 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303614 vos_mem_copy(OperationalRates,
3615 DefaultSupportedRates11a.supportedRateSet.rate,
3616 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003617
3618 // Nothing in the Extended rate set.
3619 ExtendedOperationalRatesLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003620 // populate proprietary rates if user allows them
3621 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3622 {
3623 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3624 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303625 vos_mem_copy(ProprietaryOperationalRates,
3626 DefaultSupportedPropRates.propRate,
3627 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003628 }
3629 else
3630 {
3631 // No proprietary modes
3632 ProprietaryOperationalRatesLength = 0;
3633 }
3634 }
3635 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
3636 {
3637 // 11b rates into the Operational Rate Set.
3638 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3639 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303640 vos_mem_copy(OperationalRates,
3641 DefaultSupportedRates11b.supportedRateSet.rate,
3642 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003643 // Nothing in the Extended rate set.
3644 ExtendedOperationalRatesLength = 0;
3645 // No proprietary modes
3646 ProprietaryOperationalRatesLength = 0;
3647 }
3648 else
3649 {
3650 // 11G
3651
3652 // 11b rates into the Operational Rate Set.
3653 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3654 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303655 vos_mem_copy(OperationalRates,
3656 DefaultSupportedRates11b.supportedRateSet.rate,
3657 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003658
3659 // 11a rates go in the Extended rate set.
3660 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3661 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303662 vos_mem_copy(ExtendedOperationalRates,
3663 DefaultSupportedRates11a.supportedRateSet.rate,
3664 ExtendedOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003665
3666 // populate proprietary rates if user allows them
3667 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3668 {
3669 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3670 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303671 vos_mem_copy(ProprietaryOperationalRates,
3672 DefaultSupportedPropRates.propRate,
3673 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003674 }
3675 else
3676 {
3677 // No proprietary modes
3678 ProprietaryOperationalRatesLength = 0;
3679 }
3680 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003681 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
3682 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
3683 {
3684 PropRatesEnable = 1;
3685 }
3686 else
3687 {
3688 PropRatesEnable = 0;
3689 }
3690
3691 // Set the operational rate set CFG variables...
3692 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3693 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3694 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3695 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3696 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3697 ProprietaryOperationalRates,
3698 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3699 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003700}
Jeff Johnson295189b2012-06-20 16:38:30 -07003701void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
3702{
3703 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07003704
Jeff Johnson295189b2012-06-20 16:38:30 -07003705 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
3706 tANI_U32 sessionId;
3707 tSmeCmd *pCommand = NULL;
3708
3709 if(NULL == pEntry)
3710 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003711 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07003712 return;
3713 }
3714 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
3715 sessionId = pCommand->sessionId;
3716
3717 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
3718 {
3719 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
3720 }
3721}
3722
Jeff Johnson295189b2012-06-20 16:38:30 -07003723//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
3724tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
3725{
3726 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
3727 {
3728 return (WNI_CFG_PHY_MODE_11B);
3729 }
3730 else
3731 {
3732 if(eCSR_BAND_24 == band)
3733 return (WNI_CFG_PHY_MODE_11G);
3734 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003735 return (WNI_CFG_PHY_MODE_11A);
3736}
Jeff Johnson295189b2012-06-20 16:38:30 -07003737
Jeff Johnsone7245742012-09-05 17:12:55 -07003738
3739#ifdef WLAN_FEATURE_11AC
3740ePhyChanBondState csrGetHTCBStateFromVHTCBState(ePhyChanBondState aniCBMode)
3741{
3742 switch ( aniCBMode )
3743 {
3744 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
3745 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
3746 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
3747 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3748 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
3749 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
3750 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
3751 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3752 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003753 default :
Jeff Johnsone7245742012-09-05 17:12:55 -07003754 return PHY_SINGLE_CHANNEL_CENTERED;
3755 }
3756}
3757#endif
3758
Jeff Johnson295189b2012-06-20 16:38:30 -07003759//pIes may be NULL
3760eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3761 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303762 tDot11fBeaconIEs *pIes, tANI_BOOLEAN resetCountry)
Jeff Johnson295189b2012-06-20 16:38:30 -07003763{
3764 eHalStatus status = eHAL_STATUS_SUCCESS;
3765 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3766 tANI_U8 channel = 0;
3767 //Make sure we have the domain info for the BSS we try to connect to.
3768 //Do we need to worry about sequence for OSs that are not Windows??
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303769 if (pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -07003770 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303771 if (csrLearnCountryInformation(pMac, pBssDesc, pIes, eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07003772 {
3773 //Make sure the 11d info from this BSSDesc can be applied
3774 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303775 if (VOS_TRUE == resetCountry)
3776 {
3777 csrApplyCountryInformation(pMac, FALSE);
3778 }
3779 else
3780 {
3781 csrApplyCountryInformation(pMac, TRUE);
3782 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003783 }
Kiran4a17ebe2013-01-31 10:43:43 -08003784 if ((csrIs11dSupported (pMac)) && pIes)
3785 {
3786 if (!pIes->Country.present)
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003787 {
Kiran4a17ebe2013-01-31 10:43:43 -08003788 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE );
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003789 }
3790 else
3791 {
3792 //Let's also update the below to make sure we don't update CC while
3793 //connected to an AP which is advertising some CC
Kiet Lamf2f201e2013-11-16 21:24:16 +05303794 vos_mem_copy(pMac->scan.currentCountryBssid,
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003795 pBssDesc->bssId, sizeof(tSirMacAddr));
3796 }
Kiran4a17ebe2013-01-31 10:43:43 -08003797 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003798 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003799 //Qos
3800 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
3801 //SSID
3802 csrSetCfgSsid(pMac, &pBssConfig->SSID );
3803 //fragment threshold
3804 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3805 //RTS threshold
3806 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3807
3808 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003809 //Auth type
3810 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
3811 //encryption type
3812 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
3813 //short slot time
3814 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003815 //11d
3816 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
3817 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
3818 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003819 /*//11h
3820 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
3821 */
3822 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
3823 //CB
Jeff Johnsone7245742012-09-05 17:12:55 -07003824
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003825 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile) || CSR_IS_IBSS(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07003826 {
3827 channel = pProfile->operationChannel;
3828 }
3829 else
3830 {
3831 if(pBssDesc)
3832 {
3833 channel = pBssDesc->channelId;
3834 }
3835 }
3836 if(0 != channel)
3837 {
Sandeep Puligilla60342762014-01-30 21:05:37 +05303838 if(CSR_IS_CHANNEL_24GHZ(channel) &&
3839 !pMac->roam.configParam.channelBondingMode24GHz &&
3840 !WDA_getFwWlanFeatCaps(HT40_OBSS_SCAN))
3841 {//On 2.4 Ghz, CB will be disabled if it is not configured through .ini
Jeff Johnson295189b2012-06-20 16:38:30 -07003842 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Sandeep Puligilla60342762014-01-30 21:05:37 +05303843 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
3844 " cbMode disabled cfgCb = %d channelBondingMode24GHz %d",
3845 __func__, cfgCb, pMac->roam.configParam.channelBondingMode24GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07003846 }
3847 else
3848 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003849 cfgCb = pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003850 }
3851 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003852#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudia0d88932012-11-13 10:51:26 -08003853 // cbMode = 1 in cfg.ini is mapped to PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
3854 // in function csrConvertCBIniValueToPhyCBState()
3855 // So, max value for cbMode in 40MHz mode is 3 (MAC\src\include\sirParams.h)
3856 if(cfgCb > PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
Jeff Johnsone7245742012-09-05 17:12:55 -07003857 {
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003858 if(!WDA_getFwWlanFeatCaps(DOT11AC)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07003859 cfgCb = csrGetHTCBStateFromVHTCBState(cfgCb);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003860 }
Sandeep Puligilla60342762014-01-30 21:05:37 +05303861 else
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003862 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003863 ccmCfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, pMac->roam.configParam.nVhtChannelWidth, NULL, eANI_BOOLEAN_FALSE);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003864 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003865 }
3866 else
3867#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003868 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
3869 //Rate
3870 //Fixed Rate
3871 if(pBssDesc)
3872 {
3873 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
3874 }
3875 else
3876 {
3877 csrSetCfgRateSetFromProfile(pMac, pProfile);
3878 }
3879 //Make this the last CFG to set. The callback will trigger a join_req
3880 //Join time out
3881 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
3882
3883 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003884 return (status);
3885}
3886
Jeff Johnson295189b2012-06-20 16:38:30 -07003887eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3888 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3889{
3890 eHalStatus status;
3891 tBssConfigParam *pBssConfig;
3892 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003893
3894 if(!pSession)
3895 {
3896 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3897 return eHAL_STATUS_FAILURE;
3898 }
3899
Kiet Lam64c1b492013-07-12 13:56:44 +05303900 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
3901 if ( NULL == pBssConfig )
3902 status = eHAL_STATUS_FAILURE;
3903 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003904 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303905 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003906 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
3907 if(HAL_STATUS_SUCCESS(status))
3908 {
3909 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003910 /* This will allow to pass cbMode during join req */
3911 pSession->bssParams.cbMode= pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003912 //For IBSS, we need to prepare some more information
3913 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003914 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003915 )
3916 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003917 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07003918 }
3919 // If we are in an IBSS, then stop the IBSS...
3920 ////Not worry about WDS connection for now
3921 if ( csrIsConnStateIbss( pMac, sessionId ) )
3922 {
3923 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
3924 }
3925 else
3926 {
3927 // if we are in an Infrastructure association....
3928 if ( csrIsConnStateInfra( pMac, sessionId ) )
3929 {
3930 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
3931 // across SSIDs (roaming to a new SSID)... //
3932 //Not worry about WDS connection for now
3933 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303934 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003935 {
3936 // then we need to disassociate from the Infrastructure network...
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303937 status = csrRoamIssueDisassociate( pMac, sessionId,
3938 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07003939 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303940 else
3941 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003942 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
3943 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303944 if ( pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -07003945 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303946 // Set parameters for this Bss.
3947 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
3948 pBssDesc, pBssConfig,
3949 pIes, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003950 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303951 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003952 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303953 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003954 {
3955 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
3956 // Nothing to stop.
3957 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003958 || CSR_IS_INFRA_AP(pProfile)
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303959 )
3960 {
3961 tANI_BOOLEAN is11rRoamingFlag = eANI_BOOLEAN_FALSE;
3962 is11rRoamingFlag = csrRoamIs11rAssoc(pMac);
3963 // Set parameters for this Bss.
3964 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
3965 pBssDesc, pBssConfig,
3966 pIes, is11rRoamingFlag);
3967 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003968 }
3969 }
3970 }//Success getting BSS config info
Kiet Lam64c1b492013-07-12 13:56:44 +05303971 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -07003972 }//Allocate memory
Jeff Johnson295189b2012-06-20 16:38:30 -07003973 return (status);
3974}
3975
Jeff Johnson295189b2012-06-20 16:38:30 -07003976eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
3977 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
3978{
3979 eCsrJoinState eRoamState = eCsrContinueRoaming;
3980 eHalStatus status;
3981 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
3982 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
3983 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003984
3985 if(!pSession)
3986 {
3987 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3988 return (eCsrStopRoaming);
3989 }
3990
Jeff Johnson295189b2012-06-20 16:38:30 -07003991 if( CSR_IS_WDS_STA( pProfile ) )
3992 {
3993 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
3994 if( !HAL_STATUS_SUCCESS( status ) )
3995 {
3996 eRoamState = eCsrStopRoaming;
3997 }
3998 }
3999 else
4000 {
4001 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
4002 {
4003 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
4004 return (eCsrStopRoaming);
4005 }
4006 if ( csrIsInfraBssDesc( pBssDesc ) )
4007 {
4008 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
4009 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
4010 // have changed and handle the changes (without disturbing the current association).
4011
4012 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
4013 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
4014 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
4015 )
4016 {
4017 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
4018 // with Authenticating first. To force this, stop the current association (Disassociate) and
4019 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
4020 // a new Association.
4021 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4022 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07004023 smsLog(pMac, LOGW, FL(" detect same profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004024 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
4025 {
4026 eRoamState = eCsrReassocToSelfNoCapChange;
4027 }
4028 else
4029 {
4030 tBssConfigParam bssConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004031 //The key changes
Kiet Lam64c1b492013-07-12 13:56:44 +05304032 vos_mem_set(&bssConfig, sizeof(bssConfig), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004033 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
4034 if(HAL_STATUS_SUCCESS(status))
4035 {
4036 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07004037 pSession->bssParams.cbMode = bssConfig.cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004038 //Reapply the config including Keys so reassoc is happening.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304039 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4040 pBssDesc, &bssConfig,
4041 pIesLocal, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004042 if(!HAL_STATUS_SUCCESS(status))
4043 {
4044 eRoamState = eCsrStopRoaming;
4045 }
4046 }
4047 else
4048 {
4049 eRoamState = eCsrStopRoaming;
4050 }
4051 }//same profile
4052 }
4053 else
4054 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304055 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004056 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
4057 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05304058 smsLog(pMac, LOGE, FL(" fail to issue disassociate with Session ID %d"),
4059 sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004060 eRoamState = eCsrStopRoaming;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304061 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004062 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304063 }
4064 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004065 {
4066 // 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 +05304067 // we had a lot of join timeouts when testing at Samsung. removing this step helped associations
Jeff Johnson295189b2012-06-20 16:38:30 -07004068 // work much better.
4069 //
4070 //
4071 // stop the existing network before attempting to join the new network...
4072 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4073 {
4074 eRoamState = eCsrStopRoaming;
4075 }
4076 }
4077 }//Infra
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304078 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004079 {
4080 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4081 {
4082 eRoamState = eCsrStopRoaming;
4083 }
4084 }
4085 if( pIesLocal && !pScanResult->pvIes )
4086 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304087 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004088 }
4089 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004090 return( eRoamState );
4091}
4092
Jeff Johnson295189b2012-06-20 16:38:30 -07004093eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
4094 tSirBssDescription *pBssDesc, tANI_U32 roamId)
4095{
4096 eHalStatus status = eHAL_STATUS_SUCCESS;
4097 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05304098 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004099 roamInfo.pBssDesc = pBssDesc;
4100 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
4101 return (status);
4102}
Jeff Johnson295189b2012-06-20 16:38:30 -07004103//In case no matching BSS is found, use whatever default we can find
4104static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4105{
4106 //Need to get all negotiated types in place first
4107 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08004108 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07004109 {
4110 default:
4111 case eCSR_AUTH_TYPE_WPA:
4112 case eCSR_AUTH_TYPE_WPA_PSK:
4113 case eCSR_AUTH_TYPE_WPA_NONE:
4114 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4115 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4116 break;
4117
4118 case eCSR_AUTH_TYPE_SHARED_KEY:
4119 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
4120 break;
4121
4122 case eCSR_AUTH_TYPE_AUTOSWITCH:
4123 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
4124 break;
4125 }
4126 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4127 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4128 //In this case, the multicast encryption needs to follow the uncast ones.
4129 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4130 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4131}
4132
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004133
4134static void csrSetAbortRoamingCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4135{
4136 switch(pCommand->u.roamCmd.roamReason)
4137 {
4138 case eCsrLostLink1:
4139 pCommand->u.roamCmd.roamReason = eCsrLostLink1Abort;
4140 break;
4141 case eCsrLostLink2:
4142 pCommand->u.roamCmd.roamReason = eCsrLostLink2Abort;
4143 break;
4144 case eCsrLostLink3:
4145 pCommand->u.roamCmd.roamReason = eCsrLostLink3Abort;
4146 break;
4147 default:
4148 smsLog(pMac, LOGE, FL(" aborting roaming reason %d not recognized"),
4149 pCommand->u.roamCmd.roamReason);
4150 break;
4151 }
4152}
4153
Jeff Johnson295189b2012-06-20 16:38:30 -07004154static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
4155{
4156 eHalStatus status;
4157 tCsrScanResult *pScanResult = NULL;
4158 eCsrJoinState eRoamState = eCsrStopRoaming;
4159 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
4160 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
4161 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
4162#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4163 v_U8_t acm_mask = 0;
4164#endif
4165 tANI_U32 sessionId = pCommand->sessionId;
4166 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4167 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4168 tANI_U8 concurrentChannel = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004169
4170 if(!pSession)
4171 {
4172 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4173 return (eCsrStopRoaming);
4174 }
4175
Jeff Johnson295189b2012-06-20 16:38:30 -07004176 do
4177 {
4178 // Check for Cardbus eject condition, before trying to Roam to any BSS
4179 //***if( !balIsCardPresent(pAdapter) ) break;
4180
Kiet Lam64c1b492013-07-12 13:56:44 +05304181 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004182 memcpy (&roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004183 if(NULL != pBSSList)
4184 {
4185 // When handling AP's capability change, continue to associate to
4186 // same BSS and make sure pRoamBssEntry is not Null.
4187 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
4188 {
4189 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
4190 {
4191 //Try the first BSS
4192 pCommand->u.roamCmd.pLastRoamBss = NULL;
4193 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
4194 }
4195 else
4196 {
4197 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4198 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4199 {
4200 //Done with all the BSSs
4201 //In this case, will tell HDD the completion
4202 break;
4203 }
4204 else
4205 {
4206 //We need to indicate to HDD that we are done with this one.
Kiet Lam64c1b492013-07-12 13:56:44 +05304207 //vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004208 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
4209 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4210 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4211 pRoamInfo = &roamInfo;
4212 }
4213 }
4214 while(pCommand->u.roamCmd.pRoamBssEntry)
4215 {
4216 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Jeff Johnson295189b2012-06-20 16:38:30 -07004217 /*If concurrency enabled take the concurrent connected channel first. */
4218 /* Valid multichannel concurrent sessions exempted */
Jeff Johnsone7245742012-09-05 17:12:55 -07004219 if (vos_concurrent_sessions_running() &&
4220 !csrIsValidMcConcurrentSession(pMac, sessionId, &pScanResult->Result.BssDescriptor))
Jeff Johnson295189b2012-06-20 16:38:30 -07004221 {
4222 concurrentChannel =
4223 csrGetConcurrentOperationChannel(pMac);
4224 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004225 " csr Concurrent Channel = %d", __func__, concurrentChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07004226 if ((concurrentChannel) &&
4227 (concurrentChannel ==
4228 pScanResult->Result.BssDescriptor.channelId))
4229 {
4230 //make this 0 because we do not want the
4231 //below check to pass as we don't want to
4232 //connect on other channel
4233 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4234 FL("Concurrent channel match =%d"),
4235 concurrentChannel);
4236 concurrentChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004237 }
4238 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004239
4240 if (!concurrentChannel)
4241 {
4242
4243 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
4244 sessionId, &pScanResult->Result.BssDescriptor,
4245 pCommand->u.roamCmd.roamId)))
4246 {
4247 //Ok to roam this
4248 break;
4249 }
4250 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004251 else
4252 {
4253 eRoamState = eCsrStopRoamingDueToConcurrency;
4254 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004255 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4256 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4257 {
4258 //Done with all the BSSs
4259 fDone = eANI_BOOLEAN_TRUE;
4260 break;
4261 }
4262 }
4263 if(fDone)
4264 {
4265 break;
4266 }
4267 }
4268 }
4269 //We have something to roam, tell HDD when it is infra.
4270 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
4271 //For WDS, the indication is eCSR_ROAM_WDS_IND
4272 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4273 {
4274 if(pRoamInfo)
4275 {
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004276 if(pSession->bRefAssocStartCnt)
4277 {
4278 pSession->bRefAssocStartCnt--;
4279 //Complete the last association attemp because a new one is about to be tried
4280 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4281 eCSR_ROAM_ASSOCIATION_COMPLETION,
Jeff Johnson295189b2012-06-20 16:38:30 -07004282 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004283 }
4284 }
4285 /* If the roaming has stopped, not to continue the roaming command*/
4286 if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
4287 {
4288 //No need to complete roaming here as it already completes
4289 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed"),
4290 pCommand->u.roamCmd.roamReason);
4291 eRoamState = eCsrStopRoaming;
4292 csrSetAbortRoamingCommand(pMac, pCommand);
4293 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004294 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304295 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004296 if(pScanResult)
4297 {
4298 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07004299 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
4300 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004301 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004302 fDone = eANI_BOOLEAN_TRUE;
4303 eRoamState = eCsrStopRoaming;
4304 break;
4305 }
4306 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
4307 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
4308 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
4309 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
4310 CSR_IS_QOS_BSS(pIesLocal) &&
4311 CSR_IS_UAPSD_BSS(pIesLocal) )
4312 {
4313#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Jeff Johnson295189b2012-06-20 16:38:30 -07004314 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
4315 pIesLocal);
4316 pCommand->u.roamCmd.roamProfile.uapsd_mask &= ~(acm_mask);
4317#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004318 }
4319 else
4320 {
4321 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4322 }
4323 if( pIesLocal && !pScanResult->Result.pvIes)
4324 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304325 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004326 }
4327 }
4328 else
4329 {
4330 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4331 }
4332 roamInfo.pProfile = pProfile;
4333 pSession->bRefAssocStartCnt++;
4334 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4335 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4336 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004337 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
4338 {
4339 // If this is a start IBSS profile, then we need to start the IBSS.
4340 if ( CSR_IS_START_IBSS(pProfile) )
4341 {
4342 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004343 // Attempt to start this IBSS...
4344 csrRoamAssignDefaultParam( pMac, pCommand );
4345 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
4346 if(HAL_STATUS_SUCCESS(status))
4347 {
4348 if ( fSameIbss )
4349 {
4350 eRoamState = eCsrStartIbssSameIbss;
4351 }
4352 else
4353 {
4354 eRoamState = eCsrContinueRoaming;
4355 }
4356 }
4357 else
4358 {
4359 //it somehow fail need to stop
4360 eRoamState = eCsrStopRoaming;
4361 }
4362 break;
4363 }
4364 else if ( (CSR_IS_WDS_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004365 || (CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004366 )
4367 {
4368 // Attempt to start this WDS...
4369 csrRoamAssignDefaultParam( pMac, pCommand );
4370 /* For AP WDS, we dont have any BSSDescription */
4371 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
4372 if(HAL_STATUS_SUCCESS(status))
4373 {
4374 eRoamState = eCsrContinueRoaming;
4375 }
4376 else
4377 {
4378 //it somehow fail need to stop
4379 eRoamState = eCsrStopRoaming;
4380 }
4381 }
4382 else
4383 {
4384 //Nothing we can do
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004385 smsLog(pMac, LOGW, FL("cannot continue without BSS list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004386 eRoamState = eCsrStopRoaming;
4387 break;
4388 }
4389 }
4390 else //We have BSS
4391 {
4392 //Need to assign these value because they are used in csrIsSameProfile
4393 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4394 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType = pScanResult->ucEncryptionType; //Negotiated while building scan result.
4395 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType = pScanResult->mcEncryptionType;
4396 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
4397 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
4398 {
4399 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4400 {
4401 eRoamState = eCsrStartIbssSameIbss;
4402 break;
4403 }
4404 }
4405 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
4406 {
4407 //trying to connect to the one already connected
4408 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
4409 eRoamState = eCsrReassocToSelfNoCapChange;
4410 break;
4411 }
4412 // Attempt to Join this Bss...
4413 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
4414 break;
4415 }
4416
4417 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004418 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
4419 {
4420 //Need to indicate association_completion if association_start has been done
4421 if(pSession->bRefAssocStartCnt > 0)
4422 {
4423 pSession->bRefAssocStartCnt--;
4424 //Complete the last association attemp because a new one is about to be tried
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004425 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07004426 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4427 eCSR_ROAM_ASSOCIATION_COMPLETION,
4428 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4429 }
4430 }
4431
4432 return( eRoamState );
4433}
4434
Jeff Johnson295189b2012-06-20 16:38:30 -07004435static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4436{
4437 eHalStatus status = eHAL_STATUS_SUCCESS;
4438 eCsrJoinState RoamState;
4439 tANI_U32 sessionId = pCommand->sessionId;
4440
Jeff Johnson295189b2012-06-20 16:38:30 -07004441 //***if( hddIsRadioStateOn( pAdapter ) )
4442 {
4443 // Attept to join a Bss...
4444 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07004445
Jeff Johnson295189b2012-06-20 16:38:30 -07004446 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07004447 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004448 {
4449 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004450 // and if connected in Infrastructure mode...
4451 if ( csrIsConnStateInfra(pMac, sessionId) )
4452 {
4453 //... then we need to issue a disassociation
4454 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
4455 if(!HAL_STATUS_SUCCESS(status))
4456 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004457 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004458 //roam command is completed by caller in the failed case
4459 fComplete = eANI_BOOLEAN_TRUE;
4460 }
4461 }
4462 else if( csrIsConnStateIbss(pMac, sessionId) )
4463 {
4464 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4465 if(!HAL_STATUS_SUCCESS(status))
4466 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004467 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004468 //roam command is completed by caller in the failed case
4469 fComplete = eANI_BOOLEAN_TRUE;
4470 }
4471 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004472 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
4473 {
4474 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4475 if(!HAL_STATUS_SUCCESS(status))
4476 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004477 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004478 //roam command is completed by caller in the failed case
4479 fComplete = eANI_BOOLEAN_TRUE;
4480 }
4481 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004482 else
4483 {
4484 fComplete = eANI_BOOLEAN_TRUE;
4485 }
4486 if(fComplete)
4487 {
4488 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07004489 if(eCsrStopRoamingDueToConcurrency == RoamState)
4490 {
4491 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
4492 }
4493 else
4494 {
4495 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
4496 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004497 }
4498 }
4499 else if ( eCsrReassocToSelfNoCapChange == RoamState )
4500 {
4501 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
4502 }
4503 else if ( eCsrStartIbssSameIbss == RoamState )
4504 {
4505 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
4506 }
4507 }//hddIsRadioStateOn
4508
4509 return status;
4510}
Jeff Johnson295189b2012-06-20 16:38:30 -07004511eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4512{
4513 tANI_U32 sessionId;
4514 tCsrRoamSession *pSession;
4515 tCsrScanResult *pScanResult = NULL;
4516 tSirBssDescription *pBssDesc = NULL;
4517 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004518 sessionId = pCommand->sessionId;
4519 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004520
4521 if(!pSession)
4522 {
4523 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4524 return eHAL_STATUS_FAILURE;
4525 }
4526
Jeff Johnson295189b2012-06-20 16:38:30 -07004527 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
4528 {
4529 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004530 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004531 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4532 return eHAL_STATUS_FAILURE;
4533 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004534 if (pCommand->u.roamCmd.pRoamBssEntry)
4535 {
4536 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4537 pBssDesc = &pScanResult->Result.BssDescriptor;
4538 }
4539 else
4540 {
4541 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004542 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004543 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4544 return eHAL_STATUS_FAILURE;
4545 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004546 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
4547 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
4548 return status;
4549}
4550
Jeff Johnson295189b2012-06-20 16:38:30 -07004551eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4552{
4553 eHalStatus status = eHAL_STATUS_SUCCESS;
4554 tCsrRoamInfo roamInfo;
4555 tANI_U32 sessionId = pCommand->sessionId;
4556 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004557
4558 if(!pSession)
4559 {
4560 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4561 return eHAL_STATUS_FAILURE;
4562 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004563
4564 switch ( pCommand->u.roamCmd.roamReason )
4565 {
4566 case eCsrForcedDisassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07004567 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004568 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004569 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004570 case eCsrSmeIssuedDisassocForHandoff:
4571 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
4572#if 0 // TODO : Confirm this change
4573 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
4574#else
4575 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4576#endif
4577
4578 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004579 case eCsrForcedDisassocMICFailure:
Jeff Johnson295189b2012-06-20 16:38:30 -07004580 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004581 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004582 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004583 case eCsrForcedDeauth:
Jeff Johnson295189b2012-06-20 16:38:30 -07004584 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004585 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004586 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004587 case eCsrHddIssuedReassocToSameAP:
4588 case eCsrSmeIssuedReassocToSameAP:
4589 {
4590 tDot11fBeaconIEs *pIes = NULL;
4591
Jeff Johnson295189b2012-06-20 16:38:30 -07004592 if( pSession->pConnectBssDesc )
4593 {
4594 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
4595 if(!HAL_STATUS_SUCCESS(status) )
4596 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004597 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004598 }
4599 else
4600 {
4601 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
4602 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
4603 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07004604 roamInfo.pBssDesc = pSession->pConnectBssDesc;
4605 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
4606 pSession->bRefAssocStartCnt++;
4607 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4608 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4609
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004610 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004611 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
4612 &pCommand->u.roamCmd.roamProfile );
4613 if(!HAL_STATUS_SUCCESS(status))
4614 {
4615 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08004616 csrReleaseCommandRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004617 }
4618
Kiet Lam64c1b492013-07-12 13:56:44 +05304619 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07004620 pIes = NULL;
4621 }
4622 }
4623 break;
4624 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004625 case eCsrCapsChange:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004626 smsLog(pMac, LOGE, FL("received eCsrCapsChange "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004627 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4628 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
4629 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004630 case eCsrSmeIssuedFTReassoc:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004631 smsLog(pMac, LOG1, FL("received FT Reassoc Req "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004632 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
4633 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07004634
Jeff Johnson295189b2012-06-20 16:38:30 -07004635 case eCsrStopBss:
4636 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4637 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4638 break;
4639
4640 case eCsrForcedDisassocSta:
4641 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4642 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
4643 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4644 pCommand->u.roamCmd.reason);
4645 break;
4646
4647 case eCsrForcedDeauthSta:
4648 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4649 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
4650 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4651 pCommand->u.roamCmd.reason);
4652 break;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004653
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004654 case eCsrPerformPreauth:
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08004655 smsLog(pMac, LOG1, FL("Attempting FT PreAuth Req"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004656 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
4657 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004658 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004659
4660 default:
4661 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4662
4663 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
4664 {
4665 //Remember the roaming profile
4666 csrFreeRoamProfile(pMac, sessionId);
Kiet Lam64c1b492013-07-12 13:56:44 +05304667 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
4668 if ( NULL != pSession->pCurRoamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004669 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304670 vos_mem_set(pSession->pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004671 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
4672 }
4673 }
4674
4675 //At this point, original uapsd_mask is saved in pCurRoamProfile
4676 //uapsd_mask in the pCommand may change from this point on.
4677
4678 // Attempt to roam with the new scan results (if we need to..)
4679 status = csrRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004680 if(!HAL_STATUS_SUCCESS(status))
4681 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004682 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X"), status);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004683 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004684 break;
4685 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004686 return (status);
4687}
4688
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004689void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4690{
4691 pCommand->u.roamCmd.pLastRoamBss = NULL;
4692 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4693 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05304694 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004695}
4696
Jeff Johnson295189b2012-06-20 16:38:30 -07004697void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4698{
4699 if(pCommand->u.roamCmd.fReleaseBssList)
4700 {
4701 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
4702 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
4703 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
4704 }
4705 if(pCommand->u.roamCmd.fReleaseProfile)
4706 {
4707 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
4708 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
4709 }
4710 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4711 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05304712 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004713}
4714
Jeff Johnson295189b2012-06-20 16:38:30 -07004715void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4716{
Kiet Lam64c1b492013-07-12 13:56:44 +05304717 vos_mem_set(&pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004718}
Jeff Johnson295189b2012-06-20 16:38:30 -07004719void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
4720{
4721 tListElem *pEntry;
4722 tSmeCmd *pCommand;
4723 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004724 smsLog( pMac, LOG2, "Roam Completion ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004725 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
4726 if ( pEntry )
4727 {
4728 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07004729 // If the head of the queue is Active and it is a ROAM command, remove
4730 // and put this on the Free queue.
4731 if ( eSmeCommandRoam == pCommand->command )
4732 {
4733 //we need to process the result first before removing it from active list because state changes
4734 //still happening insides roamQProcessRoamResults so no other roam command should be issued
4735 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
4736 if( fReleaseCommand )
4737 {
4738 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
4739 {
4740 csrReleaseCommandRoam( pMac, pCommand );
4741 }
4742 else
4743 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004744 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004745 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004746 }
4747 }
4748 else
4749 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004750 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004751 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004752 }
4753 }
4754 else
4755 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004756 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004757 }
4758 }
4759 else
4760 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004761 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004762 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004763 if( fReleaseCommand )
4764 {
4765 smeProcessPendingQueue( pMac );
4766 }
4767}
4768
Jeff Johnson295189b2012-06-20 16:38:30 -07004769void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4770{
4771 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004772 if(!pSession)
4773 {
4774 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4775 return;
4776 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304777 vos_mem_set(&(pSession->PmkidCandidateInfo[0]),
4778 sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004779 pSession->NumPmkidCandidate = 0;
4780}
Jeff Johnson295189b2012-06-20 16:38:30 -07004781#ifdef FEATURE_WLAN_WAPI
4782void csrResetBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4783{
4784 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004785 if(!pSession)
4786 {
4787 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4788 return;
4789 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304790 vos_mem_set(&(pSession->BkidCandidateInfo[0]),
4791 sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004792 pSession->NumBkidCandidate = 0;
4793}
4794#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004795extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
4796
Jeff Johnson295189b2012-06-20 16:38:30 -07004797static eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrAuthType authType,
4798 tSirBssDescription *pSirBssDesc,
4799 tDot11fBeaconIEs *pIes)
4800{
4801 eHalStatus status = eHAL_STATUS_SUCCESS;
4802 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4803 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004804
4805 if(!pSession)
4806 {
4807 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4808 return eHAL_STATUS_FAILURE;
4809 }
4810
Jeff Johnson295189b2012-06-20 16:38:30 -07004811 if((eCSR_AUTH_TYPE_WPA == authType) ||
4812 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
4813 (eCSR_AUTH_TYPE_RSN == authType) ||
4814 (eCSR_AUTH_TYPE_RSN_PSK == authType)
4815#if defined WLAN_FEATURE_VOWIFI_11R
4816 ||
4817 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4818 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
4819#endif /* FEATURE_WLAN_WAPI */
4820#ifdef FEATURE_WLAN_WAPI
4821 ||
4822 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4823 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
4824#endif /* FEATURE_WLAN_WAPI */
Chet Lanctot186b5732013-03-18 10:26:30 -07004825#ifdef WLAN_FEATURE_11W
4826 ||
4827 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType)
4828#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004829 )
4830 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004831 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4832 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004833 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004834 }
4835 if( pIesLocal )
4836 {
4837 tANI_U32 nIeLen;
4838 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07004839 if((eCSR_AUTH_TYPE_RSN == authType) ||
4840#if defined WLAN_FEATURE_VOWIFI_11R
4841 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4842 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
4843#endif /* WLAN_FEATURE_VOWIFI_11R */
Chet Lanctot186b5732013-03-18 10:26:30 -07004844#if defined WLAN_FEATURE_11W
4845 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
4846#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004847 (eCSR_AUTH_TYPE_RSN_PSK == authType))
4848 {
4849 if(pIesLocal->RSN.present)
4850 {
4851 //Calculate the actual length
4852 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
4853 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
4854 + 2 //akm_suite_count
4855 + pIesLocal->RSN.akm_suite_count * 4 //akm_suites
4856 + 2; //reserved
4857 if( pIesLocal->RSN.pmkid_count )
4858 {
4859 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
4860 }
4861 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304862 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
4863 if (NULL == pSession->pWpaRsnRspIE)
4864 status = eHAL_STATUS_FAILURE;
4865 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004866 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304867 vos_mem_set(pSession->pWpaRsnRspIE, nIeLen + 2, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004868 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
4869 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4870 //copy upto akm_suites
4871 pIeBuf = pSession->pWpaRsnRspIE + 2;
Kiet Lam64c1b492013-07-12 13:56:44 +05304872 vos_mem_copy(pIeBuf, &pIesLocal->RSN.version,
4873 sizeof(pIesLocal->RSN.version));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004874 pIeBuf += sizeof(pIesLocal->RSN.version);
Kiet Lam64c1b492013-07-12 13:56:44 +05304875 vos_mem_copy(pIeBuf, &pIesLocal->RSN.gp_cipher_suite,
4876 sizeof(pIesLocal->RSN.gp_cipher_suite));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004877 pIeBuf += sizeof(pIesLocal->RSN.gp_cipher_suite);
Kiet Lam64c1b492013-07-12 13:56:44 +05304878 vos_mem_copy(pIeBuf, &pIesLocal->RSN.pwise_cipher_suite_count,
4879 sizeof(pIesLocal->RSN.pwise_cipher_suite_count));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004880 pIeBuf += sizeof(pIesLocal->RSN.pwise_cipher_suite_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07004881 if( pIesLocal->RSN.pwise_cipher_suite_count )
4882 {
4883 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304884 vos_mem_copy(pIeBuf,
4885 pIesLocal->RSN.pwise_cipher_suites,
4886 pIesLocal->RSN.pwise_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004887 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
4888 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304889 vos_mem_copy(pIeBuf, &pIesLocal->RSN.akm_suite_count, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004890 pIeBuf += 2;
4891 if( pIesLocal->RSN.akm_suite_count )
4892 {
4893 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304894 vos_mem_copy(pIeBuf,
4895 pIesLocal->RSN.akm_suites,
4896 pIesLocal->RSN.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004897 pIeBuf += pIesLocal->RSN.akm_suite_count * 4;
4898 }
4899 //copy the rest
Kiet Lam64c1b492013-07-12 13:56:44 +05304900 vos_mem_copy(pIeBuf,
4901 pIesLocal->RSN.akm_suites + pIesLocal->RSN.akm_suite_count * 4,
4902 2 + pIesLocal->RSN.pmkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004903 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4904 }
4905 }
4906 }
4907 else if((eCSR_AUTH_TYPE_WPA == authType) ||
4908 (eCSR_AUTH_TYPE_WPA_PSK == authType))
4909 {
4910 if(pIesLocal->WPA.present)
4911 {
4912 //Calculate the actual length
4913 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
4914 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
4915 + 2 //auth_suite_count
4916 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
4917 // The WPA capabilities follows the Auth Suite (two octects)--
4918 // this field is optional, and we always "send" zero, so just
4919 // remove it. This is consistent with our assumptions in the
4920 // frames compiler; c.f. bug 15234:
4921 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304922
4923 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
4924 if ( NULL == pSession->pWpaRsnRspIE )
4925 status = eHAL_STATUS_FAILURE;
4926 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004927 {
4928 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
4929 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4930 pIeBuf = pSession->pWpaRsnRspIE + 2;
4931 //Copy WPA OUI
Kiet Lam64c1b492013-07-12 13:56:44 +05304932 vos_mem_copy(pIeBuf, &csrWpaOui[1], 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004933 pIeBuf += 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05304934 vos_mem_copy(pIeBuf, &pIesLocal->WPA.version,
4935 8 + pIesLocal->WPA.unicast_cipher_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004936 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05304937 vos_mem_copy(pIeBuf, &pIesLocal->WPA.auth_suite_count,
4938 2 + pIesLocal->WPA.auth_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004939 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
4940 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4941 }
4942 }
4943 }
4944#ifdef FEATURE_WLAN_WAPI
4945 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4946 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
4947 {
4948 if(pIesLocal->WAPI.present)
4949 {
4950 //Calculate the actual length
4951 nIeLen = 4 //version + akm_suite_count
4952 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
4953 + 2 //pwise_cipher_suite_count
4954 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
4955 + 6; //gp_cipher_suite + preauth + reserved
4956 if( pIesLocal->WAPI.bkid_count )
4957 {
4958 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
4959 }
4960
4961 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304962 pSession->pWapiRspIE = vos_mem_malloc(nIeLen + 2);
4963 if ( NULL == pSession->pWapiRspIE )
4964 status = eHAL_STATUS_FAILURE;
4965 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004966 {
4967 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
4968 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
4969 pIeBuf = pSession->pWapiRspIE + 2;
4970 //copy upto akm_suite_count
Kiet Lam64c1b492013-07-12 13:56:44 +05304971 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.version, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004972 pIeBuf += 4;
4973 if( pIesLocal->WAPI.akm_suite_count )
4974 {
4975 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304976 vos_mem_copy(pIeBuf, pIesLocal->WAPI.akm_suites,
4977 pIesLocal->WAPI.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004978 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05304979 }
4980 vos_mem_copy(pIeBuf,
4981 &pIesLocal->WAPI.unicast_cipher_suite_count,
4982 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004983 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004984 if( pIesLocal->WAPI.unicast_cipher_suite_count )
4985 {
4986 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304987 vos_mem_copy( pIeBuf,
4988 pIesLocal->WAPI.unicast_cipher_suites,
4989 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004990 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
4991 }
lukez3c809222013-05-03 10:23:02 -07004992 //gp_cipher_suite
Kiet Lam64c1b492013-07-12 13:56:44 +05304993 vos_mem_copy(pIeBuf,
4994 pIesLocal->WAPI.multicast_cipher_suite,
4995 4);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07004996 pIeBuf += 4;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304997 //preauth + reserved
Kiet Lam64c1b492013-07-12 13:56:44 +05304998 vos_mem_copy(pIeBuf,
4999 pIesLocal->WAPI.multicast_cipher_suite + 4,
5000 2);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005001 pIeBuf += 2;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305002 //bkid_count
Kiet Lam64c1b492013-07-12 13:56:44 +05305003 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.bkid_count, 2);
5004
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005005 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005006 if( pIesLocal->WAPI.bkid_count )
5007 {
5008 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305009 vos_mem_copy(pIeBuf, pIesLocal->WAPI.bkid,
5010 pIesLocal->WAPI.bkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005011 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
5012 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305013 pSession->nWapiRspIeLength = nIeLen + 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005014 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005015 }
5016 }
5017#endif /* FEATURE_WLAN_WAPI */
5018 if( !pIes )
5019 {
5020 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05305021 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07005022 }
5023 }
5024 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005025 return (status);
5026}
5027
Jeff Johnson295189b2012-06-20 16:38:30 -07005028static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
5029{
5030 v_U8_t bACWeights[WLANTL_MAX_AC];
5031 v_U8_t paramBk, paramBe, paramVi, paramVo;
5032 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005033 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
5034 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
5035 //of the higher AC one, make the higher AC has the same weight as the lower AC.
5036 //This doesn't address the case where the lower AC needs a real higher weight
5037 if( pIEs->WMMParams.present )
5038 {
5039 //no change to the lowest ones
5040 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
5041 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
5042 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
5043 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
5044 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
5045 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
5046 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
5047 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
5048 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
5049 {
5050 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
5051 fWeightChange = VOS_TRUE;
5052 }
5053 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
5054 {
5055 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
5056 fWeightChange = VOS_TRUE;
5057 }
5058 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
5059 {
5060 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
5061 fWeightChange = VOS_TRUE;
5062 }
5063 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
5064 {
5065 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
5066 fWeightChange = VOS_TRUE;
5067 }
5068 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
5069 {
5070 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
5071 fWeightChange = VOS_TRUE;
5072 }
5073 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
5074 {
5075 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
5076 fWeightChange = VOS_TRUE;
5077 }
5078 if(fWeightChange)
5079 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005080 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)"), bACWeights[0], bACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07005081 bACWeights[2], bACWeights[3]);
5082 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
5083 }
5084 }
5085}
Jeff Johnson295189b2012-06-20 16:38:30 -07005086#ifdef WLAN_FEATURE_VOWIFI_11R
5087//Returns whether the current association is a 11r assoc or not
5088tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
5089{
5090#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5091 return csrNeighborRoamIs11rAssoc(pMac);
5092#else
5093 return eANI_BOOLEAN_FALSE;
5094#endif
5095}
5096#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005097#ifdef FEATURE_WLAN_ESE
5098//Returns whether the current association is a ESE assoc or not
5099tANI_BOOLEAN csrRoamIsESEAssoc(tpAniSirGlobal pMac)
Jeff Johnson295189b2012-06-20 16:38:30 -07005100{
5101#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005102 return csrNeighborRoamIsESEAssoc(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07005103#else
5104 return eANI_BOOLEAN_FALSE;
5105#endif
5106}
5107#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005108#ifdef FEATURE_WLAN_LFR
5109//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305110tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005111{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305112 tCsrRoamSession *pSession = NULL;
5113
5114 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
5115 {
5116 pSession = CSR_GET_SESSION( pMac, sessionId );
5117 if (NULL != pSession->pCurRoamProfile)
5118 {
5119 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
5120 {
5121 return eANI_BOOLEAN_FALSE;
5122 }
5123 }
5124 }
5125
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005126#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5127 if (eANI_BOOLEAN_TRUE == CSR_IS_FASTROAM_IN_CONCURRENCY_INI_FEATURE_ENABLED(pMac))
5128 {
5129 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled);
5130 }
5131 else
5132#endif
5133 {
5134 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07005135 (!csrIsConcurrentSessionRunning(pMac)));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005136 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005137}
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005138
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005139#ifdef FEATURE_WLAN_ESE
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005140/* ---------------------------------------------------------------------------
5141
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005142 \fn csrNeighborRoamIsESEAssoc
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005143
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005144 \brief This function returns whether the current association is a ESE assoc or not
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005145
5146 \param pMac - The handle returned by macOpen.
5147
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005148 \return eANI_BOOLEAN_TRUE if current assoc is ESE, eANI_BOOLEAN_FALSE otherwise
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005149
5150---------------------------------------------------------------------------*/
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005151tANI_BOOLEAN csrNeighborRoamIsESEAssoc(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005152{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005153 return pMac->roam.neighborRoamInfo.isESEAssoc;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005154}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005155#endif /* FEATURE_WLAN_ESE */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005156
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005157#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5158//Returns whether "FW based BG scan" is currently enabled...or not
5159tANI_BOOLEAN csrRoamIsRoamOffloadScanEnabled(tpAniSirGlobal pMac)
5160{
5161 return (pMac->roam.configParam.isRoamOffloadScanEnabled);
5162}
5163#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005164#endif
5165
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005166#if defined(FEATURE_WLAN_ESE)
5167tANI_BOOLEAN csrRoamIsEseIniFeatureEnabled(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005168{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005169 return pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005170}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005171#endif /*FEATURE_WLAN_ESE*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005172
Jeff Johnson295189b2012-06-20 16:38:30 -07005173//Return true means the command can be release, else not
5174static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
5175 eCsrRoamCompleteResult Result, void *Context )
5176{
5177 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
5178 tSirBssDescription *pSirBssDesc = NULL;
5179 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
5180 tCsrScanResult *pScanResult = NULL;
5181 tCsrRoamInfo roamInfo;
5182 sme_QosAssocInfo assocInfo;
5183 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
5184 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
5185 tDot11fBeaconIEs *pIes = NULL;
5186 tANI_U32 sessionId = pCommand->sessionId;
5187 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5188 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
5189 eRoamCmdStatus roamStatus;
5190 eCsrRoamResult roamResult;
5191 eHalStatus status;
5192 tANI_U32 key_timeout_interval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005193 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005194
Jeff Johnson32d95a32012-09-10 13:15:23 -07005195 if(!pSession)
5196 {
5197 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5198 return eANI_BOOLEAN_FALSE;
5199 }
5200
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005201 smsLog( pMac, LOG1, FL("Processing ROAM results..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07005202 switch( Result )
5203 {
5204 case eCsrJoinSuccess:
5205 // reset the IDLE timer
5206 // !!
5207 // !! fall through to the next CASE statement here is intentional !!
5208 // !!
5209 case eCsrReassocSuccess:
5210 if(eCsrReassocSuccess == Result)
5211 {
5212 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
5213 }
5214 else
5215 {
5216 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
5217 }
5218 // Success Join Response from LIM. Tell NDIS we are connected and save the
5219 // Connected state...
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005220 smsLog(pMac, LOGW, FL("receives association indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305221 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005222 //always free the memory here
5223 if(pSession->pWpaRsnRspIE)
5224 {
5225 pSession->nWpaRsnRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305226 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005227 pSession->pWpaRsnRspIE = NULL;
5228 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005229#ifdef FEATURE_WLAN_WAPI
5230 if(pSession->pWapiRspIE)
5231 {
5232 pSession->nWapiRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305233 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005234 pSession->pWapiRspIE = NULL;
5235 }
5236#endif /* FEATURE_WLAN_WAPI */
5237#ifdef FEATURE_WLAN_BTAMP_UT_RF
5238 //Reset counter so no join retry is needed.
5239 pSession->maxRetryCount = 0;
5240 csrRoamStopJoinRetryTimer(pMac, sessionId);
5241#endif
5242 /* This creates problem since we have not saved the connected profile.
5243 So moving this after saving the profile
5244 */
5245 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
5246 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
5247 {
5248 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
5249 }
5250 else
5251 {
5252 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
5253 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005254 //Use the last connected bssdesc for reassoc-ing to the same AP.
5255 //NOTE: What to do when reassoc to a different AP???
5256 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5257 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5258 {
5259 pSirBssDesc = pSession->pConnectBssDesc;
5260 if(pSirBssDesc)
5261 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305262 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5263 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005264 }
5265 }
5266 else
5267 {
5268
5269 if(pCommand->u.roamCmd.pRoamBssEntry)
5270 {
5271 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
5272 if(pScanResult != NULL)
5273 {
5274 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5275 //this can be NULL
5276 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
Kiet Lam64c1b492013-07-12 13:56:44 +05305277 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5278 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005279 }
5280 }
5281 }
5282 if( pSirBssDesc )
5283 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005284 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07005285 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5286 //Save WPA/RSN IE
5287 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005288#ifdef FEATURE_WLAN_ESE
5289 roamInfo.isESEAssoc = pSession->connectedProfile.isESEAssoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005290#endif
5291
5292 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
5293 // substate change.
5294 // Moving even save profile above so that below mentioned conditon is also met.
5295 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
5296 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005297 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
5298 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
5299 // will be dropped for the security context may not be set properly.
5300 //
5301 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
5302 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
5303 //
5304 // this reordering was done on titan_prod_usb branch and is being replicated here.
5305 //
5306
5307 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
5308 !pProfile->bWPSAssociation)
5309 {
5310 // Issue the set Context request to LIM to establish the Unicast STA context
5311 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
5312 pProfile->negotiatedUCEncryptionType,
5313 pSirBssDesc, &(pSirBssDesc->bssId),
5314 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
5315 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005316 smsLog( pMac, LOGE, FL(" Set context for unicast fail") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005317 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5318 }
5319 // Issue the set Context request to LIM to establish the Broadcast STA context
5320 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
5321 pSirBssDesc, &BroadcastMac,
5322 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5323 }
5324 else
5325 {
5326 //Need to wait for supplicant authtication
5327 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005328 //Set the subestate to WaitForKey in case authentiation is needed
5329 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
5330
Jeff Johnson295189b2012-06-20 16:38:30 -07005331 if(pProfile->bWPSAssociation)
5332 {
5333 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
5334 }
5335 else
5336 {
5337 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
5338 }
5339
5340 //Save sessionId in case of timeout
5341 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
5342 //This time should be long enough for the rest of the process plus setting key
5343 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
5344 {
5345 //Reset our state so nothting is blocked.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005346 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005347 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
5348 }
5349 }
5350
5351 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
5352 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005353 if(Context)
5354 {
5355 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
5356 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07005357 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5358 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
5359#ifdef WLAN_FEATURE_VOWIFI_11R
5360 len += pJoinRsp->parsedRicRspLen;
5361#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005362#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005363 len += pJoinRsp->tspecIeLen;
5364#endif
5365 if(len)
5366 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305367 pSession->connectedInfo.pbFrames = vos_mem_malloc(len);
5368 if ( pSession->connectedInfo.pbFrames != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07005369 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305370 vos_mem_copy(pSession->connectedInfo.pbFrames,
5371 pJoinRsp->frames, len);
5372 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5373 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5374 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
Jeff Johnson295189b2012-06-20 16:38:30 -07005375#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05305376 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005377#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005378#ifdef FEATURE_WLAN_ESE
Kiet Lam64c1b492013-07-12 13:56:44 +05305379 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005380#endif
Kiet Lam64c1b492013-07-12 13:56:44 +05305381 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5382 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5383 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
5384 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
Jeff Johnson295189b2012-06-20 16:38:30 -07005385 }
5386 }
5387 if(pCommand->u.roamCmd.fReassoc)
5388 {
5389 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5390 }
5391 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5392 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5393 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
5394 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
5395 }
5396 else
5397 {
5398 if(pCommand->u.roamCmd.fReassoc)
5399 {
5400 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5401 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5402 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5403 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5404 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5405 }
5406 }
5407#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5408 // Indicate SME-QOS with reassoc success event, only after
5409 // copying the frames
5410 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
5411#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005412 roamInfo.pBssDesc = pSirBssDesc;
5413 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5414 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5415#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5416 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
5417#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
5418 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005419 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
5420 //It may be better to let QoS do this????
5421 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
5422 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005423 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now",
Jeff Johnson295189b2012-06-20 16:38:30 -07005424 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
5425 pmcStartUapsd( pMac, NULL, NULL );
5426 }
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05305427 pSession->connectedProfile.dot11Mode = pSession->bssParams.uCfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005428 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5429 if( pSession->bRefAssocStartCnt > 0 )
5430 {
5431 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005432 //Remove this code once SLM_Sessionization is supported
5433 //BMPS_WORKAROUND_NOT_NEEDED
5434 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005435 {
5436 pMac->roam.configParam.doBMPSWorkaround = 1;
5437 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005438 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5439 }
5440
5441 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005442 // reset the PMKID candidate list
5443 csrResetPMKIDCandidateList( pMac, sessionId );
5444 //Update TL's AC weight base on the current EDCA parameters
5445 //These parameters may change in the course of the connection, that sictuation
5446 //is not taken care here. This change is mainly to address a WIFI WMM test where
5447 //BE has a equal or higher TX priority than VI.
5448 //We only do this for infra link
5449 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
5450 {
5451 csrCheckAndUpdateACWeight(pMac, pIes);
5452 }
5453#ifdef FEATURE_WLAN_WAPI
5454 // reset the BKID candidate list
5455 csrResetBKIDCandidateList( pMac, sessionId );
5456#endif /* FEATURE_WLAN_WAPI */
5457 }
5458 else
5459 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005460 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc");
Jeff Johnson295189b2012-06-20 16:38:30 -07005461 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005462 csrScanCancelIdleScan(pMac);
5463 //Not to signal link up because keys are yet to be set.
5464 //The linkup function will overwrite the sub-state that we need to keep at this point.
5465 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
5466 {
5467 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
5468 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005469 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
5470 //enough to let security and DHCP handshake succeed before entry into BMPS
5471 if (pmcShouldBmpsTimerRun(pMac))
5472 {
5473 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
5474 != eHAL_STATUS_SUCCESS)
5475 {
5476 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
5477 }
5478 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
5479 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005480 break;
5481
Jeff Johnson295189b2012-06-20 16:38:30 -07005482 case eCsrStartBssSuccess:
5483 // on the StartBss Response, LIM is returning the Bss Description that we
5484 // are beaconing. Add this Bss Description to our scan results and
5485 // chain the Profile to this Bss Description. On a Start BSS, there was no
5486 // detected Bss description (no partner) so we issued the Start Bss to
5487 // start the Ibss without any Bss description. Lim was kind enough to return
5488 // the Bss Description that we start beaconing for the newly started Ibss.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005489 smsLog(pMac, LOG2, FL("receives start BSS ok indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005490 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005491 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
Kiet Lam64c1b492013-07-12 13:56:44 +05305492 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005493 if( CSR_IS_IBSS( pProfile ) )
5494 {
5495 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
5496 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005497 else if (CSR_IS_INFRA_AP(pProfile))
5498 {
5499 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
5500 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005501 else
5502 {
5503 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
5504 }
5505 if( !CSR_IS_WDS_STA( pProfile ) )
5506 {
5507 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005508 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
Jeff Johnson295189b2012-06-20 16:38:30 -07005509 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
5510 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05305511 smsLog(pMac, LOGW, FL("cannot parse IBSS IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005512 roamInfo.pBssDesc = pSirBssDesc;
5513 //We need to associate_complete it first, becasue Associate_start already indicated.
5514 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5515 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
5516 break;
5517 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005518 if (!CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07005519 {
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07005520 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005521 }
5522 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
5523 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5524 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5525 if(pSirBssDesc)
5526 {
5527 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
Kiet Lam64c1b492013-07-12 13:56:44 +05305528 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5529 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005530 }
5531 //We are doen with the IEs so free it
Kiet Lam64c1b492013-07-12 13:56:44 +05305532 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005533#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5534 {
5535 vos_log_ibss_pkt_type *pIbssLog;
5536 tANI_U32 bi;
5537
5538 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5539 if(pIbssLog)
5540 {
5541 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5542 {
5543 //We start the IBSS (didn't find any matched IBSS out there)
5544 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
5545 }
5546 else
5547 {
5548 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
5549 }
5550 if(pSirBssDesc)
5551 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305552 vos_mem_copy(pIbssLog->bssid, pSirBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07005553 pIbssLog->operatingChannel = pSirBssDesc->channelId;
5554 }
5555 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
5556 {
5557 //***U8 is not enough for beacon interval
5558 pIbssLog->beaconInterval = (v_U8_t)bi;
5559 }
5560 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5561 }
5562 }
5563#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5564 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
5565 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07005566 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
5567 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005568 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
5569 csrRoamIssueSetContextReq( pMac, sessionId,
5570 pProfile->negotiatedMCEncryptionType,
5571 pSirBssDesc, &BroadcastMac,
5572 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5573 }
5574 }
5575 else
5576 {
5577 //Keep the state to eCSR_ROAMING_STATE_JOINING
5578 //Need to send join_req.
5579 if(pCommand->u.roamCmd.pRoamBssEntry)
5580 {
5581 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
5582 {
5583 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5584 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
5585 // Set the roaming substate to 'join attempt'...
5586 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08005587 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07005588 }
5589 }
5590 else
5591 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005592 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc" );
Jeff Johnson295189b2012-06-20 16:38:30 -07005593 VOS_ASSERT( 0 );
5594 }
5595 }
5596 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5597 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5598 //trigger the connection start indication in Vista
5599 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
5600 {
5601 roamStatus = eCSR_ROAM_IBSS_IND;
5602 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5603 if( CSR_IS_WDS( pProfile ) )
5604 {
5605 roamStatus = eCSR_ROAM_WDS_IND;
5606 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5607 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005608 if( CSR_IS_INFRA_AP( pProfile ) )
5609 {
5610 roamStatus = eCSR_ROAM_INFRA_IND;
5611 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
5612 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005613
5614 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5615 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5616 //trigger the connection start indication in Vista
Kiet Lam64c1b492013-07-12 13:56:44 +05305617 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005618 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5619 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
krunal soni3fc26642013-10-08 22:41:42 -07005620 //We start the IBSS (didn't find any matched IBSS out there)
5621 roamInfo.pBssDesc = pSirBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005622 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
Kiet Lam64c1b492013-07-12 13:56:44 +05305623 vos_mem_copy(roamInfo.bssid, pSirBssDesc->bssId,
5624 sizeof(tCsrBssid));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005625 //Remove this code once SLM_Sessionization is supported
5626 //BMPS_WORKAROUND_NOT_NEEDED
5627 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07005628 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005629 {
5630 pMac->roam.configParam.doBMPSWorkaround = 1;
5631 }
Mohit Khanna349bc392012-09-11 17:24:52 -07005632
Jeff Johnson295189b2012-06-20 16:38:30 -07005633 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5634 }
5635
5636 csrScanCancelIdleScan(pMac);
Ravi Joshi414b14c2013-10-04 16:33:26 -07005637
5638 if( CSR_IS_WDS_STA( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005639 {
5640 //need to send stop BSS because we fail to send join_req
5641 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
5642 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5643 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
5644 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005645 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005646 case eCsrStartBssFailure:
5647#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5648 {
5649 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07005650 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5651 if(pIbssLog)
5652 {
5653 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
5654 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5655 }
5656 }
5657#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07005658 roamStatus = eCSR_ROAM_IBSS_IND;
5659 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5660 if( CSR_IS_WDS( pProfile ) )
5661 {
5662 roamStatus = eCSR_ROAM_WDS_IND;
5663 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5664 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005665 if( CSR_IS_INFRA_AP( pProfile ) )
5666 {
5667 roamStatus = eCSR_ROAM_INFRA_IND;
5668 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
5669 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005670 if(Context)
5671 {
5672 pSirBssDesc = (tSirBssDescription *)Context;
5673 }
5674 else
5675 {
5676 pSirBssDesc = NULL;
5677 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305678 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005679 roamInfo.pBssDesc = pSirBssDesc;
5680 //We need to associate_complete it first, becasue Associate_start already indicated.
5681 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5682 csrSetDefaultDot11Mode( pMac );
5683 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005684 case eCsrSilentlyStopRoaming:
5685 // We are here because we try to start the same IBSS
5686 //No message to PE
5687 // return the roaming state to Joined.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005688 smsLog(pMac, LOGW, FL("receives silently roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005689 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
5690 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05305691 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005692 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5693 if( roamInfo.pBssDesc )
5694 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305695 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5696 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005697 }
5698 //Since there is no change in the current state, simply pass back no result otherwise
5699 //HDD may be mistakenly mark to disconnected state.
5700 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5701 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005702 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005703 case eCsrSilentlyStopRoamingSaveState:
5704 //We are here because we try to connect to the same AP
5705 //No message to PE
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005706 smsLog(pMac, LOGW, FL("receives silently stop roaming indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305707 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005708
5709 //to aviod resetting the substate to NONE
5710 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
5711 //No need to change substate to wai_for_key because there is no state change
5712 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5713 if( roamInfo.pBssDesc )
5714 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305715 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5716 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005717 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005718 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5719 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5720 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5721 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5722 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5723 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5724 roamInfo.staId = pSession->connectedInfo.staId;
5725 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005726 VOS_ASSERT( roamInfo.staId != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005727 pSession->bRefAssocStartCnt--;
5728 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5729 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5730 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
5731 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005732 case eCsrReassocFailure:
5733#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5734 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
5735#endif
5736 case eCsrJoinWdsFailure:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005737 smsLog(pMac, LOGW, FL("failed to join WDS"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005738 csrFreeConnectBssDesc(pMac, sessionId);
5739 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5740 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
Kiet Lam64c1b492013-07-12 13:56:44 +05305741 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005742 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5743 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5744 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5745 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5746 eCSR_ROAM_WDS_IND,
5747 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
5748 //Need to issue stop_bss
5749 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005750 case eCsrJoinFailure:
5751 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07005752 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07005753 default:
5754 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005755 smsLog(pMac, LOGW, FL("receives no association indication"));
5756 smsLog(pMac, LOG1, FL("Assoc ref count %d"),
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07005757 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07005758 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
5759 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
5760 {
5761 //do not free for the other profiles as we need to send down stop BSS later
5762 csrFreeConnectBssDesc(pMac, sessionId);
5763 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5764 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5765 csrSetDefaultDot11Mode( pMac );
5766 }
5767
5768 switch( pCommand->u.roamCmd.roamReason )
5769 {
5770 // If this transition is because of an 802.11 OID, then we transition
5771 // back to INIT state so we sit waiting for more OIDs to be issued and
5772 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07005773 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07005774 case eCsrSmeIssuedAssocToSimilarAP:
5775 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08005776 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07005777 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05305778 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005779 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5780 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5781 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Kiet Lam64c1b492013-07-12 13:56:44 +05305782 vos_mem_copy(&roamInfo.bssid,
5783 &pSession->joinFailStatusCode.bssId,
5784 sizeof(tCsrBssid));
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005785
Jeff Johnson295189b2012-06-20 16:38:30 -07005786 /* Defeaturize this later if needed */
5787#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5788 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
5789 if (csrRoamIsHandoffInProgress(pMac))
5790 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005791 /* Should indicate neighbor roam algorithm about the connect failure here */
5792 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
5793 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005794#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005795 if(pSession->bRefAssocStartCnt > 0)
5796 {
5797 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07005798 if(eCsrJoinFailureDueToConcurrency == Result)
5799 {
5800 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5801 eCSR_ROAM_ASSOCIATION_COMPLETION,
5802 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
5803 }
5804 else
5805 {
5806 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005807 eCSR_ROAM_ASSOCIATION_COMPLETION,
5808 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07005809 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005810 }
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005811 else
5812 {
5813 /* bRefAssocStartCnt is not incremented when
5814 * eRoamState == eCsrStopRoamingDueToConcurrency
5815 * in csrRoamJoinNextBss API. so handle this in
5816 * else case by sending assoc failure
5817 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005818 csrRoamCallCallback(pMac, sessionId, &roamInfo,
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005819 pCommand->u.scanCmd.roamId,
5820 eCSR_ROAM_ASSOCIATION_FAILURE,
5821 eCSR_ROAM_RESULT_FAILURE);
5822 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005823 smsLog(pMac, LOG1, FL(" roam(reason %d) failed"), pCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07005824#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Mukul Sharma5960ac82014-01-09 20:31:35 +05305825 sme_QosUpdateHandOff((tANI_U8)sessionId, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005826 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5827#endif
5828 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5829 csrScanStartIdleScan(pMac);
5830#ifdef FEATURE_WLAN_BTAMP_UT_RF
5831 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
5832 //BT activity and not able to recevie WLAN traffic. Retry the join
5833 if( CSR_IS_WDS_STA(pProfile) )
5834 {
5835 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
5836 }
5837#endif
5838 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005839 case eCsrHddIssuedReassocToSameAP:
5840 case eCsrSmeIssuedReassocToSameAP:
5841 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5842
5843 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5844#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5845 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5846#endif
5847 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5848 csrScanStartIdleScan(pMac);
5849 break;
5850 case eCsrForcedDisassoc:
5851 case eCsrForcedDeauth:
5852 case eCsrSmeIssuedIbssJoinFailure:
5853 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5854
5855 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
5856 {
5857 // Notify HDD that IBSS join failed
5858 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
5859 }
5860 else
5861 {
5862 csrRoamCallCallback(pMac, sessionId, NULL,
5863 pCommand->u.roamCmd.roamId,
5864 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5865 }
5866#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5867 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5868#endif
5869 csrRoamLinkDown(pMac, sessionId);
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08005870 /*
5871 *DelSta not done FW still in conneced state so dont
5872 *issue IMPS req
5873 */
5874 if (pMac->roam.deauthRspStatus == eSIR_SME_DEAUTH_STATUS)
5875 {
5876 smsLog(pMac, LOGW, FL("FW still in connected state "));
5877 break;
5878 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005879 csrScanStartIdleScan(pMac);
5880 break;
5881 case eCsrForcedIbssLeave:
5882 csrRoamCallCallback(pMac, sessionId, NULL,
5883 pCommand->u.roamCmd.roamId,
5884 eCSR_ROAM_IBSS_LEAVE,
5885 eCSR_ROAM_RESULT_IBSS_STOP);
5886 break;
5887 case eCsrForcedDisassocMICFailure:
5888 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5889
5890 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
5891#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5892 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
5893#endif
5894 csrScanStartIdleScan(pMac);
5895 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005896 case eCsrStopBss:
5897 csrRoamCallCallback(pMac, sessionId, NULL,
5898 pCommand->u.roamCmd.roamId,
5899 eCSR_ROAM_INFRA_IND,
5900 eCSR_ROAM_RESULT_INFRA_STOPPED);
5901 break;
5902 case eCsrForcedDisassocSta:
5903 case eCsrForcedDeauthSta:
5904 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
5905 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
5906 {
5907 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005908
5909 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
5910 {
5911 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05305912 vos_mem_copy(roamInfo.peerMac,
5913 pCommand->u.roamCmd.peerMac,
5914 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07005915 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
5916 roamInfo.statusCode = eSIR_SME_SUCCESS;
5917 status = csrRoamCallCallback(pMac, sessionId,
5918 &roamInfo, pCommand->u.roamCmd.roamId,
5919 eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
5920 }
5921 }
5922 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005923 case eCsrLostLink1:
5924 // if lost link roam1 failed, then issue lost link Scan2 ...
5925 csrScanRequestLostLink2(pMac, sessionId);
5926 break;
5927 case eCsrLostLink2:
5928 // if lost link roam2 failed, then issue lost link scan3 ...
5929 csrScanRequestLostLink3(pMac, sessionId);
5930 break;
5931 case eCsrLostLink3:
5932 default:
5933 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5934
5935 //We are done with one round of lostlink roaming here
5936 csrScanHandleFailedLostlink3(pMac, sessionId);
5937 break;
5938 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005939 break;
5940 }
5941 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005942 return ( fReleaseCommand );
5943}
5944
Jeff Johnson295189b2012-06-20 16:38:30 -07005945eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
5946{
5947 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005948 return (status);
5949}
5950
Jeff Johnson295189b2012-06-20 16:38:30 -07005951eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
5952{
5953 eHalStatus status = eHAL_STATUS_SUCCESS;
5954 tANI_U32 size = 0;
5955
5956 do
5957 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305958 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005959 if(pSrcProfile->BSSIDs.numOfBSSIDs)
5960 {
5961 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05305962 pDstProfile->BSSIDs.bssid = vos_mem_malloc(size);
5963 if ( NULL == pDstProfile->BSSIDs.bssid )
5964 status = eHAL_STATUS_FAILURE;
5965 else
5966 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005967 if(!HAL_STATUS_SUCCESS(status))
5968 {
5969 break;
5970 }
5971 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05305972 vos_mem_copy(pDstProfile->BSSIDs.bssid,
5973 pSrcProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07005974 }
5975 if(pSrcProfile->SSIDs.numOfSSIDs)
5976 {
5977 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05305978 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(size);
5979 if ( NULL == pDstProfile->SSIDs.SSIDList )
5980 status = eHAL_STATUS_FAILURE;
5981 else
5982 status = eHAL_STATUS_SUCCESS;
5983 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07005984 {
5985 break;
5986 }
5987 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05305988 vos_mem_copy(pDstProfile->SSIDs.SSIDList,
5989 pSrcProfile->SSIDs.SSIDList, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07005990 }
5991 if(pSrcProfile->nWPAReqIELength)
5992 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305993 pDstProfile->pWPAReqIE = vos_mem_malloc(pSrcProfile->nWPAReqIELength);
5994 if ( NULL == pDstProfile->pWPAReqIE )
5995 status = eHAL_STATUS_FAILURE;
5996 else
5997 status = eHAL_STATUS_SUCCESS;
5998
5999 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006000 {
6001 break;
6002 }
6003 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306004 vos_mem_copy(pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE,
6005 pSrcProfile->nWPAReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006006 }
6007 if(pSrcProfile->nRSNReqIELength)
6008 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306009 pDstProfile->pRSNReqIE = vos_mem_malloc(pSrcProfile->nRSNReqIELength);
6010 if ( NULL == pDstProfile->pRSNReqIE )
6011 status = eHAL_STATUS_FAILURE;
6012 else
6013 status = eHAL_STATUS_SUCCESS;
6014
6015 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006016 {
6017 break;
6018 }
6019 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306020 vos_mem_copy(pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE,
6021 pSrcProfile->nRSNReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006022 }
6023#ifdef FEATURE_WLAN_WAPI
6024 if(pSrcProfile->nWAPIReqIELength)
6025 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306026 pDstProfile->pWAPIReqIE = vos_mem_malloc(pSrcProfile->nWAPIReqIELength);
6027 if ( NULL == pDstProfile->pWAPIReqIE )
6028 status = eHAL_STATUS_FAILURE;
6029 else
6030 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006031 if(!HAL_STATUS_SUCCESS(status))
6032 {
6033 break;
6034 }
6035 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306036 vos_mem_copy(pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE,
6037 pSrcProfile->nWAPIReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006038 }
6039#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07006040 if(pSrcProfile->nAddIEScanLength)
6041 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05306042 memset(pDstProfile->addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH);
6043 if ( SIR_MAC_MAX_IE_LENGTH >= pSrcProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -07006044 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05306045 vos_mem_copy(pDstProfile->addIEScan, pSrcProfile->addIEScan,
Kiet Lam64c1b492013-07-12 13:56:44 +05306046 pSrcProfile->nAddIEScanLength);
Agarwal Ashish4f616132013-12-30 23:32:50 +05306047 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
6048 }
6049 else
6050 {
6051 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
6052 FL(" AddIEScanLength is not valid %u"),
6053 pSrcProfile->nAddIEScanLength);
6054 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006055 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006056 if(pSrcProfile->nAddIEAssocLength)
6057 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306058 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6059 if ( NULL == pDstProfile->pAddIEAssoc )
6060 status = eHAL_STATUS_FAILURE;
6061 else
6062 status = eHAL_STATUS_SUCCESS;
6063
Jeff Johnson295189b2012-06-20 16:38:30 -07006064 if(!HAL_STATUS_SUCCESS(status))
6065 {
6066 break;
6067 }
6068 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306069 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6070 pSrcProfile->nAddIEAssocLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006071 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006072 if(pSrcProfile->ChannelInfo.ChannelList)
6073 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306074 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(
6075 pSrcProfile->ChannelInfo.numOfChannels);
6076 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6077 status = eHAL_STATUS_FAILURE;
6078 else
6079 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006080 if(!HAL_STATUS_SUCCESS(status))
6081 {
6082 break;
6083 }
6084 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
Kiet Lam64c1b492013-07-12 13:56:44 +05306085 vos_mem_copy(pDstProfile->ChannelInfo.ChannelList,
6086 pSrcProfile->ChannelInfo.ChannelList,
6087 pSrcProfile->ChannelInfo.numOfChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07006088 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006089 pDstProfile->AuthType = pSrcProfile->AuthType;
6090 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
6091 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
6092 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
6093 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
6094 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
Chet Lanctot186b5732013-03-18 10:26:30 -07006095#ifdef WLAN_FEATURE_11W
6096 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
6097 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
6098 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
6099#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006100 pDstProfile->BSSType = pSrcProfile->BSSType;
6101 pDstProfile->phyMode = pSrcProfile->phyMode;
6102 pDstProfile->csrPersona = pSrcProfile->csrPersona;
6103
6104#ifdef FEATURE_WLAN_WAPI
6105 if(csrIsProfileWapi(pSrcProfile))
6106 {
6107 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
6108 {
6109 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
6110 }
6111 }
6112#endif /* FEATURE_WLAN_WAPI */
6113 pDstProfile->CBMode = pSrcProfile->CBMode;
6114 /*Save the WPS info*/
6115 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
6116 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006117 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07006118 pDstProfile->privacy = pSrcProfile->privacy;
6119 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
6120 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
6121 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
6122 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
6123 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
6124 pDstProfile->protEnabled = pSrcProfile->protEnabled;
6125 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
6126 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
6127 pDstProfile->wps_state = pSrcProfile->wps_state;
6128 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
Kiet Lam64c1b492013-07-12 13:56:44 +05306129 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6130 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006131#ifdef WLAN_FEATURE_VOWIFI_11R
6132 if (pSrcProfile->MDID.mdiePresent)
6133 {
6134 pDstProfile->MDID.mdiePresent = 1;
6135 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6136 }
6137#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006138 }while(0);
6139
6140 if(!HAL_STATUS_SUCCESS(status))
6141 {
6142 csrReleaseProfile(pMac, pDstProfile);
6143 pDstProfile = NULL;
6144 }
6145
6146 return (status);
6147}
Jeff Johnson295189b2012-06-20 16:38:30 -07006148eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
6149{
6150 eHalStatus status = eHAL_STATUS_SUCCESS;
6151 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
6152 do
6153 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306154 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006155 if(pSrcProfile->bssid)
6156 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306157 pDstProfile->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
6158 if ( NULL == pDstProfile->BSSIDs.bssid )
6159 status = eHAL_STATUS_FAILURE;
6160 else
6161 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006162 if(!HAL_STATUS_SUCCESS(status))
6163 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306164 smsLog( pMac, LOGE,
6165 FL("failed to allocate memory for BSSID"
6166 "%02x:%02x:%02x:%02x:%02x:%02x"),
6167 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6168 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006169 break;
6170 }
6171 pDstProfile->BSSIDs.numOfBSSIDs = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05306172 vos_mem_copy(pDstProfile->BSSIDs.bssid, pSrcProfile->bssid,
6173 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006174 }
6175 if(pSrcProfile->SSID.ssId)
6176 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306177 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
6178 if ( NULL == pDstProfile->SSIDs.SSIDList )
6179 status = eHAL_STATUS_FAILURE;
6180 else
6181 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006182 if(!HAL_STATUS_SUCCESS(status))
6183 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306184 smsLog( pMac, LOGE,
6185 FL("failed to allocate memory for SSIDList"
6186 "%02x:%02x:%02x:%02x:%02x:%02x"),
6187 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6188 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006189 break;
6190 }
6191 pDstProfile->SSIDs.numOfSSIDs = 1;
6192 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
6193 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
Kiet Lam64c1b492013-07-12 13:56:44 +05306194 vos_mem_copy(&pDstProfile->SSIDs.SSIDList[0].SSID,
6195 &pSrcProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006196 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006197 if(pSrcProfile->nAddIEAssocLength)
6198 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306199 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6200 if ( NULL == pDstProfile->pAddIEAssoc)
6201 status = eHAL_STATUS_FAILURE;
6202 else
6203 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006204 if(!HAL_STATUS_SUCCESS(status))
6205 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006206 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs ") );
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006207 break;
6208 }
6209 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306210 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6211 pSrcProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006212 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306213 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(1);
6214 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6215 status = eHAL_STATUS_FAILURE;
6216 else
6217 status = eHAL_STATUS_SUCCESS;
6218
Jeff Johnson295189b2012-06-20 16:38:30 -07006219 if(!HAL_STATUS_SUCCESS(status))
6220 {
6221 break;
6222 }
6223 pDstProfile->ChannelInfo.numOfChannels = 1;
6224 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006225 pDstProfile->AuthType.numEntries = 1;
6226 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
6227 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
6228 pDstProfile->EncryptionType.numEntries = 1;
6229 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
6230 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
6231 pDstProfile->mcEncryptionType.numEntries = 1;
6232 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
6233 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
6234 pDstProfile->BSSType = pSrcProfile->BSSType;
6235 pDstProfile->CBMode = pSrcProfile->CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +05306236 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6237 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006238#ifdef WLAN_FEATURE_VOWIFI_11R
6239 if (pSrcProfile->MDID.mdiePresent)
6240 {
6241 pDstProfile->MDID.mdiePresent = 1;
6242 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6243 }
6244#endif
6245
6246 }while(0);
6247
6248 if(!HAL_STATUS_SUCCESS(status))
6249 {
6250 csrReleaseProfile(pMac, pDstProfile);
6251 pDstProfile = NULL;
6252 }
6253
6254 return (status);
6255}
6256
Jeff Johnson295189b2012-06-20 16:38:30 -07006257eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6258 tScanResultHandle hBSSList,
6259 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
6260 tANI_BOOLEAN fClearScan)
6261{
6262 eHalStatus status = eHAL_STATUS_SUCCESS;
6263 tSmeCmd *pCommand;
6264
6265 pCommand = csrGetCommandBuffer(pMac);
6266 if(NULL == pCommand)
6267 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006268 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006269 status = eHAL_STATUS_RESOURCES;
6270 }
6271 else
6272 {
6273 if( fClearScan )
6274 {
6275 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306276 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006277 }
6278 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6279 if(NULL == pProfile)
6280 {
6281 //We can roam now
6282 //Since pProfile is NULL, we need to build our own profile, set everything to default
6283 //We can only support open and no encryption
6284 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
6285 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
6286 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
6287 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6288 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
6289 }
6290 else
6291 {
6292 //make a copy of the profile
6293 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6294 if(HAL_STATUS_SUCCESS(status))
6295 {
6296 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6297 }
6298 }
6299 pCommand->command = eSmeCommandRoam;
6300 pCommand->sessionId = (tANI_U8)sessionId;
6301 pCommand->u.roamCmd.hBSSList = hBSSList;
6302 pCommand->u.roamCmd.roamId = roamId;
6303 pCommand->u.roamCmd.roamReason = reason;
6304 //We need to free the BssList when the command is done
6305 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
6306 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006307 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6308 FL("CSR PERSONA=%d"),
6309 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07006310 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6311 if( !HAL_STATUS_SUCCESS( status ) )
6312 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006313 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006314 csrReleaseCommandRoam( pMac, pCommand );
6315 }
6316 }
6317
6318 return (status);
6319}
Jeff Johnson295189b2012-06-20 16:38:30 -07006320eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6321 tCsrRoamModifyProfileFields *pMmodProfileFields,
6322 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
6323{
6324 eHalStatus status = eHAL_STATUS_SUCCESS;
6325 tSmeCmd *pCommand;
6326
6327 pCommand = csrGetCommandBuffer(pMac);
6328 if(NULL == pCommand)
6329 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006330 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006331 status = eHAL_STATUS_RESOURCES;
6332 }
6333 else
6334 {
6335 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306336 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006337 if(pProfile)
6338 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006339 //This is likely trying to reassoc to different profile
6340 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6341 //make a copy of the profile
6342 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6343 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006344 }
6345 else
6346 {
6347 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
6348 //how to update WPA/WPA2 info in roamProfile??
6349 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006350 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006351 if(HAL_STATUS_SUCCESS(status))
6352 {
6353 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6354 }
6355 pCommand->command = eSmeCommandRoam;
6356 pCommand->sessionId = (tANI_U8)sessionId;
6357 pCommand->u.roamCmd.roamId = roamId;
6358 pCommand->u.roamCmd.roamReason = reason;
6359 //We need to free the BssList when the command is done
6360 //For reassoc there is no BSS list, so the boolean set to false
6361 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
6362 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
6363 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006364 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6365 if( !HAL_STATUS_SUCCESS( status ) )
6366 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006367 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006368 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6369 csrReleaseCommandRoam( pMac, pCommand );
6370 }
6371 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006372 return (status);
6373}
6374
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006375eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
6376 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306377// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006378{
6379 eHalStatus status = eHAL_STATUS_SUCCESS;
6380 tSmeCmd *pCommand;
6381
6382 pCommand = csrGetCommandBuffer(pMac);
6383 if(NULL == pCommand)
6384 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006385 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006386 status = eHAL_STATUS_RESOURCES;
6387 }
6388 else
6389 {
6390 if(pBssDescription)
6391 {
6392 //copy over the parameters we need later
6393 pCommand->command = eSmeCommandRoam;
6394 pCommand->sessionId = (tANI_U8)sessionId;
6395 pCommand->u.roamCmd.roamReason = reason;
6396 //this is the important parameter
6397 //in this case we are using this field for the "next" BSS
6398 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
6399 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
6400 if( !HAL_STATUS_SUCCESS( status ) )
6401 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006402 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d"), status );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006403 csrReleaseCommandPreauth( pMac, pCommand );
6404 }
6405 }
6406 else
6407 {
6408 //Return failure
6409 status = eHAL_STATUS_RESOURCES;
6410 }
6411 }
6412 return (status);
6413}
6414
6415eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
6416{
6417 tListElem *pEntry;
6418 tSmeCmd *pCommand;
6419 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6420 if ( pEntry )
6421 {
6422 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6423 if ( (eSmeCommandRoam == pCommand->command) &&
6424 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
6425 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006426 smsLog( pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006427 pCommand->command, pCommand->u.roamCmd.roamReason);
6428 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
6429 csrReleaseCommandPreauth( pMac, pCommand );
6430 }
6431 } else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006432 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d "),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006433 pCommand->command, pCommand->u.roamCmd.roamReason);
6434 }
6435 }
6436 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006437 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006438 }
6439 smeProcessPendingQueue( pMac );
6440 return eHAL_STATUS_SUCCESS;
6441}
6442
Jeff Johnson295189b2012-06-20 16:38:30 -07006443eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6444 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6445{
6446 eHalStatus status = eHAL_STATUS_FAILURE;
6447 tScanResultHandle hBSSList;
6448 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006449 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
6450 if(HAL_STATUS_SUCCESS(status))
6451 {
6452 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6453 if(pRoamId)
6454 {
6455 *pRoamId = roamId;
6456 }
6457 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6458 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6459 if(!HAL_STATUS_SUCCESS(status))
6460 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006461 smsLog(pMac, LOGE, FL("failed to start a join process"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006462 csrScanResultPurge(pMac, hBSSList);
6463 }
6464 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006465 return (status);
6466}
6467
Jeff Johnson295189b2012-06-20 16:38:30 -07006468eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6469 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6470{
6471 eHalStatus status = eHAL_STATUS_SUCCESS;
6472 tScanResultHandle hBSSList;
6473 tCsrScanResultFilter *pScanFilter;
6474 tANI_U32 roamId = 0;
6475 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
6476 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006477 if (NULL == pProfile)
6478 {
6479 smsLog(pMac, LOGP, FL("No profile specified"));
6480 return eHAL_STATUS_FAILURE;
6481 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006482 smsLog(pMac, LOG1, FL("called BSSType = %d authtype = %d encryType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006483 pProfile->BSSType, pProfile->AuthType.authType[0], pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006484 if( CSR_IS_WDS( pProfile ) &&
6485 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
6486 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006487 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d"),
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006488 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006489 return status;
6490 }
6491 csrRoamCancelRoaming(pMac, sessionId);
6492 csrScanRemoveFreshScanCommand(pMac, sessionId);
6493 csrScanCancelIdleScan(pMac);
6494 //Only abort the scan if it is not used for other roam/connect purpose
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05306495 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Jeff Johnson295189b2012-06-20 16:38:30 -07006496 if (!vos_concurrent_sessions_running() && (VOS_STA_SAP_MODE == pProfile->csrPersona))//In case of AP mode we do not want idle mode scan
6497 {
6498 csrScanDisable(pMac);
6499 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006500 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6501 //Check whether ssid changes
6502 if(csrIsConnStateConnected(pMac, sessionId))
6503 {
6504 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6505 {
6506 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6507 }
6508 }
6509#ifdef FEATURE_WLAN_BTAMP_UT_RF
6510 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
6511#endif
6512 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
6513 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006514 smsLog(pMac, LOG1, FL("is called with BSSList"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006515 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
6516 if(pRoamId)
6517 {
6518 roamId = *pRoamId;
6519 }
6520 if(!HAL_STATUS_SUCCESS(status))
6521 {
6522 fCallCallback = eANI_BOOLEAN_TRUE;
6523 }
6524 }
6525 else
6526 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306527 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
6528 if ( NULL == pScanFilter )
6529 status = eHAL_STATUS_FAILURE;
6530 else
6531 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006532 if(HAL_STATUS_SUCCESS(status))
6533 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306534 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006535 //Try to connect to any BSS
6536 if(NULL == pProfile)
6537 {
6538 //No encryption
6539 pScanFilter->EncryptionType.numEntries = 1;
6540 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6541 }//we don't have a profile
6542 else
6543 {
6544 //Here is the profile we need to connect to
6545 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6546 }//We have a profile
6547 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6548 if(pRoamId)
6549 {
6550 *pRoamId = roamId;
6551 }
6552
6553 if(HAL_STATUS_SUCCESS(status))
6554 {
6555 /*Save the WPS info*/
6556 if(NULL != pProfile)
6557 {
6558 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
6559 }
6560 else
6561 {
6562 pScanFilter->bWPSAssociation = 0;
6563 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006564 do
6565 {
6566 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006567 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006568 )
6569 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006570 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07006571 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6572 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6573 if(!HAL_STATUS_SUCCESS(status))
6574 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006575 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006576 fCallCallback = eANI_BOOLEAN_TRUE;
6577 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006578 else
6579 {
6580 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
6581 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006582 break;
6583 }
6584 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006585 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006586 if(HAL_STATUS_SUCCESS(status))
6587 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006588 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6589 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6590 if(!HAL_STATUS_SUCCESS(status))
6591 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006592 smsLog(pMac, LOGE, FL(" CSR failed to issue connect command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006593 csrScanResultPurge(pMac, hBSSList);
6594 fCallCallback = eANI_BOOLEAN_TRUE;
6595 }
6596 }//Have scan result
6597 else if(NULL != pProfile)
6598 {
6599 //Check whether it is for start ibss
6600 if(CSR_IS_START_IBSS(pProfile))
6601 {
6602 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6603 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6604 if(!HAL_STATUS_SUCCESS(status))
6605 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006606 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006607 fCallCallback = eANI_BOOLEAN_TRUE;
6608 }
6609 }
6610 else
6611 {
6612 //scan for this SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006613 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006614 if(!HAL_STATUS_SUCCESS(status))
6615 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006616 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006617 fCallCallback = eANI_BOOLEAN_TRUE;
6618 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006619 else
6620 {
6621 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
6622 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006623 }
6624 }
6625 else
6626 {
6627 fCallCallback = eANI_BOOLEAN_TRUE;
6628 }
6629 } while (0);
6630 if(NULL != pProfile)
6631 {
6632 //we need to free memory for filter if profile exists
6633 csrFreeScanFilter(pMac, pScanFilter);
6634 }
6635 }//Got the scan filter from profile
6636
Kiet Lam64c1b492013-07-12 13:56:44 +05306637 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006638 }//allocated memory for pScanFilter
6639 }//No Bsslist coming in
6640 //tell the caller if we fail to trigger a join request
6641 if( fCallCallback )
6642 {
6643 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6644 }
6645
6646 return (status);
6647}
Jeff Johnson295189b2012-06-20 16:38:30 -07006648eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6649 tCsrRoamModifyProfileFields modProfileFields,
6650 tANI_U32 *pRoamId)
6651{
6652 eHalStatus status = eHAL_STATUS_SUCCESS;
6653 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
6654 tANI_U32 roamId = 0;
6655 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006656 if (NULL == pProfile)
6657 {
6658 smsLog(pMac, LOGP, FL("No profile specified"));
6659 return eHAL_STATUS_FAILURE;
6660 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006661 smsLog(pMac, LOG1, FL("called BSSType = %d authtype = %d encryType = %d"), pProfile->BSSType, pProfile->AuthType.authType[0], pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006662 csrRoamCancelRoaming(pMac, sessionId);
6663 csrScanRemoveFreshScanCommand(pMac, sessionId);
6664 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306665 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006666 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07006667 if(csrIsConnStateConnected(pMac, sessionId))
6668 {
6669 if(pProfile)
6670 {
6671 if(pProfile->SSIDs.numOfSSIDs &&
6672 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6673 {
6674 fCallCallback = eANI_BOOLEAN_FALSE;
6675 }
6676 else
6677 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006678 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006679 }
6680 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306681 else if (!vos_mem_compare(&modProfileFields,
6682 &pSession->connectedProfile.modifyProfileFields,
6683 sizeof(tCsrRoamModifyProfileFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -07006684 {
6685 fCallCallback = eANI_BOOLEAN_FALSE;
6686 }
6687 else
6688 {
6689 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006690 "in tCsrRoamModifyProfileFields got modified"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006691 }
6692 }
6693 else
6694 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006695 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006696 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006697 if(!fCallCallback)
6698 {
6699 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6700 if(pRoamId)
6701 {
6702 *pRoamId = roamId;
6703 }
6704
Jeff Johnson295189b2012-06-20 16:38:30 -07006705 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
6706 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006707 }
6708 else
6709 {
6710 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
6711 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6712 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006713 return status;
6714}
Jeff Johnson295189b2012-06-20 16:38:30 -07006715eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6716{
6717 eHalStatus status = eHAL_STATUS_FAILURE;
6718 tScanResultHandle hBSSList = NULL;
6719 tCsrScanResultFilter *pScanFilter = NULL;
6720 tANI_U32 roamId;
6721 tCsrRoamProfile *pProfile = NULL;
6722 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006723
6724 if(!pSession)
6725 {
6726 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6727 return eHAL_STATUS_FAILURE;
6728 }
6729
Jeff Johnson295189b2012-06-20 16:38:30 -07006730 do
6731 {
6732 if(pSession->pCurRoamProfile)
6733 {
6734 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306735 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006736 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
Kiet Lam64c1b492013-07-12 13:56:44 +05306737 pProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
6738 if ( NULL == pProfile )
6739 status = eHAL_STATUS_FAILURE;
6740 else
6741 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006742 if(!HAL_STATUS_SUCCESS(status))
6743 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05306744 vos_mem_set(pProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006745 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05306746 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006747 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05306748 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
6749 if ( NULL == pScanFilter )
6750 status = eHAL_STATUS_FAILURE;
6751 else
6752 status = eHAL_STATUS_SUCCESS;
6753
Jeff Johnson295189b2012-06-20 16:38:30 -07006754 if(!HAL_STATUS_SUCCESS(status))
6755 {
6756 break;
6757 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306758 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006759 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6760 if(!HAL_STATUS_SUCCESS(status))
6761 {
6762 break;
6763 }
6764 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6765 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
6766 if(HAL_STATUS_SUCCESS(status))
6767 {
6768 //we want to put the last connected BSS to the very beginning, if possible
6769 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
6770 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6771 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6772 if(!HAL_STATUS_SUCCESS(status))
6773 {
6774 csrScanResultPurge(pMac, hBSSList);
6775 break;
6776 }
6777 }
6778 else
6779 {
6780 //Do a scan on this profile
6781 //scan for this SSID only in case the AP suppresses SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006782 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006783 if(!HAL_STATUS_SUCCESS(status))
6784 {
6785 break;
6786 }
6787 }
6788 }//We have a profile
6789 else
6790 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006791 smsLog(pMac, LOGW, FL("cannot find a roaming profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006792 break;
6793 }
6794 }while(0);
6795 if(pScanFilter)
6796 {
6797 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05306798 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006799 }
6800 if(NULL != pProfile)
6801 {
6802 csrReleaseProfile(pMac, pProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05306803 vos_mem_free(pProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07006804 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006805 return (status);
6806}
Jeff Johnson295189b2012-06-20 16:38:30 -07006807eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
6808{
6809 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006810 if(csrIsConnStateConnected(pMac, sessionId))
6811 {
6812 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6813 if(HAL_STATUS_SUCCESS(status))
6814 {
6815 status = csrRoamJoinLastProfile(pMac, sessionId);
6816 }
6817 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006818 return (status);
6819}
6820
Jeff Johnson295189b2012-06-20 16:38:30 -07006821eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6822{
6823 eHalStatus status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006824 smsLog(pMac, LOGW, FL("is called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006825 csrRoamCancelRoaming(pMac, sessionId);
6826 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6827 if(csrIsConnStateDisconnected(pMac, sessionId))
6828 {
6829 status = csrRoamJoinLastProfile(pMac, sessionId);
6830 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006831 return (status);
6832}
6833
Jeff Johnson295189b2012-06-20 16:38:30 -07006834eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
6835{
6836 eHalStatus status = eHAL_STATUS_SUCCESS;
6837 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
6838 eCsrRoamSubState NewSubstate;
6839 tANI_U32 sessionId = pCommand->sessionId;
6840
6841 // change state to 'Roaming'...
6842 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
6843
6844 if ( csrIsConnStateIbss( pMac, sessionId ) )
6845 {
6846 // If we are in an IBSS, then stop the IBSS...
6847 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6848 fComplete = (!HAL_STATUS_SUCCESS(status));
6849 }
6850 else if ( csrIsConnStateInfra( pMac, sessionId ) )
6851 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006852 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 -07006853 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
6854 //Restore AC weight in case we change it
6855 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
6856 // in Infrasturcture, we need to disassociate from the Infrastructure network...
6857 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
6858 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
6859 {
6860 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
6861 }
6862 if( fDisassoc )
6863 {
6864 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
6865 }
6866 else
6867 {
6868 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
6869 }
6870 fComplete = (!HAL_STATUS_SUCCESS(status));
6871 }
6872 else if ( csrIsConnStateWds( pMac, sessionId ) )
6873 {
6874 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
6875 {
6876 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6877 fComplete = (!HAL_STATUS_SUCCESS(status));
6878 }
6879 //This has to be WDS station
6880 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
6881 {
6882
6883 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
6884 if( fDisassoc )
6885 {
6886 status = csrRoamIssueDisassociate( pMac, sessionId,
6887 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
6888 fComplete = (!HAL_STATUS_SUCCESS(status));
6889 }
6890 }
6891 } else {
6892 // we got a dis-assoc request while not connected to any peer
6893 // just complete the command
6894 fComplete = eANI_BOOLEAN_TRUE;
6895 status = eHAL_STATUS_FAILURE;
6896 }
6897 if(fComplete)
6898 {
6899 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6900 }
6901
6902 if(HAL_STATUS_SUCCESS(status))
6903 {
6904 if ( csrIsConnStateInfra( pMac, sessionId ) )
6905 {
6906 //Set the state to disconnect here
6907 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
6908 }
6909 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006910 else
6911 {
6912 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
6913 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006914 return (status);
6915}
6916
Jeff Johnson295189b2012-06-20 16:38:30 -07006917/* This is been removed from latest code base */
6918/*
6919static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
6920{
6921 eHalStatus status;
6922 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07006923 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
6924 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006925 return ( status );
6926}
6927*/
6928
Jeff Johnson295189b2012-06-20 16:38:30 -07006929eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
6930{
6931 eHalStatus status = eHAL_STATUS_SUCCESS;
6932 tSmeCmd *pCommand;
6933 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006934 do
6935 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006936 smsLog( pMac, LOG1, FL(" reason = %d"), reason );
Jeff Johnson295189b2012-06-20 16:38:30 -07006937 pCommand = csrGetCommandBuffer( pMac );
6938 if ( !pCommand )
6939 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006940 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006941 status = eHAL_STATUS_RESOURCES;
6942 break;
6943 }
6944 //Change the substate in case it is wait-for-key
6945 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
6946 {
6947 csrRoamStopWaitForKeyTimer( pMac );
6948 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6949 }
6950 pCommand->command = eSmeCommandRoam;
6951 pCommand->sessionId = (tANI_U8)sessionId;
6952 switch ( reason )
6953 {
6954 case eCSR_DISCONNECT_REASON_MIC_ERROR:
6955 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
6956 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006957 case eCSR_DISCONNECT_REASON_DEAUTH:
6958 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
6959 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006960 case eCSR_DISCONNECT_REASON_HANDOFF:
6961 fHighPriority = eANI_BOOLEAN_TRUE;
6962 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
6963 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006964 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
6965 case eCSR_DISCONNECT_REASON_DISASSOC:
6966 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
6967 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006968 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
6969 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
6970 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006971 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
6972 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
6973 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006974 default:
6975 break;
6976 }
6977 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
6978 if( !HAL_STATUS_SUCCESS( status ) )
6979 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006980 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006981 csrReleaseCommandRoam( pMac, pCommand );
6982 }
6983 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07006984 return( status );
6985}
6986
Jeff Johnson295189b2012-06-20 16:38:30 -07006987eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
6988{
6989 eHalStatus status = eHAL_STATUS_SUCCESS;
6990 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07006991 pCommand = csrGetCommandBuffer( pMac );
6992 if ( NULL != pCommand )
6993 {
6994 //Change the substate in case it is wait-for-key
6995 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
6996 {
6997 csrRoamStopWaitForKeyTimer( pMac );
6998 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
6999 }
7000 pCommand->command = eSmeCommandRoam;
7001 pCommand->sessionId = (tANI_U8)sessionId;
7002 pCommand->u.roamCmd.roamReason = eCsrStopBss;
7003 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7004 if( !HAL_STATUS_SUCCESS( status ) )
7005 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007006 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007007 csrReleaseCommandRoam( pMac, pCommand );
7008 }
7009 }
7010 else
7011 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007012 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007013 status = eHAL_STATUS_RESOURCES;
7014 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007015 return ( status );
7016}
7017
Jeff Johnson295189b2012-06-20 16:38:30 -07007018eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7019{
7020 eHalStatus status = eHAL_STATUS_SUCCESS;
7021 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007022
7023 if(!pSession)
7024 {
7025 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7026 return eHAL_STATUS_FAILURE;
7027 }
7028
Jeff Johnson295189b2012-06-20 16:38:30 -07007029#ifdef FEATURE_WLAN_BTAMP_UT_RF
7030 //Stop te retry
7031 pSession->maxRetryCount = 0;
7032 csrRoamStopJoinRetryTimer(pMac, sessionId);
7033#endif
7034 //Not to call cancel roaming here
7035 //Only issue disconnect when necessary
7036 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
7037 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
7038 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
7039
7040 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007041 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007042 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
7043 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307044 else
7045 {
7046 smsLog( pMac, LOGE, FL("Roam command is not present"));
7047 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007048 return (status);
7049}
7050
Jeff Johnson295189b2012-06-20 16:38:30 -07007051eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7052{
7053 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007054
7055 if(!pSession)
7056 {
7057 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7058 return eHAL_STATUS_FAILURE;
7059 }
7060
Jeff Johnson295189b2012-06-20 16:38:30 -07007061 csrRoamCancelRoaming(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007062 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
7063
7064 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
7065}
7066
Jeff Johnson295189b2012-06-20 16:38:30 -07007067eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
7068 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
7069{
7070 eHalStatus status = eHAL_STATUS_SUCCESS;
7071 tDot11fBeaconIEs *pIesTemp = pIes;
7072 tANI_U8 index;
7073 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7074 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007075
7076 if(!pSession)
7077 {
7078 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7079 return eHAL_STATUS_FAILURE;
7080 }
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007081 if(pConnectProfile->pAddIEAssoc)
7082 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307083 vos_mem_free(pConnectProfile->pAddIEAssoc);
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007084 pConnectProfile->pAddIEAssoc = NULL;
7085 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307086 vos_mem_set(&pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007087 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
7088 pConnectProfile->AuthInfo = pProfile->AuthType;
7089 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
7090 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
7091 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
7092 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
7093 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
7094 pConnectProfile->BSSType = pProfile->BSSType;
7095 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
7096 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07007097 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
AnjaneeDevi Kapparapu4b043912014-02-18 13:22:35 +05307098 if (!pConnectProfile->beaconInterval)
7099 {
7100 smsLog(pMac, LOGW, FL("ERROR: Beacon interval is ZERO"));
7101 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307102 vos_mem_copy(&pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007103 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
7104 if(pProfile->nAddIEAssocLength)
7105 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307106 pConnectProfile->pAddIEAssoc = vos_mem_malloc(pProfile->nAddIEAssocLength);
7107 if ( NULL == pConnectProfile->pAddIEAssoc )
7108 status = eHAL_STATUS_FAILURE;
7109 else
7110 status = eHAL_STATUS_SUCCESS;
7111 if (!HAL_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007112 {
7113 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
7114 return eHAL_STATUS_FAILURE;
7115 }
7116 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05307117 vos_mem_copy(pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
7118 pProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007119 }
7120
Jeff Johnson295189b2012-06-20 16:38:30 -07007121 //Save bssid
7122 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
7123#ifdef WLAN_FEATURE_VOWIFI_11R
7124 if (pSirBssDesc->mdiePresent)
7125 {
7126 pConnectProfile->MDID.mdiePresent = 1;
7127 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
7128 }
7129#endif
Leela Venkata Kiran Kumar Reddy Chiralad48e3272013-04-12 14:21:07 -07007130 if( NULL == pIesTemp )
7131 {
7132 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
7133 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007134#ifdef FEATURE_WLAN_ESE
7135 if ((csrIsProfileESE(pProfile) ||
7136 ((pIesTemp->ESEVersion.present)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007137 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
7138 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
7139 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
7140 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -07007141#ifdef WLAN_FEATURE_11W
7142 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
7143#endif
Saurabh Gupta775073c2013-02-14 13:31:36 +05307144 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007145 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07007146 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007147 pConnectProfile->isESEAssoc = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007148 }
7149#endif
7150 //save ssid
Jeff Johnson295189b2012-06-20 16:38:30 -07007151 if(HAL_STATUS_SUCCESS(status))
7152 {
7153 if(pIesTemp->SSID.present)
7154 {
7155 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +05307156 vos_mem_copy(pConnectProfile->SSID.ssId, pIesTemp->SSID.ssid,
7157 pIesTemp->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07007158 }
7159
7160 //Save the bss desc
7161 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307162
7163 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07007164 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307165 //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 -07007166 pConnectProfile->qap = TRUE;
7167 }
7168 else
7169 {
7170 pConnectProfile->qap = FALSE;
7171 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007172 if ( NULL == pIes )
7173 {
7174 //Free memory if it allocated locally
Kiet Lam64c1b492013-07-12 13:56:44 +05307175 vos_mem_free(pIesTemp);
Jeff Johnson295189b2012-06-20 16:38:30 -07007176 }
7177 }
7178 //Save Qos connection
7179 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
7180
7181 if(!HAL_STATUS_SUCCESS(status))
7182 {
7183 csrFreeConnectBssDesc(pMac, sessionId);
7184 }
7185 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
7186 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307187 if ((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
7188 vos_mem_compare(pProfile->SSIDs.SSIDList[index].SSID.ssId,
7189 pConnectProfile->SSID.ssId,
7190 pConnectProfile->SSID.length))
Jeff Johnson295189b2012-06-20 16:38:30 -07007191 {
7192 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
7193 break;
7194 }
7195 pConnectProfile->handoffPermitted = FALSE;
7196 }
7197
7198 return (status);
7199}
7200
Jeff Johnson295189b2012-06-20 16:38:30 -07007201static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
7202{
7203 tListElem *pEntry = NULL;
7204 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007205 //The head of the active list is the request we sent
7206 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7207 if(pEntry)
7208 {
7209 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7210 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007211 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7212 {
7213 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
7214 {
7215#ifndef WLAN_MDM_CODE_REDUCTION_OPT
7216 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7217#endif
7218 }
7219 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
7220 }
7221 else
7222 {
7223 tANI_U32 roamId = 0;
7224 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007225 if(!pSession)
7226 {
7227 smsLog(pMac, LOGE, FL(" session %d not found "), pSmeJoinRsp->sessionId);
7228 return;
7229 }
7230
Jeff Johnson295189b2012-06-20 16:38:30 -07007231
7232 //The head of the active list is the request we sent
7233 //Try to get back the same profile and roam again
7234 if(pCommand)
7235 {
7236 roamId = pCommand->u.roamCmd.roamId;
7237 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007238 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
7239 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007240 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007241#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7242 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
7243 if (csrRoamIsHandoffInProgress(pMac))
7244 {
7245 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
7246 /* Should indicate neighbor roam algorithm about the connect failure here */
7247 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
7248 }
7249#endif
7250 if (pCommand)
7251 {
7252 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
7253 {
7254 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7255 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
7256 csrRoamReissueRoamCommand(pMac);
7257 }
7258 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
7259 {
7260 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7261 }
7262 else
7263 {
7264 csrRoam(pMac, pCommand);
7265 }
7266 }
7267 else
7268 {
7269 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7270 }
7271 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
7272}
7273
Jeff Johnson295189b2012-06-20 16:38:30 -07007274eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7275 tDot11fBeaconIEs *pIes,
7276 tCsrRoamProfile *pProfile, tANI_U32 roamId )
7277{
7278 eHalStatus status;
Arif Hussain24bafea2013-11-15 15:10:03 -08007279 smsLog( pMac, LOG1, "Attempting to Join Bssid= "MAC_ADDRESS_STR,
7280 MAC_ADDR_ARRAY(pSirBssDesc->bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07007281
7282 // Set the roaming substate to 'join attempt'...
7283 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007284 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007285 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007286 return (status);
7287}
7288
Jeff Johnson295189b2012-06-20 16:38:30 -07007289static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7290 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
7291{
7292 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007293 // Set the roaming substate to 'join attempt'...
7294 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
7295
Kaushik, Sushant8489f472014-01-27 11:41:22 +05307296 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7297 FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007298
7299 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007300 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07007301}
7302
Jeff Johnson295189b2012-06-20 16:38:30 -07007303void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
7304{
7305 tListElem *pEntry;
7306 tSmeCmd *pCommand;
7307 tCsrRoamInfo roamInfo;
7308 tANI_U32 sessionId;
7309 tCsrRoamSession *pSession;
7310
7311 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7312 if(pEntry)
7313 {
7314 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7315 if ( eSmeCommandRoam == pCommand->command )
7316 {
7317 sessionId = pCommand->sessionId;
7318 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007319
7320 if(!pSession)
7321 {
7322 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7323 return;
7324 }
Abhishek Singhaf15f152013-11-30 16:08:55 +05307325 /* While switching between two AP, csr will reissue roam command again
7326 to the nextbss if it was interrupted by the dissconnect req for the
7327 previous bss.During this csr is incrementing bRefAssocStartCnt twice.
7328 so reset the bRefAssocStartCnt.
7329 */
7330 if(pSession->bRefAssocStartCnt > 0)
7331 {
7332 pSession->bRefAssocStartCnt--;
7333 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007334 if( pCommand->u.roamCmd.fStopWds )
7335 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307336 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007337 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
7338 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
7339 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007340 if (CSR_IS_WDS(&pSession->connectedProfile)){
Jeff Johnson295189b2012-06-20 16:38:30 -07007341 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
7342 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7343 eCSR_ROAM_WDS_IND,
7344 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
Jeff Johnson295189b2012-06-20 16:38:30 -07007345 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
7346 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
7347 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7348 eCSR_ROAM_INFRA_IND,
7349 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
7350 }
7351
Jeff Johnson295189b2012-06-20 16:38:30 -07007352
Jeff Johnson295189b2012-06-20 16:38:30 -07007353 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
7354 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007355 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007356 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7357 }
7358 }
7359 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
7360 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007361 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007362 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7363 }
7364 }
7365 else
7366 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007367 smsLog(pMac, LOGW, " Command is not roaming after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007368 }
7369 }
7370 else
7371 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007372 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available");
Jeff Johnson295189b2012-06-20 16:38:30 -07007373 }
7374}
7375
Jeff Johnson295189b2012-06-20 16:38:30 -07007376tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
7377{
7378 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7379 tListElem *pEntry;
7380 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007381 //alwasy lock active list before locking pending list
7382 csrLLLock( &pMac->sme.smeCmdActiveList );
7383 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7384 if(pEntry)
7385 {
7386 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7387 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7388 {
7389 fRet = eANI_BOOLEAN_TRUE;
7390 }
7391 }
7392 if(eANI_BOOLEAN_FALSE == fRet)
7393 {
7394 csrLLLock(&pMac->sme.smeCmdPendingList);
7395 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
7396 while(pEntry)
7397 {
7398 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7399 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7400 {
7401 fRet = eANI_BOOLEAN_TRUE;
7402 break;
7403 }
7404 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7405 }
7406 csrLLUnlock(&pMac->sme.smeCmdPendingList);
7407 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307408 if (eANI_BOOLEAN_FALSE == fRet)
7409 {
7410 csrLLLock(&pMac->roam.roamCmdPendingList);
7411 pEntry = csrLLPeekHead(&pMac->roam.roamCmdPendingList, LL_ACCESS_NOLOCK);
7412 while (pEntry)
7413 {
7414 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7415 if (( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7416 {
7417 fRet = eANI_BOOLEAN_TRUE;
7418 break;
7419 }
7420 pEntry = csrLLNext(&pMac->roam.roamCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7421 }
7422 csrLLUnlock(&pMac->roam.roamCmdPendingList);
7423 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007424 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007425 return (fRet);
7426}
7427
Jeff Johnson295189b2012-06-20 16:38:30 -07007428tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
7429{
7430 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7431 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07007432 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
7433 {
7434 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
7435 {
7436 break;
7437 }
7438 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007439 return ( fRet );
7440}
7441
Jeff Johnson295189b2012-06-20 16:38:30 -07007442tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
7443{
7444 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007445 //alwasy lock active list before locking pending list
7446 csrLLLock( &pMac->sme.smeCmdActiveList );
7447 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7448 if(eANI_BOOLEAN_FALSE == fRet)
7449 {
7450 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
7451 }
7452 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007453 return (fRet);
7454}
7455
Jeff Johnson295189b2012-06-20 16:38:30 -07007456tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
7457{
7458 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7459 tListElem *pEntry;
7460 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007461 //alwasy lock active list before locking pending list
7462 csrLLLock( &pMac->sme.smeCmdActiveList );
7463 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7464 if( pEntry )
7465 {
7466 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
7467 if( ( eCsrRoamCommandScan == pCommand->command ) &&
7468 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
7469 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
7470 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
7471 {
7472 fRet = eANI_BOOLEAN_TRUE;
7473 }
7474 }
7475 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007476 return (fRet);
7477}
Jeff Johnson295189b2012-06-20 16:38:30 -07007478eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
7479{
7480 eHalStatus status = eHAL_STATUS_SUCCESS;
7481 tSmeCmd *pCommand = NULL;
7482 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
7483 tANI_BOOLEAN fRemoveCmd = FALSE;
7484 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07007485 // Delete the old assoc command. All is setup for reassoc to be serialized
7486 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7487 if ( pEntry )
7488 {
7489 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
7490 if ( !pCommand )
7491 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007492 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007493 return eHAL_STATUS_RESOURCES;
7494 }
7495 if ( eSmeCommandRoam == pCommand->command )
7496 {
7497 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
7498 {
7499 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7500 }
7501 else
7502 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007503 smsLog( pMac, LOGE, FL(" Unexpected active roam command present ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007504 }
7505 if (fRemoveCmd == FALSE)
7506 {
7507 // Implies we did not get the serialized assoc command we
7508 // were expecting
7509 pCommand = NULL;
7510 }
7511 }
7512 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007513 if(NULL == pCommand)
7514 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007515 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007516 return eHAL_STATUS_RESOURCES;
7517 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007518 do
7519 {
7520 //Change the substate in case it is wait-for-key
7521 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7522 {
7523 csrRoamStopWaitForKeyTimer( pMac );
7524 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
7525 }
7526 pCommand->command = eSmeCommandRoam;
7527 pCommand->sessionId = (tANI_U8)sessionId;
7528 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07007529 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7530 if( !HAL_STATUS_SUCCESS( status ) )
7531 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007532 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007533 csrReleaseCommandRoam( pMac, pCommand );
7534 }
7535 } while( 0 );
7536
Jeff Johnson295189b2012-06-20 16:38:30 -07007537 return( status );
7538}
7539static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
7540{
7541 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7542 tCsrScanResult *pScanResult = NULL;
7543 tSirBssDescription *pBssDesc = NULL;
7544 tSmeCmd *pCommand = NULL;
7545 tANI_U32 sessionId;
7546 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07007547 if(NULL == pEntry)
7548 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307549 smsLog(pMac, LOGE, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07007550 return;
7551 }
7552 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7553 sessionId = pCommand->sessionId;
7554 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007555
7556 if(!pSession)
7557 {
7558 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7559 return;
7560 }
7561
Jeff Johnson295189b2012-06-20 16:38:30 -07007562 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
7563 {
7564 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007565 smsLog(pMac, LOGW, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007566 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7567 }
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07007568 /* If the roaming has stopped, not to continue the roaming command*/
7569 else if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
7570 {
7571 //No need to complete roaming here as it already completes
7572 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed\n"),
7573 pCommand->u.roamCmd.roamReason);
7574 csrSetAbortRoamingCommand( pMac, pCommand );
7575 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7576 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007577 else
7578 {
7579 if ( CCM_IS_RESULT_SUCCESS(result) )
7580 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007581 smsLog(pMac, LOG2, "Cfg sequence complete");
Jeff Johnson295189b2012-06-20 16:38:30 -07007582 // Successfully set the configuration parameters for the new Bss. Attempt to
7583 // join the roaming Bss.
7584 if(pCommand->u.roamCmd.pRoamBssEntry)
7585 {
7586 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
7587 pBssDesc = &pScanResult->Result.BssDescriptor;
7588 }
7589 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
7590 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07007591 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07007592 )
7593 {
7594 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
7595 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
7596 pBssDesc, pCommand->u.roamCmd.roamId )))
7597 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307598 smsLog(pMac, LOGE, " CSR start BSS failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07007599 //We need to complete the command
7600 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7601 }
7602 }
7603 else
7604 {
7605 if (!pCommand->u.roamCmd.pRoamBssEntry)
7606 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307607 smsLog(pMac, LOGE, " pRoamBssEntry is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07007608 //We need to complete the command
7609 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
7610 return;
7611 }
7612 // If we are roaming TO an Infrastructure BSS...
7613 VOS_ASSERT(pScanResult != NULL);
7614 if ( csrIsInfraBssDesc( pBssDesc ) )
7615 {
7616 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07007617 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
7618 {
7619 // ..and currently in an Infrastructure connection....
7620 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
7621 {
7622 // ...and the SSIDs are equal, then we Reassoc.
7623 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
7624 pIesLocal ) )
7625 // ..and currently in an infrastructure connection
7626 {
7627 // then issue a Reassoc.
7628 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
7629 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
7630 &pCommand->u.roamCmd.roamProfile );
7631 }
7632 else
7633 {
7634
7635 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
7636 // previously associated AP.
7637 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7638 pIesLocal,
7639 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
7640 {
7641 //try something else
7642 csrRoam( pMac, pCommand );
7643 }
7644 }
7645 }
7646 else
7647 {
7648 eHalStatus status = eHAL_STATUS_SUCCESS;
7649
7650 /* We need to come with other way to figure out that this is because of HO in BMP
7651 The below API will be only available for Android as it uses a different HO algorithm */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007652 /* Reassoc request will be used only for ESE and 11r handoff whereas other legacy roaming should
Jeff Johnson295189b2012-06-20 16:38:30 -07007653 * use join request */
7654#ifdef WLAN_FEATURE_VOWIFI_11R
7655 if (csrRoamIsHandoffInProgress(pMac) &&
7656 csrRoamIs11rAssoc(pMac))
7657 {
7658 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
7659 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
7660 }
7661 else
7662#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007663#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07007664 if (csrRoamIsHandoffInProgress(pMac) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007665 csrRoamIsESEAssoc(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07007666 {
7667 // Now serialize the reassoc command.
7668 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7669 }
7670 else
7671#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007672#ifdef FEATURE_WLAN_LFR
7673 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05307674 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007675 {
7676 // Now serialize the reassoc command.
7677 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7678 }
7679 else
7680#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007681 // else we are not connected and attempting to Join. Issue the
7682 // Join request.
7683 {
7684 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7685 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
7686 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
7687 }
7688 if(!HAL_STATUS_SUCCESS(status))
7689 {
7690 //try something else
7691 csrRoam( pMac, pCommand );
7692 }
7693 }
7694 if( !pScanResult->Result.pvIes )
7695 {
7696 //Locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05307697 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07007698 }
7699 }
7700 }//if ( csrIsInfraBssDesc( pBssDesc ) )
7701 else
7702 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007703 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007704 }
7705 }//else
7706 }//if ( WNI_CFG_SUCCESS == result )
7707 else
7708 {
7709 // In the event the configuration failed, for infra let the roam processor
7710 //attempt to join something else...
7711 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
7712 {
7713 csrRoam(pMac, pCommand);
7714 }
7715 else
7716 {
7717 //We need to complete the command
7718 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
7719 {
7720 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7721 }
7722 else
7723 {
7724 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7725 }
7726 }
7727 }
7728 }//we have active entry
7729}
7730
Jeff Johnson295189b2012-06-20 16:38:30 -07007731static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
7732{
7733 //No one is sending eWNI_SME_AUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007734 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007735 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
7736 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007737 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007738 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
7739 // join the new one...
7740 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07007741 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
7742 }
7743 else {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007744 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08X [%d]", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007745 /***profHandleLostLinkAfterReset(pAdapter);
7746 // In the event the authenticate fails, let the roam processor attempt to join something else...
7747 roamRoam( pAdapter );***/
7748 }
7749}
7750
Jeff Johnson295189b2012-06-20 16:38:30 -07007751static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
7752{
7753 eCsrRoamCompleteResult result;
7754 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
7755 tCsrRoamInfo roamInfo;
7756 tANI_U32 roamId = 0;
7757
7758 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7759 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007760 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007761 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07007762 /* Defeaturize this part later if needed */
7763#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
7764 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
7765 * we need the response contents while processing the result in csrRoamProcessResults() */
7766 if (csrRoamIsHandoffInProgress(pMac))
7767 {
7768 /* Need to dig more on indicating events to SME QoS module */
7769 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7770 csrRoamComplete( pMac, result, pSmeJoinRsp);
7771 }
7772 else
7773#endif
7774 {
7775 csrRoamComplete( pMac, result, NULL );
7776 }
7777 }
7778 /* Should we handle this similar to handling the join failure? Is it ok
7779 * to call csrRoamComplete() with state as CsrJoinFailure */
7780 else
7781 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007782 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007783 result = eCsrReassocFailure;
7784#ifdef WLAN_FEATURE_VOWIFI_11R
7785 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
7786 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode))
7787 {
7788 // Inform HDD to turn off FT flag in HDD
7789 if (pNeighborRoamInfo)
7790 {
7791 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7792 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
7793 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07007794 /*
7795 * Since the above callback sends a disconnect
7796 * to HDD, we should clean-up our state
7797 * machine as well to be in sync with the upper
7798 * layers. There is no need to send a disassoc
7799 * since: 1) we will never reassoc to the current
7800 * AP in LFR, and 2) there is no need to issue a
7801 * disassoc to the AP with which we were trying
7802 * to reassoc.
7803 */
7804 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7805 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07007806 }
7807 }
7808#endif
7809 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
7810 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
7811 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
7812 //The disassoc rsp message will remove the command from active list
7813 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
7814 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
7815 {
7816 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7817 }
7818 }
7819}
7820
Jeff Johnson295189b2012-06-20 16:38:30 -07007821static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
7822{
Jeff Johnson295189b2012-06-20 16:38:30 -07007823#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7824 {
7825 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07007826 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
7827 if(pIbssLog)
7828 {
7829 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
7830 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
7831 {
7832 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
7833 }
7834 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
7835 }
7836 }
7837#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07007838 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7839 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
7840 {
7841 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7842 }
7843 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
7844 {
7845 csrRoamReissueRoamCommand(pMac);
7846 }
7847}
7848
Jeff Johnson295189b2012-06-20 16:38:30 -07007849void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
7850{
7851 tSirResultCodes statusCode;
7852#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7853 tScanResultHandle hBSSList;
7854 tANI_BOOLEAN fCallCallback, fRemoveCmd;
7855 eHalStatus status;
7856 tCsrRoamInfo roamInfo;
7857 tCsrScanResultFilter *pScanFilter = NULL;
7858 tANI_U32 roamId = 0;
7859 tCsrRoamProfile *pCurRoamProfile = NULL;
7860 tListElem *pEntry = NULL;
7861 tSmeCmd *pCommand = NULL;
7862#endif
7863 tANI_U32 sessionId;
7864 tCsrRoamSession *pSession;
Jeff Johnsone7245742012-09-05 17:12:55 -07007865
Jeff Johnson295189b2012-06-20 16:38:30 -07007866 tSirSmeDisassocRsp SmeDisassocRsp;
7867
7868 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
7869 sessionId = SmeDisassocRsp.sessionId;
7870 statusCode = SmeDisassocRsp.statusCode;
7871
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007872 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007873
7874 if ( csrIsConnStateInfra( pMac, sessionId ) )
7875 {
7876 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7877 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007878 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007879
7880 if(!pSession)
7881 {
7882 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7883 return;
7884 }
7885
Jeff Johnson295189b2012-06-20 16:38:30 -07007886 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
7887 {
7888 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7889 }
7890 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
7891 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
7892 {
7893 if ( eSIR_SME_SUCCESS == statusCode )
7894 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007895 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007896 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
7897 }
7898 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7899 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007900 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
7901 {
Kaushik, Sushant8489f472014-01-27 11:41:22 +05307902 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH,
7903 "CSR SmeDisassocReq due to HO on session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007904#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007905 /*
7906 * First ensure if the roam profile is in the scan cache.
7907 * If not, post a reassoc failure and disconnect.
7908 */
Kiet Lam64c1b492013-07-12 13:56:44 +05307909 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
7910 if ( NULL == pScanFilter )
7911 status = eHAL_STATUS_FAILURE;
7912 else
7913 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007914 if(HAL_STATUS_SUCCESS(status))
7915 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307916 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007917 status = csrRoamPrepareFilterFromProfile(pMac,
7918 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
7919 if(!HAL_STATUS_SUCCESS(status))
7920 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007921 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007922 __func__, status);
7923 goto POST_ROAM_FAILURE;
7924 }
7925 else
7926 {
7927 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
7928 if (!HAL_STATUS_SUCCESS(status))
7929 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007930 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007931 __func__, status);
7932 goto POST_ROAM_FAILURE;
7933 }
7934 }
7935 }
7936 else
7937 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007938 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007939 __func__, status);
7940 goto POST_ROAM_FAILURE;
7941 }
7942
7943 /*
7944 * After ensuring that the roam profile is in the scan result list,
7945 * dequeue the command from the active list.
7946 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007947 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7948 if ( pEntry )
7949 {
7950 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007951 /* If the head of the queue is Active and it is a ROAM command, remove
7952 * and put this on the Free queue.
7953 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007954 if ( eSmeCommandRoam == pCommand->command )
7955 {
Jeff Johnsone7245742012-09-05 17:12:55 -07007956
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007957 /*
7958 * we need to process the result first before removing it from active list
7959 * because state changes still happening insides roamQProcessRoamResults so
7960 * no other roam command should be issued.
7961 */
Jeff Johnson295189b2012-06-20 16:38:30 -07007962 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7963 if(pCommand->u.roamCmd.fReleaseProfile)
7964 {
7965 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
7966 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
7967 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007968 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07007969 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07007970 else
7971 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007972 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007973 __func__, pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07007974 }
7975 }
7976 else
7977 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007978 smsLog( pMac, LOGE, "%s: roam command not active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007979 }
7980 }
7981 else
7982 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007983 smsLog( pMac, LOGE, "%s: NO commands are active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007984 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007985
7986 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07007987 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
7988
Kiet Lam64c1b492013-07-12 13:56:44 +05307989 vos_mem_copy(roamInfo.bssid,
7990 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
7991 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07007992
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007993 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
7994 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07007995
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007996 /* Copy the connected profile to apply the same for this connection as well */
Kiet Lam64c1b492013-07-12 13:56:44 +05307997 pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
7998 if ( pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07007999 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308000 vos_mem_set(pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008001 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
8002 //make sure to put it at the head of the cmd queue
8003 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
8004 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
8005 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
8006
Jeff Johnson295189b2012-06-20 16:38:30 -07008007 if(!HAL_STATUS_SUCCESS(status))
8008 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008009 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008010 __func__, status);
8011 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008012 }
8013
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008014 /* Notify sub-modules like QoS etc. that handoff happening */
8015 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08008016 csrReleaseProfile(pMac, pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05308017 vos_mem_free(pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07008018 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308019 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008020 return;
8021 }
8022
8023POST_ROAM_FAILURE:
8024 if (pScanFilter)
8025 {
8026 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308027 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008028 }
8029 if (pCurRoamProfile)
Kiet Lam64c1b492013-07-12 13:56:44 +05308030 vos_mem_free(pCurRoamProfile);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008031
8032 /* Inform the upper layers that the reassoc failed */
8033 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
8034 csrRoamCallCallback(pMac, sessionId,
8035 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
8036
8037 /*
8038 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
8039 * Upon success, we would re-enter this routine after receiving the disassoc
8040 * response and will fall into the reassoc fail sub-state. And, eventually
8041 * call csrRoamComplete which would remove the roam command from SME active
8042 * queue.
8043 */
8044 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
8045 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
8046 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008047 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008048 __func__, status);
8049 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07008050 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008051#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008052
Jeff Johnson295189b2012-06-20 16:38:30 -07008053 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
8054 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
8055 {
8056 // Disassoc due to Reassoc failure falls into this codepath....
8057 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8058 }
8059 else
8060 {
8061 if ( eSIR_SME_SUCCESS == statusCode )
8062 {
8063 // Successfully disassociated from the 'old' Bss...
8064 //
8065 // We get Disassociate response in three conditions.
8066 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
8067 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
8068 // Infrastructure network.
8069 // - Third is where we are doing an Infra to Infra roam between networks with different
8070 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
8071
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008072 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008073 }
8074 else
8075 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008076 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008077 }
8078 //We are not done yet. Get the data and continue roaming
8079 csrRoamReissueRoamCommand(pMac);
8080 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008081}
8082
Jeff Johnson295189b2012-06-20 16:38:30 -07008083static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
8084{
8085 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008086 //No one is sending eWNI_SME_DEAUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008087 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008088 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08008089 pMac->roam.deauthRspStatus = statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008090 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
8091 {
8092 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8093 }
8094 else
8095 {
8096 if ( eSIR_SME_SUCCESS == statusCode )
8097 {
8098 // Successfully deauth from the 'old' Bss...
8099 //
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008100 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008101 }
8102 else
8103 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008104 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008105 }
8106 //We are not done yet. Get the data and continue roaming
8107 csrRoamReissueRoamCommand(pMac);
8108 }
8109}
8110
Jeff Johnson295189b2012-06-20 16:38:30 -07008111static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
8112{
8113 eCsrRoamCompleteResult result;
8114
8115 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
8116 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008117 smsLog( pMac, LOGW, "SmeStartBssReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008118 result = eCsrStartBssSuccess;
8119 }
8120 else
8121 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008122 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08X", pSmeStartBssRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008123 //Let csrRoamComplete decide what to do
8124 result = eCsrStartBssFailure;
8125 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008126 csrRoamComplete( pMac, result, pSmeStartBssRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -07008127}
8128
Jeff Johnson295189b2012-06-20 16:38:30 -07008129/*
8130 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
8131 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
8132 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
8133 For the messages where sender allocates memory for specific structures, then it can be
8134 cast accordingly.
8135*/
8136void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8137{
8138 tSirSmeRsp *pSmeRsp;
8139 tSmeIbssPeerInd *pIbssPeerInd;
8140 tCsrRoamInfo roamInfo;
8141 // TODO Session Id need to be acquired in this function
8142 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008143 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308144 smsLog(pMac, LOG2, FL("Message %d[0x%04X] received in substate %s"),
8145 pSmeRsp->messageType, pSmeRsp->messageType,
8146 macTraceGetcsrRoamSubState(
8147 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008148 pSmeRsp->messageType = (pSmeRsp->messageType);
8149 pSmeRsp->length = (pSmeRsp->length);
8150 pSmeRsp->statusCode = (pSmeRsp->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008151 switch (pSmeRsp->messageType)
8152 {
8153
8154 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
8155 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
8156 {
8157 //We sent a JOIN_REQ
8158 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
8159 }
8160 break;
8161
8162 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
8163 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
8164 {
8165 //We sent a AUTH_REQ
8166 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
8167 }
8168 break;
8169
8170 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
8171 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
8172 {
8173 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
8174 }
8175 break;
8176
8177 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
8178 {
8179 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
8180 }
8181 break;
8182
8183 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
8184 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
8185 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
8186 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
8187 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
8188 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
8189//HO
8190 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
8191 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308192 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %s"),
8193 macTraceGetcsrRoamSubState(
8194 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008195 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
8196 }
8197 break;
8198
8199 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
8200 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
8201 {
8202 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
8203 }
8204 break;
8205
8206 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
8207 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
8208 {
8209 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
8210 }
8211 break;
8212
8213 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
8214 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
8215 {
8216 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
8217 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008218 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008219 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
8220 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
8221 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008222 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state");
Kiet Lam64c1b492013-07-12 13:56:44 +05308223 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
8224 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008225 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
8226 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05308227 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
8228 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008229 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
8230 eCSR_ROAM_CONNECT_STATUS_UPDATE,
8231 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
8232 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008233 default:
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308234 smsLog(pMac, LOG1,
8235 FL("Unexpected message type = %d[0x%X] received in substate %s"),
8236 pSmeRsp->messageType, pSmeRsp->messageType,
8237 macTraceGetcsrRoamSubState(
8238 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008239
8240 //If we are connected, check the link status change
8241 if(!csrIsConnStateDisconnected(pMac, sessionId))
8242 {
8243 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
8244 }
8245 break;
8246 }
8247}
8248
Jeff Johnson295189b2012-06-20 16:38:30 -07008249void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8250{
8251 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07008252 switch (pSirMsg->messageType)
8253 {
8254 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008255 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008256 csrRoamStatsRspProcessor( pMac, pSirMsg );
8257 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008258 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
8259 {
8260 tCsrRoamSession *pSession;
8261 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
8262 tCsrRoamInfo roamInfo;
8263 tCsrRoamInfo *pRoamInfo = NULL;
8264 tANI_U32 sessionId;
8265 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008266 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer "));
Kiet Lam64c1b492013-07-12 13:56:44 +05308267 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008268 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07008269 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
8270 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
8271 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008272
8273 if(!pSession)
8274 {
8275 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8276 return;
8277 }
8278
Jeff Johnson295189b2012-06-20 16:38:30 -07008279 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
8280 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07008281 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
8282 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
8283 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07008284 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
8285 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05308286 vos_mem_copy(pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr,
8287 sizeof(tSirMacAddr));
8288 vos_mem_copy(&pRoamInfo->bssid, pUpperLayerAssocCnf->bssId,
8289 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008290 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07008291 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
8292 {
8293 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
8294 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
8295 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
8296 }
8297 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8298 {
8299 vos_sleep( 100 );
8300 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
8301 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
8302 }
8303
Jeff Johnson295189b2012-06-20 16:38:30 -07008304 }
8305 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008306 default:
8307 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
8308 break;
8309 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008310}
8311
Jeff Johnson295189b2012-06-20 16:38:30 -07008312eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
8313 tSirBssDescription *pBssDescription,
8314 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
8315 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
8316 tANI_U8 keyId, tANI_U16 keyLength,
8317 tANI_U8 *pKey, tANI_U8 paeRole )
8318{
8319 eHalStatus status = eHAL_STATUS_SUCCESS;
8320 tAniEdType edType;
8321
8322 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
8323 {
8324 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
8325 }
8326
8327 edType = csrTranslateEncryptTypeToEdType( EncryptType );
8328
8329 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
8330 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
8331 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
8332 addKey )
8333 {
8334 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07008335 setKey.encType = EncryptType;
8336 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308337 vos_mem_copy(&setKey.peerMac, bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008338 setKey.paeRole = paeRole; //0 for supplicant
8339 setKey.keyId = keyId; // Kye index
8340 setKey.keyLength = keyLength;
8341 if( keyLength )
8342 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308343 vos_mem_copy(setKey.Key, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008344 }
8345 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
8346 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008347 return (status);
8348}
8349
Jeff Johnson295189b2012-06-20 16:38:30 -07008350static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8351 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8352{
8353 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8354 tSmeCmd *pCommand = NULL;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008355#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008356 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008357#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07008358
8359 do
8360 {
8361 pCommand = csrGetCommandBuffer(pMac);
8362 if(NULL == pCommand)
8363 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008364 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008365 status = eHAL_STATUS_RESOURCES;
8366 break;
8367 }
8368 pCommand->command = eSmeCommandSetKey;
8369 pCommand->sessionId = (tANI_U8)sessionId;
8370 // validate the key length, Adjust if too long...
8371 // for static WEP the keys are not set thru' SetContextReq
8372 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
8373 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
8374 {
8375 //KeyLength maybe 0 for static WEP
8376 if( pSetKey->keyLength )
8377 {
8378 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
8379 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008380 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008381 break;
8382 }
8383
8384 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308385 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8386 CSR_WEP40_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008387 }
8388 }
8389 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
8390 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
8391 {
8392 //KeyLength maybe 0 for static WEP
8393 if( pSetKey->keyLength )
8394 {
8395 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
8396 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008397 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008398 break;
8399 }
8400
8401 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308402 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8403 CSR_WEP104_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008404 }
8405 }
8406 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
8407 {
8408 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
8409 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008410 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008411 break;
8412 }
8413 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308414 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8415 CSR_TKIP_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008416 }
8417 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
8418 {
8419 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
8420 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008421 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008422 break;
8423 }
8424 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308425 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8426 CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008427 }
8428#ifdef FEATURE_WLAN_WAPI
8429 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
8430 {
8431 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
8432 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008433 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008434 break;
8435 }
8436 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308437 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8438 CSR_WAPI_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008439 }
8440#endif /* FEATURE_WLAN_WAPI */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008441#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008442 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8443 {
8444 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
8445 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008446 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008447 break;
8448 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008449 vos_mem_copy(pSession->eseCckmInfo.krk, pSetKey->Key,
Kiet Lam64c1b492013-07-12 13:56:44 +05308450 CSR_KRK_KEY_LEN);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008451 pSession->eseCckmInfo.reassoc_req_num=1;
8452 pSession->eseCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008453 status = eHAL_STATUS_SUCCESS;
8454 break;
8455 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008456#endif /* FEATURE_WLAN_ESE */
Jeff Johnsone7245742012-09-05 17:12:55 -07008457
Jeff Johnson295189b2012-06-20 16:38:30 -07008458#ifdef WLAN_FEATURE_11W
8459 //Check for 11w BIP
Chet Lanctot186b5732013-03-18 10:26:30 -07008460 else if (eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008461 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008462 if (pSetKey->keyLength < CSR_AES_KEY_LEN)
Jeff Johnson295189b2012-06-20 16:38:30 -07008463 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008464 smsLog(pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008465 break;
8466 }
8467 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308468 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008469 }
8470#endif
8471 status = eHAL_STATUS_SUCCESS;
8472 pCommand->u.setKeyCmd.roamId = roamId;
8473 pCommand->u.setKeyCmd.encType = pSetKey->encType;
8474 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308475 vos_mem_copy(&pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac,
8476 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008477 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
8478 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
Kiet Lam64c1b492013-07-12 13:56:44 +05308479 vos_mem_copy(pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008480 //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
8481
8482 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
8483 if( !HAL_STATUS_SUCCESS( status ) )
8484 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008485 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008486 }
8487 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008488 // Free the command if there has been a failure, or it is a
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008489 // "local" operation like the set ESE CCKM KRK key.
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008490 if ( ( NULL != pCommand ) &&
8491 ( (!HAL_STATUS_SUCCESS( status ) )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008492#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008493 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008494#endif /* FEATURE_WLAN_ESE */
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008495 ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008496 {
8497 csrReleaseCommandSetKey( pMac, pCommand );
8498 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008499 return( status );
8500}
8501
Jeff Johnson295189b2012-06-20 16:38:30 -07008502eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8503 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
8504{
8505 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8506 tSmeCmd *pCommand = NULL;
8507 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008508 do
8509 {
8510 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8511 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008512 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008513 status = eHAL_STATUS_CSR_WRONG_STATE;
8514 break;
8515 }
8516 pCommand = csrGetCommandBuffer(pMac);
8517 if(NULL == pCommand)
8518 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008519 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008520 status = eHAL_STATUS_RESOURCES;
8521 break;
8522 }
8523 pCommand->command = eSmeCommandRemoveKey;
8524 pCommand->sessionId = (tANI_U8)sessionId;
8525 pCommand->u.removeKeyCmd.roamId = roamId;
8526 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
Kiet Lam64c1b492013-07-12 13:56:44 +05308527 vos_mem_copy(&pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac,
8528 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008529 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
8530 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8531 {
8532 //in this case, put it to the end of the Q incase there is a set key pending.
8533 fImediate = eANI_BOOLEAN_FALSE;
8534 }
Arif Hussain24bafea2013-11-15 15:10:03 -08008535 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac="MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07008536 pRemoveKey->encType, pRemoveKey->keyId,
Arif Hussain24bafea2013-11-15 15:10:03 -08008537 MAC_ADDR_ARRAY(pCommand->u.removeKeyCmd.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07008538 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
8539 if( !HAL_STATUS_SUCCESS( status ) )
8540 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008541 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008542 break;
8543 }
8544 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008545 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
8546 {
8547 csrReleaseCommandRemoveKey( pMac, pCommand );
8548 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008549 return (status );
8550}
8551
Jeff Johnson295189b2012-06-20 16:38:30 -07008552eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8553{
8554 eHalStatus status;
8555 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
8556 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
8557 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
8558 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008559#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8560 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8561 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
lukez3c809222013-05-03 10:23:02 -07008562 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008563 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308564 vos_mem_set(&setKeyEvent,
8565 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008566 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8567 {
8568 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_REQ;
8569 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8570 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8571 }
8572 else
8573 {
8574 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_REQ;
8575 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8576 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8577 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308578 vos_mem_copy(setKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
lukez3c809222013-05-03 10:23:02 -07008579 if(CSR_IS_ENC_TYPE_STATIC(pCommand->u.setKeyCmd.encType))
Jeff Johnson295189b2012-06-20 16:38:30 -07008580 {
8581 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008582 //It has to be static WEP here
8583 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
8584 {
8585 setKeyEvent.keyId = (v_U8_t)defKeyId;
8586 }
8587 }
8588 else
8589 {
8590 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
8591 }
8592 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8593 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8594 }
8595#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008596 if( csrIsSetKeyAllowed(pMac, sessionId) )
8597 {
8598 status = csrSendMBSetContextReqMsg( pMac, sessionId,
8599 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
8600 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
8601 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
8602 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
8603 pCommand->u.setKeyCmd.keyRsc);
8604 }
8605 else
8606 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008607 smsLog( pMac, LOGW, FL(" cannot process not connected") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008608 //Set this status so the error handling take care of the case.
8609 status = eHAL_STATUS_CSR_WRONG_STATE;
8610 }
8611 if( !HAL_STATUS_SUCCESS(status) )
8612 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008613 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008614 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008615#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
lukez3c809222013-05-03 10:23:02 -07008616 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008617 {
8618 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8619 {
8620 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
8621 }
8622 else
8623 {
8624 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
8625 }
8626 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
8627 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8628 }
8629#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008630 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008631 return ( status );
8632}
8633
Jeff Johnson295189b2012-06-20 16:38:30 -07008634eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8635{
8636 eHalStatus status;
8637 tpSirSmeRemoveKeyReq pMsg = NULL;
8638 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
8639 tANI_U8 *p;
8640 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008641#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8642 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8643 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +05308644 vos_mem_set(&removeKeyEvent,
8645 sizeof(vos_event_wlan_security_payload_type),0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008646 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
8647 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8648 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05308649 vos_mem_copy(removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07008650 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
8651 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8652 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8653#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008654 if( csrIsSetKeyAllowed(pMac, sessionId) )
8655 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308656 pMsg = vos_mem_malloc(wMsgLen);
8657 if ( NULL == pMsg )
8658 status = eHAL_STATUS_FAILURE;
8659 else
8660 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008661 }
8662 else
8663 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008664 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008665 //Set the error status so error handling kicks in below
8666 status = eHAL_STATUS_CSR_WRONG_STATE;
8667 }
8668 if( HAL_STATUS_SUCCESS( status ) )
8669 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308670 vos_mem_set(pMsg, wMsgLen ,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008671 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
8672 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008673 pMsg->sessionId = (tANI_U8)sessionId;
8674 pMsg->transactionId = 0;
8675 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
8676 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
8677 // bssId - copy from session Info
Kiet Lam64c1b492013-07-12 13:56:44 +05308678 vos_mem_copy(p,
8679 &pMac->roam.roamSession[sessionId].connectedProfile.bssid,
8680 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008681 p += sizeof(tSirMacAddr);
8682 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +05308683 vos_mem_copy(p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008684 p += sizeof(tSirMacAddr);
8685 // edType
8686 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
8687 p++;
8688 // weptype
8689 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
8690 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
8691 {
8692 *p = (tANI_U8)eSIR_WEP_STATIC;
8693 }
8694 else
8695 {
8696 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
8697 }
8698 p++;
8699 //keyid
8700 *p = pCommand->u.removeKeyCmd.keyId;
8701 p++;
8702 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008703 status = palSendMBMessage(pMac->hHdd, pMsg);
8704 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008705 if( !HAL_STATUS_SUCCESS( status ) )
8706 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008707 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008708#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8709 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07008710 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008711 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8712#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008713 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
8714 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008715 return ( status );
8716}
8717
Jeff Johnson295189b2012-06-20 16:38:30 -07008718eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8719{
8720 eHalStatus status;
8721
8722 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8723 {
8724 status = eHAL_STATUS_CSR_WRONG_STATE;
8725 }
8726 else
8727 {
8728 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
8729 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008730 return ( status );
8731}
8732
Jeff Johnson295189b2012-06-20 16:38:30 -07008733/*
8734 Prepare a filter base on a profile for parsing the scan results.
8735 Upon successful return, caller MUST call csrFreeScanFilter on
8736 pScanFilter when it is done with the filter.
8737*/
8738eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
8739 tCsrScanResultFilter *pScanFilter)
8740{
8741 eHalStatus status = eHAL_STATUS_SUCCESS;
8742 tANI_U32 size = 0;
8743 tANI_U8 index = 0;
8744
8745 do
8746 {
8747 if(pProfile->BSSIDs.numOfBSSIDs)
8748 {
8749 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308750 pScanFilter->BSSIDs.bssid = vos_mem_malloc(size);
8751 if ( NULL == pScanFilter->BSSIDs.bssid )
8752 status = eHAL_STATUS_FAILURE;
8753 else
8754 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008755 if(!HAL_STATUS_SUCCESS(status))
8756 {
8757 break;
8758 }
8759 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308760 vos_mem_copy(pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07008761 }
8762 if(pProfile->SSIDs.numOfSSIDs)
8763 {
8764 if( !CSR_IS_WDS_STA( pProfile ) )
8765 {
8766 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
8767 }
8768 else
8769 {
8770 //For WDS station
8771 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
8772 pScanFilter->SSIDs.numOfSSIDs = 1;
8773 }
8774 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308775 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(size);
8776 if ( NULL == pScanFilter->SSIDs.SSIDList )
8777 status = eHAL_STATUS_FAILURE;
8778 else
8779 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008780 if(!HAL_STATUS_SUCCESS(status))
8781 {
8782 break;
8783 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308784 vos_mem_copy(pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList,
8785 size);
Jeff Johnson295189b2012-06-20 16:38:30 -07008786 }
8787 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
8788 {
8789 pScanFilter->ChannelInfo.numOfChannels = 0;
8790 pScanFilter->ChannelInfo.ChannelList = NULL;
8791 }
8792 else if(pProfile->ChannelInfo.numOfChannels)
8793 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308794 pScanFilter->ChannelInfo.ChannelList = vos_mem_malloc(
8795 sizeof(*pScanFilter->ChannelInfo.ChannelList) *
8796 pProfile->ChannelInfo.numOfChannels);
8797 if ( NULL == pScanFilter->ChannelInfo.ChannelList )
8798 status = eHAL_STATUS_FAILURE;
8799 else
8800 status = eHAL_STATUS_SUCCESS;
8801
Jeff Johnson295189b2012-06-20 16:38:30 -07008802 pScanFilter->ChannelInfo.numOfChannels = 0;
8803 if(HAL_STATUS_SUCCESS(status))
8804 {
8805 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
8806 {
8807 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
8808 {
8809 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
8810 = pProfile->ChannelInfo.ChannelList[index];
8811 pScanFilter->ChannelInfo.numOfChannels++;
8812 }
8813 else
8814 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008815 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid"), pProfile->ChannelInfo.ChannelList[index]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008816 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008817 }
8818 }
8819 else
8820 {
8821 break;
8822 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008823 }
8824 else
8825 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05308826 smsLog(pMac, LOGE, FL("Channel list empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008827 status = eHAL_STATUS_FAILURE;
8828 break;
8829 }
8830 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
8831 pScanFilter->authType = pProfile->AuthType;
8832 pScanFilter->EncryptionType = pProfile->EncryptionType;
8833 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
8834 pScanFilter->BSSType = pProfile->BSSType;
8835 pScanFilter->phyMode = pProfile->phyMode;
8836#ifdef FEATURE_WLAN_WAPI
8837 //check if user asked for WAPI with 11n or auto mode, in that case modify
8838 //the phymode to 11g
8839 if(csrIsProfileWapi(pProfile))
8840 {
8841 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
8842 {
8843 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
8844 }
8845 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
8846 {
8847 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
8848 }
8849 if(!pScanFilter->phyMode)
8850 {
8851 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
8852 }
8853 }
8854#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07008855 /*Save the WPS info*/
8856 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07008857 if( pProfile->countryCode[0] )
8858 {
8859 //This causes the matching function to use countryCode as one of the criteria.
Kiet Lam64c1b492013-07-12 13:56:44 +05308860 vos_mem_copy(pScanFilter->countryCode, pProfile->countryCode,
8861 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008862 }
8863#ifdef WLAN_FEATURE_VOWIFI_11R
8864 if (pProfile->MDID.mdiePresent)
8865 {
8866 pScanFilter->MDID.mdiePresent = 1;
8867 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
8868 }
8869#endif
8870
8871 }while(0);
8872
8873 if(!HAL_STATUS_SUCCESS(status))
8874 {
8875 csrFreeScanFilter(pMac, pScanFilter);
8876 }
8877
8878 return(status);
8879}
8880
Jeff Johnson295189b2012-06-20 16:38:30 -07008881tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
8882 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
8883{
8884 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
8885 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008886 do
8887 {
8888 // Validate the type is ok...
8889 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
8890 pCommand = csrGetCommandBuffer( pMac );
8891 if ( !pCommand )
8892 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008893 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008894 break;
8895 }
8896 //Change the substate in case it is waiting for key
8897 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8898 {
8899 csrRoamStopWaitForKeyTimer( pMac );
8900 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
8901 }
8902 pCommand->command = eSmeCommandWmStatusChange;
8903 pCommand->sessionId = (tANI_U8)sessionId;
8904 pCommand->u.wmStatusChangeCmd.Type = Type;
8905 if ( eCsrDisassociated == Type )
8906 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308907 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg,
8908 pSmeRsp,
8909 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07008910 }
8911 else
8912 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308913 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg,
8914 pSmeRsp,
8915 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07008916 }
8917 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
8918 {
8919 fCommandQueued = eANI_BOOLEAN_TRUE;
8920 }
8921 else
8922 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008923 smsLog( pMac, LOGE, FL(" fail to send message ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008924 csrReleaseCommandWmStatusChange( pMac, pCommand );
8925 }
8926
Jeff Johnson295189b2012-06-20 16:38:30 -07008927 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
8928 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07008929 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07008930 return( fCommandQueued );
8931}
8932
Jeff Johnson295189b2012-06-20 16:38:30 -07008933static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
8934{
8935 v_S7_t rssi = 0;
8936 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
8937 if(pGetRssiReq)
8938 {
8939 if(NULL != pGetRssiReq->pVosContext)
8940 {
8941 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
8942 }
8943 else
8944 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008945 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008946 return;
8947 }
8948
8949 if(NULL != pGetRssiReq->rssiCallback)
8950 {
8951 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
8952 }
8953 else
8954 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008955 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008956 return;
8957 }
8958 }
8959 else
8960 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008961 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008962 }
8963 return;
8964}
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05308965
8966static void csrUpdateSnr(tpAniSirGlobal pMac, void* pMsg)
8967{
8968 tANI_S8 snr = 0;
8969 tAniGetSnrReq *pGetSnrReq = (tAniGetSnrReq*)pMsg;
8970
8971 if (pGetSnrReq)
8972 {
8973 if (VOS_STATUS_SUCCESS !=
8974 WDA_GetSnr(pGetSnrReq->staId, &snr))
8975 {
8976 smsLog(pMac, LOGE, FL("Error in WLANTL_GetSnr"));
8977 return;
8978 }
8979
8980 if (pGetSnrReq->snrCallback)
8981 {
8982 ((tCsrSnrCallback)(pGetSnrReq->snrCallback))(snr, pGetSnrReq->staId,
8983 pGetSnrReq->pDevContext);
8984 }
8985 else
8986 {
8987 smsLog(pMac, LOGE, FL("pGetSnrReq->snrCallback is NULL"));
8988 return;
8989 }
8990 }
8991 else
8992 {
8993 smsLog(pMac, LOGE, FL("pGetSnrReq is NULL"));
8994 }
8995 return;
8996}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008997#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08008998void csrRoamRssiRspProcessor(tpAniSirGlobal pMac, void* pMsg)
8999{
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009000 tAniGetRoamRssiRsp* pRoamRssiRsp = (tAniGetRoamRssiRsp*)pMsg;
9001
Jeff Johnson36d483b2013-04-08 11:08:53 -07009002 if (NULL != pRoamRssiRsp)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009003 {
Jeff Johnson36d483b2013-04-08 11:08:53 -07009004 /* Get roam Rssi request is backed up and passed back to the response,
9005 Extract the request message to fetch callback */
9006 tpAniGetRssiReq reqBkp = (tAniGetRssiReq*)pRoamRssiRsp->rssiReq;
9007 v_S7_t rssi = pRoamRssiRsp->rssi;
9008
9009 if ((NULL != reqBkp) && (NULL != reqBkp->rssiCallback))
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009010 {
9011 ((tCsrRssiCallback)(reqBkp->rssiCallback))(rssi, pRoamRssiRsp->staId, reqBkp->pDevContext);
9012 reqBkp->rssiCallback = NULL;
9013 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009014 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009015 }
9016 else
9017 {
9018 smsLog( pMac, LOGE, FL("reqBkp->rssiCallback is NULL"));
9019 if (NULL != reqBkp)
9020 {
9021 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009022 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009023 }
9024 }
9025 }
9026 else
9027 {
9028 smsLog( pMac, LOGE, FL("pRoamRssiRsp is NULL"));
9029 }
9030 return;
9031}
9032#endif
9033
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009034
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009035#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009036void csrTsmStatsRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9037{
9038 tAniGetTsmStatsRsp* pTsmStatsRsp = (tAniGetTsmStatsRsp*)pMsg;
9039
9040 if (NULL != pTsmStatsRsp)
9041 {
9042 /* Get roam Rssi request is backed up and passed back to the response,
9043 Extract the request message to fetch callback */
9044 tpAniGetTsmStatsReq reqBkp = (tAniGetTsmStatsReq*)pTsmStatsRsp->tsmStatsReq;
9045
9046 if (NULL != reqBkp)
9047 {
9048 if (NULL != reqBkp->tsmStatsCallback)
9049 {
9050 ((tCsrTsmStatsCallback)(reqBkp->tsmStatsCallback))(pTsmStatsRsp->tsmMetrics,
9051 pTsmStatsRsp->staId, reqBkp->pDevContext);
9052 reqBkp->tsmStatsCallback = NULL;
9053 }
9054 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009055 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009056 }
9057 else
9058 {
9059 smsLog( pMac, LOGE, FL("reqBkp is NULL"));
9060 if (NULL != reqBkp)
9061 {
9062 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009063 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009064 }
9065 }
9066 }
9067 else
9068 {
9069 smsLog( pMac, LOGE, FL("pTsmStatsRsp is NULL"));
9070 }
9071 return;
9072}
9073
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009074void csrSendEseAdjacentApRepInd(tpAniSirGlobal pMac, tCsrRoamSession *pSession)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009075{
9076 tANI_U32 roamTS2 = 0;
9077 tCsrRoamInfo roamInfo;
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009078 tpPESession pSessionEntry = NULL;
9079 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009080
9081 if (NULL == pSession)
9082 {
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009083 smsLog(pMac, LOGE, FL("pSession is NULL"));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009084 return;
9085 }
9086
9087 roamTS2 = vos_timer_get_system_time();
9088 roamInfo.tsmRoamDelay = roamTS2 - pSession->roamTS1;
Arif Hussaina7c8e412013-11-20 11:06:42 -08009089 smsLog(pMac, LOG1, "Bssid("MAC_ADDRESS_STR") Roaming Delay(%u ms)",
9090 MAC_ADDR_ARRAY(pSession->connectedProfile.bssid),
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009091 roamInfo.tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009092
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009093 pSessionEntry = peFindSessionByBssid(pMac, pSession->connectedProfile.bssid, &sessionId);
9094 if (NULL == pSessionEntry)
9095 {
9096 smsLog(pMac, LOGE, FL("session %d not found"), sessionId);
9097 return;
9098 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009099 pSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly = roamInfo.tsmRoamDelay;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009100 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009101 0, eCSR_ROAM_ESE_ADJ_AP_REPORT_IND, 0);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009102}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009103#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009104
Jeff Johnsone7245742012-09-05 17:12:55 -07009105static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
9106{
9107 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
9108 if(pTlRssiInd)
9109 {
9110 if(NULL != pTlRssiInd->tlCallback)
9111 {
9112 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -08009113 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07009114 }
9115 else
9116 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009117 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009118 }
9119 }
9120 else
9121 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009122 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009123 }
9124 return;
9125}
Jeff Johnson295189b2012-06-20 16:38:30 -07009126
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309127eHalStatus csrSendResetApCapsChanged(tpAniSirGlobal pMac, tSirMacAddr *bssId)
9128{
9129 tpSirResetAPCapsChange pMsg;
9130 tANI_U16 len;
9131 eHalStatus status = eHAL_STATUS_SUCCESS;
9132
9133 /* Create the message and send to lim */
9134 len = sizeof(tSirResetAPCapsChange);
Kiet Lam64c1b492013-07-12 13:56:44 +05309135 pMsg = vos_mem_malloc(len);
9136 if ( NULL == pMsg )
9137 status = eHAL_STATUS_FAILURE;
9138 else
9139 status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309140 if (HAL_STATUS_SUCCESS(status))
9141 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309142 vos_mem_set(pMsg, sizeof(tSirResetAPCapsChange), 0);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309143 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
9144 pMsg->length = len;
Kiet Lam64c1b492013-07-12 13:56:44 +05309145 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08009146 smsLog( pMac, LOG1, FL("CSR reset caps change for Bssid= "MAC_ADDRESS_STR),
9147 MAC_ADDR_ARRAY(pMsg->bssId));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309148 status = palSendMBMessage(pMac->hHdd, pMsg);
9149 }
9150 else
9151 {
9152 smsLog( pMac, LOGE, FL("Memory allocation failed\n"));
9153 }
9154 return status;
9155}
9156
Jeff Johnson295189b2012-06-20 16:38:30 -07009157void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
9158{
9159 tSirSmeAssocInd *pAssocInd;
9160 tSirSmeDisassocInd *pDisassocInd;
9161 tSirSmeDeauthInd *pDeauthInd;
9162 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
9163 tSirSmeNewBssInfo *pNewBss;
9164 tSmeIbssPeerInd *pIbssPeerInd;
9165 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
9166 tSirSmeApNewCaps *pApNewCaps;
9167 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
9168 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
9169 tCsrRoamInfo *pRoamInfo = NULL;
9170 tCsrRoamInfo roamInfo;
9171 eHalStatus status;
9172 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
9173 tCsrRoamSession *pSession = NULL;
9174 tpSirSmeSwitchChannelInd pSwitchChnInd;
9175 tSmeMaxAssocInd *pSmeMaxAssocInd;
Kiet Lam64c1b492013-07-12 13:56:44 +05309176 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
krunal soni587bf012014-02-04 12:35:11 -08009177
9178
9179 if (NULL == pSirMsg)
9180 { smsLog(pMac, LOGE, FL("pSirMsg is NULL"));
9181 return;
9182 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009183 switch( pSirMsg->messageType )
9184 {
9185 case eWNI_SME_ASSOC_IND:
9186 {
9187 tCsrRoamSession *pSession;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009188 smsLog( pMac, LOG1, FL("ASSOCIATION Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009189 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
9190 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
9191 if( HAL_STATUS_SUCCESS( status ) )
9192 {
9193 pSession = CSR_GET_SESSION(pMac, sessionId);
9194
Jeff Johnson32d95a32012-09-10 13:15:23 -07009195 if(!pSession)
9196 {
9197 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9198 return;
9199 }
9200
Jeff Johnson295189b2012-06-20 16:38:30 -07009201 pRoamInfo = &roamInfo;
9202
9203 // Required for indicating the frames to upper layer
9204 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
9205 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
9206
9207 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
9208 pRoamInfo->beaconLength = pAssocInd->beaconLength;
9209 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
9210 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9211
9212 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
9213 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
9214 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
9215
9216 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
9217 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05309218 vos_mem_copy(pRoamInfo->peerMac, pAssocInd->peerMacAddr,
9219 sizeof(tSirMacAddr));
9220 vos_mem_copy(&pRoamInfo->bssid, pAssocInd->bssId,
9221 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009222 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
9223 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07009224 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -07009225 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
9226 {
9227 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
9228 {
9229 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
9230 pSession->pConnectBssDesc,
9231 &(pRoamInfo->peerMac),
9232 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9233 pRoamInfo->fAuthRequired = FALSE;
9234 }
9235 else
9236 {
9237 pRoamInfo->fAuthRequired = TRUE;
9238 }
9239 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
9240 if (!HAL_STATUS_SUCCESS(status))
9241 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
9242 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009243 /* Send Association completion message to PE */
9244 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
9245
9246 /* send a message to CSR itself just to avoid the EAPOL frames going
9247 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -07009248 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
9249 {
9250 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9251 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009252 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
9253 {
9254 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
9255 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
9256 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9257 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009258 }
9259 }
9260 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009261 case eWNI_SME_DISASSOC_IND:
Jeff Johnson295189b2012-06-20 16:38:30 -07009262 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309263 // Check if AP dis-associated us because of MIC failure. If so,
9264 // then we need to take action immediately and not wait till the
9265 // the WmStatusChange requests is pushed and processed
9266 tSmeCmd *pCommand;
9267
9268 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
9269 status = csrRoamGetSessionIdFromBSSID( pMac,
9270 (tCsrBssid *)pDisassocInd->bssId, &sessionId );
9271 if( HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009272 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309273 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC"
9274 " for session %d "), sessionId);
9275 smsLog( pMac, LOGE, FL("DISASSOCIATION from peer ="
9276 MAC_ADDRESS_STR " "
9277 " reason = %d status = %d "),
9278 MAC_ADDR_ARRAY(pDisassocInd->peerMacAddr),
9279 pDisassocInd->reasonCode,
9280 pDisassocInd->statusCode);
9281 // If we are in neighbor preauth done state then on receiving
9282 // disassoc or deauth we dont roam instead we just disassoc
9283 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009284 // This happens for ESE and 11r FT connections ONLY.
Agarwal Ashish4f616132013-12-30 23:32:50 +05309285#ifdef WLAN_FEATURE_VOWIFI_11R
9286 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9287 {
9288 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9289 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009290#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009291#ifdef FEATURE_WLAN_ESE
9292 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Agarwal Ashish4f616132013-12-30 23:32:50 +05309293 {
9294 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9295 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009296#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009297#ifdef FEATURE_WLAN_LFR
Agarwal Ashish4f616132013-12-30 23:32:50 +05309298 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
9299 {
9300 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9301 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009302#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +05309303 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009304
Agarwal Ashish4f616132013-12-30 23:32:50 +05309305 if (!pSession)
9306 {
9307 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9308 return;
9309 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07009310
Agarwal Ashish4f616132013-12-30 23:32:50 +05309311 if ( csrIsConnStateInfra( pMac, sessionId ) )
9312 {
9313 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9314 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009315#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Agarwal Ashish4f616132013-12-30 23:32:50 +05309316 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009317#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +05309318 csrRoamLinkDown(pMac, sessionId);
9319 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
9320 if (CSR_IS_INFRA_AP(&pSession->connectedProfile))
9321 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309322 pRoamInfo = &roamInfo;
9323 pRoamInfo->statusCode = pDisassocInd->statusCode;
9324 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9325 pRoamInfo->staId = (tANI_U8)pDisassocInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009326
Agarwal Ashish4f616132013-12-30 23:32:50 +05309327 vos_mem_copy(pRoamInfo->peerMac, pDisassocInd->peerMacAddr,
9328 sizeof(tSirMacAddr));
9329 vos_mem_copy(&pRoamInfo->bssid, pDisassocInd->bssId,
9330 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009331
Agarwal Ashish4f616132013-12-30 23:32:50 +05309332 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9333 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DISASSOC_IND);
Jeff Johnson295189b2012-06-20 16:38:30 -07009334
Agarwal Ashish4f616132013-12-30 23:32:50 +05309335 /*
9336 * STA/P2P client got disassociated so remove any pending deauth
9337 * commands in sme pending list
9338 */
Kaushik, Sushant488df382014-03-05 11:43:47 +05309339 pCommand = csrGetCommandBuffer(pMac);
9340 if (NULL == pCommand)
9341 {
9342 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
9343 status = eHAL_STATUS_RESOURCES;
9344 return;
9345 }
Agarwal Ashish4f616132013-12-30 23:32:50 +05309346 pCommand->command = eSmeCommandRoam;
9347 pCommand->sessionId = (tANI_U8)sessionId;
9348 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
9349 vos_mem_copy(pCommand->u.roamCmd.peerMac,
9350 pDisassocInd->peerMacAddr,
9351 sizeof(tSirMacAddr));
9352 csrRoamRemoveDuplicateCommand(pMac, sessionId, pCommand, eCsrForcedDeauthSta);
9353 csrReleaseCommand( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07009354
Agarwal Ashish4f616132013-12-30 23:32:50 +05309355 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009356 }
Agarwal Ashish4f616132013-12-30 23:32:50 +05309357 else
9358 {
9359 smsLog(pMac, LOGE, FL(" Session Id not found for BSSID " MAC_ADDRESS_STR),
9360 MAC_ADDR_ARRAY(pDisassocInd->bssId));
9361 }
Kiet Lam82004c62013-11-11 13:24:28 +05309362 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009363 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009364 case eWNI_SME_DEAUTH_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009365 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009366 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
9367 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
9368 if( HAL_STATUS_SUCCESS( status ) )
9369 {
9370 // If we are in neighbor preauth done state then on receiving
9371 // disassoc or deauth we dont roam instead we just disassoc
9372 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009373 // This happens for ESE and 11r FT connections ONLY.
Jeff Johnson295189b2012-06-20 16:38:30 -07009374#ifdef WLAN_FEATURE_VOWIFI_11R
9375 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9376 {
9377 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9378 }
9379#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009380#ifdef FEATURE_WLAN_ESE
9381 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson295189b2012-06-20 16:38:30 -07009382 {
9383 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9384 }
9385#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009386#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05309387 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009388 {
9389 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9390 }
9391#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009392 pSession = CSR_GET_SESSION( pMac, sessionId );
9393
Jeff Johnson32d95a32012-09-10 13:15:23 -07009394 if(!pSession)
9395 {
9396 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9397 return;
9398 }
9399
Jeff Johnson295189b2012-06-20 16:38:30 -07009400 if ( csrIsConnStateInfra( pMac, sessionId ) )
9401 {
9402 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9403 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009404#ifndef WLAN_MDM_CODE_REDUCTION_OPT
9405 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
9406#endif
9407 csrRoamLinkDown(pMac, sessionId);
9408 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07009409 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
9410 {
9411
9412 pRoamInfo = &roamInfo;
9413
9414 pRoamInfo->statusCode = pDeauthInd->statusCode;
9415 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9416
9417 pRoamInfo->staId = (tANI_U8)pDeauthInd->staId;
9418
Kiet Lam64c1b492013-07-12 13:56:44 +05309419 vos_mem_copy(pRoamInfo->peerMac, pDeauthInd->peerMacAddr,
9420 sizeof(tSirMacAddr));
9421 vos_mem_copy(&pRoamInfo->bssid, pDeauthInd->bssId,
9422 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009423
9424 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DEAUTH_IND);
9425 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009426 }
9427 break;
9428
9429 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 -08009430 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009431 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
9432 //Update with the new channel id.
9433 //The channel id is hidden in the statusCode.
9434 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
9435 if( HAL_STATUS_SUCCESS( status ) )
9436 {
9437 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009438 if(!pSession)
9439 {
9440 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9441 return;
9442 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009443 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
9444 if(pSession->pConnectBssDesc)
9445 {
9446 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
9447 }
9448 }
9449 break;
9450
9451 case eWNI_SME_DEAUTH_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009452 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009453 {
9454 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
9455 sessionId = pDeauthRsp->sessionId;
9456 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9457 {
9458 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009459 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9460 {
9461 pRoamInfo = &roamInfo;
9462 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309463 vos_mem_copy(pRoamInfo->peerMac, pDeauthRsp->peerMacAddr,
9464 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009465 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9466 pRoamInfo->statusCode = pDeauthRsp->statusCode;
9467 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9468 }
9469 }
9470 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009471 break;
9472
9473 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009474 /* session id is invalid here so cant use it to access the array curSubstate as index */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009475 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -07009476 {
9477 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
9478 sessionId = pDisassocRsp->sessionId;
9479 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9480 {
9481 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009482 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9483 {
9484 pRoamInfo = &roamInfo;
9485 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309486 vos_mem_copy(pRoamInfo->peerMac, pDisassocRsp->peerMacAddr,
9487 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009488 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9489 pRoamInfo->statusCode = pDisassocRsp->statusCode;
9490 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9491 }
9492 }
9493 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009494 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009495 case eWNI_SME_MIC_FAILURE_IND:
9496 {
9497 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
9498 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
9499 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Leo Chang9b01ad92013-09-12 17:26:56 -07009500
9501 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
9502 if( HAL_STATUS_SUCCESS( status ) )
9503 {
Kiet Lamf2f201e2013-11-16 21:24:16 +05309504 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Leo Chang9b01ad92013-09-12 17:26:56 -07009505 roamInfo.u.pMICFailureInfo = &pMicInd->info;
9506 pRoamInfo = &roamInfo;
9507 if(pMicInd->info.multicast)
9508 {
9509 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
9510 }
9511 else
9512 {
9513 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
9514 }
9515 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
9516 }
9517
Jeff Johnson295189b2012-06-20 16:38:30 -07009518#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9519 {
lukez3c809222013-05-03 10:23:02 -07009520 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07009521 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009522 if(!pSession)
9523 {
9524 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9525 return;
9526 }
lukez3c809222013-05-03 10:23:02 -07009527
Kiet Lam64c1b492013-07-12 13:56:44 +05309528 vos_mem_set(&secEvent, sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009529 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
9530 secEvent.encryptionModeMulticast =
9531 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9532 secEvent.encryptionModeUnicast =
9533 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9534 secEvent.authMode =
9535 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309536 vos_mem_copy(secEvent.bssid,
9537 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009538 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
9539 }
9540#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009541 }
9542 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009543 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
9544 {
9545 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
9546 tCsrRoamInfo roamInfo;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009547 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009548
9549 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
9550 if( HAL_STATUS_SUCCESS( status ) )
9551 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309552 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009553 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
9554 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
9555 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
9556 }
9557 }
9558 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009559
Jeff Johnson295189b2012-06-20 16:38:30 -07009560 case eWNI_SME_WM_STATUS_CHANGE_NTF:
9561 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
9562 switch( pStatusChangeMsg->statusChangeCode )
9563 {
9564 case eSIR_SME_IBSS_ACTIVE:
9565 sessionId = csrFindIbssSession( pMac );
9566 if( CSR_SESSION_ID_INVALID != sessionId )
9567 {
9568 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009569 if(!pSession)
9570 {
9571 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9572 return;
9573 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009574 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
9575 if(pSession->pConnectBssDesc)
9576 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309577 vos_mem_copy(&roamInfo.bssid,
9578 pSession->pConnectBssDesc->bssId,
9579 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009580 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
9581 pRoamInfo = &roamInfo;
9582 }
9583 else
9584 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009585 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009586 }
9587 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
9588 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9589 }
9590 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009591 case eSIR_SME_IBSS_INACTIVE:
9592 sessionId = csrFindIbssSession( pMac );
9593 if( CSR_SESSION_ID_INVALID != sessionId )
9594 {
9595 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009596 if(!pSession)
9597 {
9598 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9599 return;
9600 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009601 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
9602 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
9603 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9604 }
9605 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009606 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
9607 sessionId = csrFindIbssSession( pMac );
9608 if( CSR_SESSION_ID_INVALID != sessionId )
9609 {
9610 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009611 if(!pSession)
9612 {
9613 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9614 return;
9615 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009616 // update the connection state information
9617 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009618#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9619 {
9620 vos_log_ibss_pkt_type *pIbssLog;
9621 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -07009622 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9623 if(pIbssLog)
9624 {
9625 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
9626 if(pNewBss)
9627 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309628 vos_mem_copy(pIbssLog->bssid, pNewBss->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009629 if(pNewBss->ssId.length)
9630 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309631 vos_mem_copy(pIbssLog->ssid, pNewBss->ssId.ssId,
9632 pNewBss->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07009633 }
9634 pIbssLog->operatingChannel = pNewBss->channelNumber;
9635 }
9636 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
9637 {
9638 //***U8 is not enough for beacon interval
9639 pIbssLog->beaconInterval = (v_U8_t)bi;
9640 }
9641 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9642 }
9643 }
9644#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009645 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009646
9647 if ((eCSR_ENCRYPT_TYPE_NONE ==
9648 pSession->connectedProfile.EncryptionType ))
9649 {
9650 csrRoamIssueSetContextReq( pMac, sessionId,
9651 pSession->connectedProfile.EncryptionType,
9652 pSession->pConnectBssDesc,
9653 &Broadcastaddr,
9654 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
9655 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009656 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
9657 roamStatus = eCSR_ROAM_IBSS_IND;
Kiet Lam64c1b492013-07-12 13:56:44 +05309658 vos_mem_copy(&roamInfo.bssid, &pNewBss->bssId,
9659 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009660 pRoamInfo = &roamInfo;
9661 //This BSSID is th ereal BSSID, let's save it
9662 if(pSession->pConnectBssDesc)
9663 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309664 vos_mem_copy(pSession->pConnectBssDesc->bssId,
9665 &pNewBss->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009666 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009667 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009668 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Jeff Johnson295189b2012-06-20 16:38:30 -07009669 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009670 // detection by LIM that the capabilities of the associated AP have changed.
9671 case eSIR_SME_AP_CAPS_CHANGED:
9672 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009673 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED");
Jeff Johnson295189b2012-06-20 16:38:30 -07009674 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
9675 if( HAL_STATUS_SUCCESS( status ) )
9676 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009677 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
9678 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309679 (eCSR_ROAM_SUBSTATE_NONE == pMac->roam.curSubState[sessionId]) ||
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009680 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
9681 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
9682 )
9683 {
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309684 smsLog(pMac, LOGW, "Calling csrRoamDisconnectInternal");
9685 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009686 }
9687 else
9688 {
9689 smsLog(pMac, LOGW,
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05309690 FL("Skipping csrScanForCapabilityChange as "
9691 "CSR is in state %s and sub-state %s"),
9692 macTraceGetcsrRoamState(
9693 pMac->roam.curState[sessionId]),
9694 macTraceGetcsrRoamSubState(
9695 pMac->roam.curSubState[sessionId]));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309696 /* We ignore the caps change event if CSR is not in full connected state.
9697 * Send one event to PE to reset limSentCapsChangeNtf
9698 * Once limSentCapsChangeNtf set 0, lim can send sub sequent CAPS change event
9699 * otherwise lim cannot send any CAPS change events to SME */
9700 csrSendResetApCapsChanged(pMac, &pApNewCaps->bssId);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009701 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009702 }
9703 break;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309704
Jeff Johnson295189b2012-06-20 16:38:30 -07009705 default:
9706 roamStatus = eCSR_ROAM_FAILED;
9707 result = eCSR_ROAM_RESULT_NONE;
9708 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009709 } // end switch on statusChangeCode
9710 if(eCSR_ROAM_RESULT_NONE != result)
9711 {
9712 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
9713 }
9714 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009715 case eWNI_SME_IBSS_NEW_PEER_IND:
9716 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07009717#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9718 {
9719 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07009720 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9721 if(pIbssLog)
9722 {
9723 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309724 vos_mem_copy(pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009725 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9726 }
9727 }
9728#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009729 sessionId = csrFindIbssSession( pMac );
9730 if( CSR_SESSION_ID_INVALID != sessionId )
9731 {
9732 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009733
9734 if(!pSession)
9735 {
9736 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9737 return;
9738 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009739 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
9740 if(pSession->pConnectBssDesc)
9741 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309742 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
9743 sizeof(tCsrBssid));
9744 vos_mem_copy(&roamInfo.bssid, pSession->pConnectBssDesc->bssId,
9745 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009746 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
9747 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309748 roamInfo.pbFrames = vos_mem_malloc((pIbssPeerInd->mesgLen
9749 - sizeof(tSmeIbssPeerInd)));
9750 if ( NULL == roamInfo.pbFrames )
9751 status = eHAL_STATUS_FAILURE;
9752 else
9753 status = eHAL_STATUS_SUCCESS;
9754 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07009755 {
9756 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
Kiet Lam64c1b492013-07-12 13:56:44 +05309757 vos_mem_copy(roamInfo.pbFrames,
9758 ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
9759 roamInfo.nBeaconLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07009760 }
9761 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9762 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9763 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05309764 roamInfo.pBssDesc = vos_mem_malloc(pSession->pConnectBssDesc->length);
9765 if ( NULL == roamInfo.pBssDesc )
9766 status = eHAL_STATUS_FAILURE;
9767 else
9768 status = eHAL_STATUS_SUCCESS;
9769 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07009770 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309771 vos_mem_copy(roamInfo.pBssDesc,
9772 pSession->pConnectBssDesc,
9773 pSession->pConnectBssDesc->length);
Jeff Johnson295189b2012-06-20 16:38:30 -07009774 }
9775 if(HAL_STATUS_SUCCESS(status))
9776 {
9777 pRoamInfo = &roamInfo;
9778 }
9779 else
9780 {
9781 if(roamInfo.pbFrames)
9782 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309783 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -07009784 }
9785 if(roamInfo.pBssDesc)
9786 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309787 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07009788 }
9789 }
9790 }
9791 else
9792 {
9793 pRoamInfo = &roamInfo;
9794 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009795 if ((eCSR_ENCRYPT_TYPE_NONE ==
9796 pSession->connectedProfile.EncryptionType ))
9797 {
9798 csrRoamIssueSetContextReq( pMac, sessionId,
9799 pSession->connectedProfile.EncryptionType,
9800 pSession->pConnectBssDesc,
9801 &(pIbssPeerInd->peerAddr),
9802 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9803 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009804 }
9805 else
9806 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009807 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009808 }
9809 //send up the sec type for the new peer
9810 if (pRoamInfo)
9811 {
9812 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9813 }
9814 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9815 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
9816 if(pRoamInfo)
9817 {
9818 if(roamInfo.pbFrames)
9819 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309820 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -07009821 }
9822 if(roamInfo.pBssDesc)
9823 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309824 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07009825 }
9826 }
9827 }
9828 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009829 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
9830 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
9831 sessionId = csrFindIbssSession( pMac );
9832 if( CSR_SESSION_ID_INVALID != sessionId )
9833 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009834#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9835 {
9836 vos_log_ibss_pkt_type *pIbssLog;
9837
9838 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9839 if(pIbssLog)
9840 {
9841 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
9842 if(pIbssPeerInd)
9843 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309844 vos_mem_copy(pIbssLog->peerMacAddr,
9845 &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009846 }
9847 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9848 }
9849 }
9850#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009851 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM");
Jeff Johnson295189b2012-06-20 16:38:30 -07009852 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9853 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9854 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05309855 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
9856 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009857 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9858 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
9859 }
9860 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009861 case eWNI_SME_SETCONTEXT_RSP:
9862 {
9863 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
9864 tListElem *pEntry;
9865 tSmeCmd *pCommand;
9866
9867 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9868 if ( pEntry )
9869 {
9870 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9871 if ( eSmeCommandSetKey == pCommand->command )
9872 {
9873 sessionId = pCommand->sessionId;
9874 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009875
9876 if(!pSession)
9877 {
9878 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9879 return;
9880 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009881
9882#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9883 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
9884 {
9885 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +05309886 vos_mem_set(&setKeyEvent,
9887 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009888 if( pRsp->peerMacAddr[0] & 0x01 )
9889 {
9890 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
9891 }
9892 else
9893 {
9894 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
9895 }
9896 setKeyEvent.encryptionModeMulticast =
9897 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9898 setKeyEvent.encryptionModeUnicast =
9899 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309900 vos_mem_copy(setKeyEvent.bssid,
9901 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009902 setKeyEvent.authMode =
9903 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -07009904 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009905 {
9906 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9907 }
9908 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9909 }
9910#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
9911 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
9912 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009913 csrRoamStopWaitForKeyTimer( pMac );
9914
Jeff Johnson295189b2012-06-20 16:38:30 -07009915 //We are done with authentication, whethere succeed or not
9916 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009917 //We do it here because this linkup function is not called after association
9918 //when a key needs to be set.
9919 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
9920 {
9921 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
9922 }
9923 }
Jeff Johnson43971f52012-07-17 12:26:56 -07009924 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009925 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309926 vos_mem_copy(&roamInfo.peerMac,
9927 &pRsp->peerMacAddr, sizeof(tCsrBssid));
Jeff Johnsone7245742012-09-05 17:12:55 -07009928 //Make sure we install the GTK before indicating to HDD as authenticated
9929 //This is to prevent broadcast packets go out after PTK and before GTK.
Kiet Lam64c1b492013-07-12 13:56:44 +05309930 if ( vos_mem_compare( &Broadcastaddr, pRsp->peerMacAddr,
9931 sizeof(tSirMacAddr) ) )
Jeff Johnsone7245742012-09-05 17:12:55 -07009932 {
Yathish9f22e662012-12-10 14:21:35 -08009933#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
9934 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
9935 {
9936 tpSirSetActiveModeSetBncFilterReq pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +05309937 pMsg = vos_mem_malloc(sizeof(tSirSetActiveModeSetBncFilterReq));
Yathish9f22e662012-12-10 14:21:35 -08009938 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
9939 pMsg->length = pal_cpu_to_be16(sizeof( tANI_U8));
9940 pMsg->seesionId = sessionId;
9941 status = palSendMBMessage(pMac->hHdd, pMsg );
9942 }
9943#endif
Sandeep Puligilla332ea912014-02-04 00:16:24 +05309944 /* OBSS SCAN Indication will be sent to Firmware to start OBSS Scan */
9945 if( CSR_IS_CHANNEL_24GHZ(pSession->connectedProfile.operationChannel)
9946 && IS_HT40_OBSS_SCAN_FEATURE_ENABLE )
9947 {
9948 tpSirSmeHT40OBSSScanInd pMsg;
9949 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSScanInd));
9950 pMsg->messageType =
9951 pal_cpu_to_be16((tANI_U16)eWNI_SME_HT40_OBSS_SCAN_IND);
9952 pMsg->length =
9953 pal_cpu_to_be16(sizeof( tANI_U8));
9954 pMsg->seesionId = sessionId;
9955 status = palSendMBMessage(pMac->hHdd,
9956 pMsg );
9957 }
9958 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -07009959 }
9960 else
9961 {
9962 result = eCSR_ROAM_RESULT_NONE;
9963 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009964 pRoamInfo = &roamInfo;
9965 }
9966 else
9967 {
9968 result = eCSR_ROAM_RESULT_FAILURE;
Arif Hussaina7c8e412013-11-20 11:06:42 -08009969 smsLog(pMac, LOGE, "CSR: Roam Completion setkey "
9970 "command failed(%d) PeerMac "MAC_ADDRESS_STR,
9971 pRsp->statusCode, MAC_ADDR_ARRAY(pRsp->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009972 }
9973 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
9974 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -07009975 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
9976 // can go ahead and initiate the TSPEC if any are pending
9977 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009978#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07009979 //Send Adjacent AP repot to new AP.
9980 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
9981 pSession->isPrevApInfoValid &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009982 pSession->connectedProfile.isESEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -07009983 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009984#ifdef FEATURE_WLAN_ESE_UPLOAD
9985 csrSendEseAdjacentApRepInd(pMac, pSession);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009986#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009987 csrEseSendAdjacentApRepMsg(pMac, pSession);
Jeff Johnson295189b2012-06-20 16:38:30 -07009988#endif
9989 pSession->isPrevApInfoValid = FALSE;
9990 }
9991#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009992 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
9993 {
9994 csrReleaseCommandSetKey( pMac, pCommand );
9995 }
9996 }
9997 else
9998 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009999 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010000 }
10001 }
10002 else
10003 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010004 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010005 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010006 smeProcessPendingQueue( pMac );
10007 }
10008 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010009 case eWNI_SME_REMOVEKEY_RSP:
10010 {
10011 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
10012 tListElem *pEntry;
10013 tSmeCmd *pCommand;
10014
10015 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10016 if ( pEntry )
10017 {
10018 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10019 if ( eSmeCommandRemoveKey == pCommand->command )
10020 {
10021 sessionId = pCommand->sessionId;
10022 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010023
10024 if(!pSession)
10025 {
10026 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10027 return;
10028 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010029#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10030 {
10031 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053010032 vos_mem_set(&removeKeyEvent,
10033 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010034 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
10035 removeKeyEvent.encryptionModeMulticast =
10036 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10037 removeKeyEvent.encryptionModeUnicast =
10038 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010039 vos_mem_copy( removeKeyEvent.bssid,
10040 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010041 removeKeyEvent.authMode =
10042 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -070010043 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010044 {
10045 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10046 }
10047 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
10048 }
10049#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -070010050 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010051 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010052 vos_mem_copy(&roamInfo.peerMac, &pRsp->peerMacAddr,
10053 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010054 result = eCSR_ROAM_RESULT_NONE;
10055 pRoamInfo = &roamInfo;
10056 }
10057 else
10058 {
10059 result = eCSR_ROAM_RESULT_FAILURE;
10060 }
10061 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10062 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
10063 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10064 {
10065 csrReleaseCommandRemoveKey( pMac, pCommand );
10066 }
10067 }
10068 else
10069 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010070 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010071 }
10072 }
10073 else
10074 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010075 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010076 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010077 smeProcessPendingQueue( pMac );
10078 }
10079 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010080 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010081 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010082 csrRoamStatsRspProcessor( pMac, pSirMsg );
10083 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010084#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080010085 case eWNI_SME_GET_ROAM_RSSI_RSP:
10086 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
10087 csrRoamRssiRspProcessor( pMac, pSirMsg );
10088 break;
10089#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010090#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010091 case eWNI_SME_GET_TSM_STATS_RSP:
10092 smsLog( pMac, LOG2, FL("TSM Stats rsp from PE"));
10093 csrTsmStatsRspProcessor( pMac, pSirMsg );
10094 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010095#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -070010096 case eWNI_SME_GET_RSSI_REQ:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010097 smsLog( pMac, LOG2, FL("GetRssiReq from self"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010098 csrUpdateRssi( pMac, pSirMsg );
10099 break;
10100
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053010101 case eWNI_SME_GET_SNR_REQ:
10102 smsLog( pMac, LOG2, FL("GetSnrReq from self"));
10103 csrUpdateSnr(pMac, pSirMsg);
10104 break;
10105
Jeff Johnson295189b2012-06-20 16:38:30 -070010106#ifdef WLAN_FEATURE_VOWIFI_11R
10107 case eWNI_SME_FT_PRE_AUTH_RSP:
10108 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
10109 break;
10110#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010111 case eWNI_SME_MAX_ASSOC_EXCEEDED:
10112 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010113 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 -070010114 sessionId = pSmeMaxAssocInd->sessionId;
10115 roamInfo.sessionId = sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053010116 vos_mem_copy(&roamInfo.peerMac, pSmeMaxAssocInd->peerMac,
10117 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010118 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
10119 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
10120 break;
10121
10122 case eWNI_SME_BTAMP_LOG_LINK_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010123 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010124 btampEstablishLogLinkHdlr( pSirMsg );
10125 break;
Jeff Johnsone7245742012-09-05 17:12:55 -070010126 case eWNI_SME_RSSI_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010127 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread"));
Jeff Johnsone7245742012-09-05 17:12:55 -070010128 csrRoamRssiIndHdlr( pMac, pSirMsg );
10129 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010130#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
10131 case eWNI_SME_CANDIDATE_FOUND_IND:
10132 smsLog( pMac, LOG2, FL("Candidate found indication from PE"));
10133 csrNeighborRoamCandidateFoundIndHdlr( pMac, pSirMsg );
10134 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070010135 case eWNI_SME_HANDOFF_REQ:
10136 smsLog( pMac, LOG2, FL("Handoff Req from self"));
10137 csrNeighborRoamHandoffReqHdlr( pMac, pSirMsg );
10138 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010139#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010140
10141 default:
10142 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010143 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -070010144}
10145
Jeff Johnson295189b2012-06-20 16:38:30 -070010146void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
10147 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
10148{
10149 if(pSession)
10150 {
10151 if(pSession->bRefAssocStartCnt)
10152 {
10153 pSession->bRefAssocStartCnt--;
10154 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
10155 //Need to call association_completion because there is an assoc_start pending.
10156 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
10157 eCSR_ROAM_ASSOCIATION_COMPLETION,
10158 eCSR_ROAM_RESULT_FAILURE);
10159 }
10160 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
10161 }
10162 else
10163 {
10164 smsLog(pMac, LOGW, FL(" pSession is NULL"));
10165 }
10166}
10167
10168
10169eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
10170{
10171 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010172 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
10173 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
10174 {
10175 status = csrScanRequestLostLink1( pMac, sessionId );
10176 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010177 return(status);
10178}
10179
Jeff Johnson295189b2012-06-20 16:38:30 -070010180//return a boolean to indicate whether roaming completed or continue.
10181tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
10182 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
10183{
10184 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
10185 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
10186 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10187 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010188 if(!pSession)
10189 {
10190 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10191 return eANI_BOOLEAN_FALSE;
10192 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010193 //Check whether time is up
10194 if(pSession->fCancelRoaming || fForce ||
10195 ((curTime - pSession->roamingStartTime) > roamTime) ||
10196 eCsrReassocRoaming == pSession->roamingReason ||
10197 eCsrDynamicRoaming == pSession->roamingReason)
10198 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010199 smsLog(pMac, LOGW, FL(" indicates roaming completion"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010200 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
10201 {
10202 //roaming is cancelled, tell HDD to indicate disconnect
10203 //Because LIM overload deauth_ind for both deauth frame and missed beacon
10204 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
10205 //to be eSIR_BEACON_MISSED
10206 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
10207 {
10208 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10209 }
10210 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
10211 {
10212 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
10213 }
10214 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
10215 {
10216 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
10217 }
10218 else
10219 {
10220 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10221 }
10222 }
10223 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10224 pSession->roamingReason = eCsrNotRoaming;
10225 }
10226 else
10227 {
10228 pSession->roamResult = roamResult;
10229 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
10230 {
10231 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10232 pSession->roamingReason = eCsrNotRoaming;
10233 }
10234 else
10235 {
10236 fCompleted = eANI_BOOLEAN_FALSE;
10237 }
10238 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010239 return(fCompleted);
10240}
10241
Jeff Johnson295189b2012-06-20 16:38:30 -070010242void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
10243{
10244 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010245
10246 if(!pSession)
10247 {
10248 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10249 return;
10250 }
10251
Jeff Johnson295189b2012-06-20 16:38:30 -070010252 if(CSR_IS_ROAMING(pSession))
10253 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010254 smsLog(pMac, LOGW, " Cancelling roaming");
Jeff Johnson295189b2012-06-20 16:38:30 -070010255 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
10256 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
10257 {
10258 //No need to do anything in here because the handler takes care of it
10259 }
10260 else
10261 {
10262 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
10263 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
10264 //Roaming is stopped after here
10265 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
10266 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053010267 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010268 csrRoamStopRoamingTimer(pMac, sessionId);
10269 }
10270 }
10271}
10272
Jeff Johnson295189b2012-06-20 16:38:30 -070010273void csrRoamRoamingTimerHandler(void *pv)
10274{
10275 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10276 tpAniSirGlobal pMac = pInfo->pMac;
10277 tANI_U32 sessionId = pInfo->sessionId;
10278 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010279
10280 if(!pSession)
10281 {
10282 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10283 return;
10284 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010285
10286 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
10287 {
10288 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
10289 {
10290 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
10291 pSession->roamingReason = eCsrNotRoaming;
10292 }
10293 }
10294}
10295
Jeff Johnson295189b2012-06-20 16:38:30 -070010296eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
10297{
10298 eHalStatus status;
10299 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010300
10301 if(!pSession)
10302 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010303 smsLog(pMac, LOGE, FL(" session %d not found"), sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -070010304 return eHAL_STATUS_FAILURE;
10305 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010306
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010307 smsLog(pMac, LOG1, " csrScanStartRoamingTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070010308 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010309 status = vos_timer_start(&pSession->hTimerRoaming, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010310
10311 return (status);
10312}
10313
Jeff Johnson295189b2012-06-20 16:38:30 -070010314eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
10315{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010316 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerRoaming));
Jeff Johnson295189b2012-06-20 16:38:30 -070010317}
10318
Jeff Johnson295189b2012-06-20 16:38:30 -070010319void csrRoamWaitForKeyTimeOutHandler(void *pv)
10320{
10321 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10322 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010323 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080010324 eHalStatus status = eHAL_STATUS_FAILURE;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010325
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010326 smsLog(pMac, LOGW, FL("WaitForKey timer expired in state=%s sub-state=%s"),
10327 macTraceGetNeighbourRoamState(
10328 pMac->roam.neighborRoamInfo.neighborRoamState),
10329 macTraceGetcsrRoamSubState(
10330 pMac->roam.curSubState[pInfo->sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010331
Jeff Johnson295189b2012-06-20 16:38:30 -070010332 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
10333 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010334#ifdef FEATURE_WLAN_LFR
10335 if (csrNeighborRoamIsHandoffInProgress(pMac))
10336 {
10337 /*
10338 * Enable heartbeat timer when hand-off is in progress
10339 * and Key Wait timer expired.
10340 */
10341 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010342 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010343 pMac->roam.configParam.HeartbeatThresh24);
10344 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10345 pMac->roam.configParam.HeartbeatThresh24,
10346 NULL, eANI_BOOLEAN_FALSE);
10347 }
10348#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010349 smsLog(pMac, LOGW, " SME pre-auth state timeout. ");
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010350
Jeff Johnson295189b2012-06-20 16:38:30 -070010351 //Change the substate so command queue is unblocked.
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010352 if (CSR_ROAM_SESSION_MAX > pInfo->sessionId)
10353 {
10354 csrRoamSubstateChange(pMac, eCSR_ROAM_SUBSTATE_NONE,
10355 pInfo->sessionId);
10356 }
10357
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010358 if (pSession)
10359 {
10360 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
10361 {
10362 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10363 smeProcessPendingQueue(pMac);
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080010364 if( (pSession->connectedProfile.AuthType ==
10365 eCSR_AUTH_TYPE_SHARED_KEY) &&
10366 ( (pSession->connectedProfile.EncryptionType ==
10367 eCSR_ENCRYPT_TYPE_WEP40) ||
10368 (pSession->connectedProfile.EncryptionType ==
10369 eCSR_ENCRYPT_TYPE_WEP104) ))
10370 {
10371 status = sme_AcquireGlobalLock( &pMac->sme );
10372 if ( HAL_STATUS_SUCCESS( status ) )
10373 {
10374 csrRoamDisconnect( pMac, pInfo->sessionId,
10375 eCSR_DISCONNECT_REASON_UNSPECIFIED );
10376 sme_ReleaseGlobalLock( &pMac->sme );
10377 }
10378 }
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010379 }
10380 else
10381 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010382 smsLog(pMac, LOGW, "%s: could not post link up",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010383 __func__);
10384 }
10385 }
10386 else
10387 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010388 smsLog(pMac, LOGW, "%s: session not found", __func__);
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010389 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010390 }
10391
10392}
10393
Jeff Johnson295189b2012-06-20 16:38:30 -070010394eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
10395{
10396 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010397#ifdef FEATURE_WLAN_LFR
10398 if (csrNeighborRoamIsHandoffInProgress(pMac))
10399 {
10400 /* Disable heartbeat timer when hand-off is in progress */
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010401 smsLog(pMac, LOG2, FL("disabling HB timer in state=%s sub-state=%s"),
10402 macTraceGetNeighbourRoamState(
10403 pMac->roam.neighborRoamInfo.neighborRoamState),
10404 macTraceGetcsrRoamSubState(
10405 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]
10406 ));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010407 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
10408 }
10409#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010410 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010411 status = vos_timer_start(&pMac->roam.hTimerWaitForKey, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010412
10413 return (status);
10414}
10415
Jeff Johnson295189b2012-06-20 16:38:30 -070010416eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
10417{
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010418 smsLog(pMac, LOG2, FL("WaitForKey timer stopped in state=%s sub-state=%s"),
10419 macTraceGetNeighbourRoamState(
10420 pMac->roam.neighborRoamInfo.neighborRoamState),
10421 macTraceGetcsrRoamSubState(
10422 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010423#ifdef FEATURE_WLAN_LFR
10424 if (csrNeighborRoamIsHandoffInProgress(pMac))
10425 {
10426 /*
10427 * Enable heartbeat timer when hand-off is in progress
10428 * and Key Wait timer got stopped for some reason
10429 */
10430 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010431 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010432 pMac->roam.configParam.HeartbeatThresh24);
10433 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10434 pMac->roam.configParam.HeartbeatThresh24,
10435 NULL, eANI_BOOLEAN_FALSE);
10436 }
10437#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010438 return (vos_timer_stop(&pMac->roam.hTimerWaitForKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070010439}
10440
Jeff Johnson295189b2012-06-20 16:38:30 -070010441void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
10442 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
10443{
10444 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
10445 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010446 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
10447 /* To silence the KW tool Null chaeck is added */
10448 if(!pSession)
10449 {
10450 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10451 return;
10452 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010453
10454 if(pCommand)
10455 {
10456 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010457 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070010458 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010459 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
10460 {
10461 //if success, force roaming completion
10462 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
10463 }
10464 else
10465 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010466 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010467 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d"), roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -070010468 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
10469 }
10470}
10471
Jeff Johnson295189b2012-06-20 16:38:30 -070010472eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
10473{
10474 eHalStatus status = eHAL_STATUS_SUCCESS;
10475 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
10476 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
10477 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
10478 tCsrRoamInfo *pRoamInfo = NULL;
10479 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010480 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -070010481 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010482 /* To silence the KW tool Null chaeck is added */
10483 if(!pSession)
10484 {
10485 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10486 return eHAL_STATUS_FAILURE;
10487 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010488 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010489 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -070010490 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
10491 if ( eWNI_SME_DISASSOC_IND == type )
10492 {
10493 result = eCSR_ROAM_RESULT_DISASSOC_IND;
10494 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
10495 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010496 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010497 }
10498 else if ( eWNI_SME_DEAUTH_IND == type )
10499 {
10500 result = eCSR_ROAM_RESULT_DEAUTH_IND;
10501 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
10502 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Madan Mohan Koyyalamudi6a808932012-11-06 16:05:54 -080010503 /* Convert into proper reason code */
10504 pSession->joinFailStatusCode.reasonCode =
10505 (pDeauthIndMsg->reasonCode == eSIR_BEACON_MISSED) ?
Agarwal Ashish838f1f32013-03-11 20:54:52 +053010506 0 : pDeauthIndMsg->reasonCode;
10507 /* cfg layer expects 0 as reason code if
10508 the driver dosent know the reason code
10509 eSIR_BEACON_MISSED is defined as locally */
Jeff Johnson295189b2012-06-20 16:38:30 -070010510 }
10511 else
10512 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010513 smsLog(pMac, LOGW, FL("gets an unknown type (%d)"), type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010514 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010515 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070010516 }
10517
10518 // call profile lost link routine here
Jeff Johnson295189b2012-06-20 16:38:30 -070010519 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -070010520 {
10521 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_LOSTLINK_DETECTED, result);
10522 }
10523
10524 if ( eWNI_SME_DISASSOC_IND == type )
10525 {
10526 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
10527 }
10528 else if ( eWNI_SME_DEAUTH_IND == type )
10529 {
10530 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
10531 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010532 if(!HAL_STATUS_SUCCESS(status))
10533 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010534 //If fail to send confirmation to PE, not to trigger roaming
10535 fToRoam = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010536 }
10537
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010538 //prepare to tell HDD to disconnect
Kiet Lam64c1b492013-07-12 13:56:44 +053010539 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010540 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10541 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010542 if( eWNI_SME_DISASSOC_IND == type)
10543 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010544 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010545 vos_mem_copy(roamInfo.peerMac, pDisassocIndMsg->peerMacAddr,
10546 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010547 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
10548 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010549 else if( eWNI_SME_DEAUTH_IND == type )
10550 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010551 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010552 vos_mem_copy(roamInfo.peerMac, pDeauthIndMsg->peerMacAddr,
10553 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010554 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
10555 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010556 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)"), roamInfo.staId);
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010557
10558 /* See if we can possibly roam. If so, start the roaming process and notify HDD
10559 that we are roaming. But if we cannot possibly roam, or if we are unable to
10560 currently roam, then notify HDD of the lost link */
Jeff Johnson295189b2012-06-20 16:38:30 -070010561 if(fToRoam)
10562 {
10563 //Only remove the connected BSS in infrastructure mode
10564 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10565 //Not to do anying for lostlink with WDS
10566 if( pMac->roam.configParam.nRoamingTime )
10567 {
10568 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
10569 ( eWNI_SME_DEAUTH_IND == type ) ?
10570 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
10571 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010572 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010573 //For IBSS, we need to give some more info to HDD
10574 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
10575 {
10576 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
10577 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10578 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
10579 }
10580 else
10581 {
10582 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
10583 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010584 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010585 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
10586 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
10587 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10588 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
10589 }
10590 else
10591 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010592 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010593 fToRoam = eANI_BOOLEAN_FALSE;
10594 }
10595 }
10596 else
10597 {
10598 //We are told not to roam, indicate lostlink
10599 fToRoam = eANI_BOOLEAN_FALSE;
10600 }
10601 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010602 if(!fToRoam)
10603 {
Madan Mohan Koyyalamudiaf854cf2012-10-30 17:56:25 -070010604 //Tell HDD about the lost link
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010605 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010606 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010607 /* Don't call csrRoamCallCallback for GO/SoftAp case as this indication
10608 * was already given as part of eWNI_SME_DISASSOC_IND msg handling in
10609 * csrRoamCheckForLinkStatusChange API.
10610 */
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010611 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
10612 }
10613
10614 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -070010615 Still enable idle scan for polling in case concurrent sessions are running */
10616 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
10617 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010618 csrScanStartIdleScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010619 }
10620 }
10621
10622 return (status);
10623}
10624
Jeff Johnson295189b2012-06-20 16:38:30 -070010625eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
10626{
10627 eHalStatus status = eHAL_STATUS_SUCCESS;
10628 tListElem *pEntry = NULL;
10629 tSmeCmd *pCommand = NULL;
10630 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010631
10632 if(!pSession)
10633 {
10634 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10635 return eHAL_STATUS_FAILURE;
10636 }
10637
Jeff Johnson295189b2012-06-20 16:38:30 -070010638 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010639 //Only remove the connected BSS in infrastructure mode
10640 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10641 if(pMac->roam.configParam.nRoamingTime)
10642 {
10643 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
10644 {
10645 //before starting the lost link logic release the roam command for handoff
10646 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
10647 if(pEntry)
10648 {
10649 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
10650 }
10651 if(pCommand)
10652 {
10653 if (( eSmeCommandRoam == pCommand->command ) &&
10654 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
10655 {
10656 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10657 {
10658 csrReleaseCommandRoam( pMac, pCommand );
10659 }
10660 }
10661 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010662 smsLog( pMac, LOGW, "Lost link roaming started ...");
Jeff Johnson295189b2012-06-20 16:38:30 -070010663 }
10664 }
10665 else
10666 {
10667 //We are told not to roam, indicate lostlink
10668 status = eHAL_STATUS_FAILURE;
10669 }
10670
10671 return (status);
10672}
Jeff Johnson295189b2012-06-20 16:38:30 -070010673void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
10674{
10675 tListElem *pEntry;
10676 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070010677 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10678 if ( pEntry )
10679 {
10680 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10681 if ( eSmeCommandWmStatusChange == pCommand->command )
10682 {
10683 // Nothing to process in a Lost Link completion.... It just kicks off a
10684 // roaming sequence.
10685 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10686 {
10687 csrReleaseCommandWmStatusChange( pMac, pCommand );
10688 }
10689 else
10690 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010691 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command");
Jeff Johnson295189b2012-06-20 16:38:30 -070010692 }
10693
10694 }
10695 else
10696 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010697 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010698 }
10699 }
10700 else
10701 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010702 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010703 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010704 smeProcessPendingQueue( pMac );
10705}
10706
Jeff Johnson295189b2012-06-20 16:38:30 -070010707void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
10708{
10709 eHalStatus status = eHAL_STATUS_FAILURE;
10710 tSirSmeRsp *pSirSmeMsg;
10711 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010712
10713 if(!pSession)
10714 {
10715 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
10716 return;
10717 }
10718
Jeff Johnson295189b2012-06-20 16:38:30 -070010719 switch ( pCommand->u.wmStatusChangeCmd.Type )
10720 {
10721 case eCsrDisassociated:
10722 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
10723 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
10724 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010725 case eCsrDeauthenticated:
10726 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
10727 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
10728 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010729 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010730 smsLog(pMac, LOGW, FL("gets an unknown command %d"), pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010731 break;
10732 }
10733 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
10734 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
10735 {
10736 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
10737 {
10738 //This is not good
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010739 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010740 }
10741 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010742 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
10743 // command here since there is nothing else to do.
10744 csrRoamWmStatusChangeComplete( pMac );
10745}
10746
Jeff Johnson295189b2012-06-20 16:38:30 -070010747//This function returns band and mode information.
10748//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
10749//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -070010750static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10751 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -070010752{
Jeff Johnson295189b2012-06-20 16:38:30 -070010753 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
10754 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
10755 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070010756 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -070010757
Jeff Johnson295189b2012-06-20 16:38:30 -070010758 //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 -070010759 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
10760 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
10761 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
10762 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -070010763 {
10764 switch( pMac->roam.configParam.uCfgDot11Mode )
10765 {
10766 case eCSR_CFG_DOT11_MODE_11A:
10767 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10768 eBand = eCSR_BAND_5G;
10769 break;
10770 case eCSR_CFG_DOT11_MODE_11B:
10771 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10772 eBand = eCSR_BAND_24;
10773 break;
10774 case eCSR_CFG_DOT11_MODE_11G:
10775 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10776 eBand = eCSR_BAND_24;
10777 break;
10778 case eCSR_CFG_DOT11_MODE_11N:
10779 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010780 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10781 break;
10782#ifdef WLAN_FEATURE_11AC
10783 case eCSR_CFG_DOT11_MODE_11AC:
10784 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10785 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010786 /* If the operating channel is in 2.4 GHz band, check for
10787 * INI item to disable VHT operation in 2.4 GHz band
10788 */
10789 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10790 !pMac->roam.configParam.enableVhtFor24GHz)
10791 {
10792 /* Disable 11AC operation */
10793 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10794 }
10795 else
10796 {
10797 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10798 }
10799 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010800 }
10801 else
10802 {
10803 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10804 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10805 }
10806 break;
10807 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
10808 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10809 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010810 /* If the operating channel is in 2.4 GHz band, check for
10811 * INI item to disable VHT operation in 2.4 GHz band
10812 */
10813 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10814 !pMac->roam.configParam.enableVhtFor24GHz)
10815 {
10816 /* Disable 11AC operation */
10817 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10818 }
10819 else
10820 {
10821 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
10822 }
10823 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010824 }
10825 else
10826 {
10827 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10828 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10829 }
10830 break;
10831#endif
10832 case eCSR_CFG_DOT11_MODE_AUTO:
10833 eBand = pMac->roam.configParam.eBand;
10834 if (eCSR_BAND_24 == eBand)
10835 {
10836 // WiFi tests require IBSS networks to start in 11b mode
10837 // without any change to the default parameter settings
10838 // on the adapter. We use ACU to start an IBSS through
10839 // creation of a startIBSS profile. This startIBSS profile
10840 // has Auto MACProtocol and the adapter property setting
10841 // for dot11Mode is also AUTO. So in this case, let's
10842 // start the IBSS network in 11b mode instead of 11g mode.
10843 // So this is for Auto=profile->MacProtocol && Auto=Global.
10844 // dot11Mode && profile->channel is < 14, then start the IBSS
10845 // in b mode.
10846 //
10847 // Note: we used to have this start as an 11g IBSS for best
10848 // performance... now to specify that the user will have to
10849 // set the do11Mode in the property page to 11g to force it.
10850 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10851 }
10852 else
10853 {
10854#ifdef WLAN_FEATURE_11AC
10855 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10856 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010857 /* If the operating channel is in 2.4 GHz band, check for
10858 * INI item to disable VHT operation in 2.4 GHz band
10859 */
10860 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10861 !pMac->roam.configParam.enableVhtFor24GHz)
10862 {
10863 /* Disable 11AC operation */
10864 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10865 }
10866 else
10867 {
10868 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10869 }
10870 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010871 }
10872 else
10873 {
10874 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10875 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10876 }
10877#else
10878 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10879 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10880#endif
10881 }
10882 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010883 default:
10884 // Global dot11 Mode setting is 11a/b/g.
10885 // use the channel number to determine the Mode setting.
10886 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10887 {
10888 eBand = pMac->roam.configParam.eBand;
10889 if(eCSR_BAND_24 == eBand)
10890 {
10891 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
10892 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10893 }
10894 else
10895 {
10896 //prefer 5GHz
10897 eBand = eCSR_BAND_5G;
10898 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10899 }
10900 }
10901 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10902 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070010903 // WiFi tests require IBSS networks to start in 11b mode
10904 // without any change to the default parameter settings
10905 // on the adapter. We use ACU to start an IBSS through
10906 // creation of a startIBSS profile. This startIBSS profile
10907 // has Auto MACProtocol and the adapter property setting
10908 // for dot11Mode is also AUTO. So in this case, let's
10909 // start the IBSS network in 11b mode instead of 11g mode.
10910 // So this is for Auto=profile->MacProtocol && Auto=Global.
10911 // dot11Mode && profile->channel is < 14, then start the IBSS
10912 // in b mode.
Jeff Johnson295189b2012-06-20 16:38:30 -070010913 //
Ravi Joshia96ceb42013-05-20 18:52:39 -070010914 // Note: we used to have this start as an 11g IBSS for best
10915 // performance... now to specify that the user will have to
10916 // set the do11Mode in the property page to 11g to force it.
Jeff Johnson295189b2012-06-20 16:38:30 -070010917 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10918 eBand = eCSR_BAND_24;
10919 }
10920 else
10921 {
10922 // else, it's a 5.0GHz channel. Set mode to 11a.
10923 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10924 eBand = eCSR_BAND_5G;
10925 }
10926 break;
10927 }//switch
10928 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
10929 else
10930 {
10931 //dot11 mode is set, lets pick the band
10932 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10933 {
10934 // channel is Auto also.
10935 eBand = pMac->roam.configParam.eBand;
10936 if(eCSR_BAND_ALL == eBand)
10937 {
10938 //prefer 5GHz
10939 eBand = eCSR_BAND_5G;
10940 }
10941 }
10942 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10943 {
10944 eBand = eCSR_BAND_24;
10945 }
10946 else
10947 {
10948 eBand = eCSR_BAND_5G;
10949 }
Ravi Joshia96ceb42013-05-20 18:52:39 -070010950 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010951 if(pBand)
10952 {
10953 *pBand = eBand;
10954 }
10955
10956 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010957 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -070010958 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10959 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010960
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080010961 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
10962 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 -070010963 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010964#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010965 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070010966#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070010967 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
10968 {
10969 //We cannot do 11n here
10970 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10971 {
10972 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10973 }
10974 else
10975 {
10976 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10977 }
10978 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010979 return( cfgDot11Mode );
10980}
10981
Jeff Johnson295189b2012-06-20 16:38:30 -070010982eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
10983{
10984 eHalStatus status;
10985 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010986
10987 if(!pSession)
10988 {
10989 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10990 return eHAL_STATUS_FAILURE;
10991 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010992
10993#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10994 {
10995 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010996 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10997 if(pIbssLog)
10998 {
10999 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
11000 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11001 }
11002 }
11003#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011004 // Set the roaming substate to 'stop Bss request'...
11005 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
11006
11007 // attempt to stop the Bss (reason code is ignored...)
11008 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080011009 if(!HAL_STATUS_SUCCESS(status))
11010 {
11011 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
11012 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011013 return (status);
11014}
11015
Jeff Johnson295189b2012-06-20 16:38:30 -070011016//pNumChan is a caller allocated space with the sizeof pChannels
11017eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
11018{
11019
11020 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
11021 (tANI_U8 *)pChannels,
11022 pNumChan));
11023}
11024
Kiran4a17ebe2013-01-31 10:43:43 -080011025tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
11026{
11027 tANI_U32 cfgLength = 0;
11028 tANI_U16 cfgId = 0;
11029 tPowerdBm maxTxPwr = 0;
11030 tANI_U8 *pCountryInfo = NULL;
11031 eHalStatus status;
11032 tANI_U8 count = 0;
11033 tANI_U8 firstChannel;
11034 tANI_U8 maxChannels;
11035
11036 if (CSR_IS_CHANNEL_5GHZ(channel))
11037 {
11038 cfgId = WNI_CFG_MAX_TX_POWER_5;
11039 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
11040 }
11041 else if (CSR_IS_CHANNEL_24GHZ(channel))
11042 {
11043 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
11044 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
11045 }
11046 else
11047 return maxTxPwr;
11048
Kiet Lam64c1b492013-07-12 13:56:44 +053011049 pCountryInfo = vos_mem_malloc(cfgLength);
11050 if ( NULL == pCountryInfo )
11051 status = eHAL_STATUS_FAILURE;
11052 else
11053 status = eHAL_STATUS_SUCCESS;
Kiran4a17ebe2013-01-31 10:43:43 -080011054 if (status != eHAL_STATUS_SUCCESS)
11055 {
11056 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiet Lam64c1b492013-07-12 13:56:44 +053011057 FL("%s: failed to allocate memory, status = %d"),
Kiran4a17ebe2013-01-31 10:43:43 -080011058 __FUNCTION__, status);
11059 goto error;
11060 }
11061 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
11062 if (status != eHAL_STATUS_SUCCESS)
11063 {
11064 goto error;
11065 }
11066 /* Identify the channel and maxtxpower */
11067 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
11068 {
11069 firstChannel = pCountryInfo[count++];
11070 maxChannels = pCountryInfo[count++];
11071 maxTxPwr = pCountryInfo[count++];
11072
11073 if ((channel >= firstChannel) &&
11074 (channel < (firstChannel + maxChannels)))
11075 {
11076 break;
11077 }
11078 }
11079
11080error:
11081 if (NULL != pCountryInfo)
Kiet Lam64c1b492013-07-12 13:56:44 +053011082 vos_mem_free(pCountryInfo);
Kiran4a17ebe2013-01-31 10:43:43 -080011083
11084 return maxTxPwr;
11085}
11086
11087
Jeff Johnson295189b2012-06-20 16:38:30 -070011088tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
11089{
11090 tANI_BOOLEAN fValid = FALSE;
11091 tANI_U32 idxValidChannels;
11092 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11093
11094 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
11095 {
11096 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
11097 {
11098 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
11099 {
11100 fValid = TRUE;
11101 break;
11102 }
11103 }
11104 }
11105 pMac->roam.numValidChannels = len;
11106 return fValid;
11107}
11108
Jeff Johnson295189b2012-06-20 16:38:30 -070011109tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
11110{
11111 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
11112 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011113 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
11114 {
11115 if(channel == pMac->scan.base40MHzChannels.channelList[i])
11116 {
11117 fValid = eANI_BOOLEAN_TRUE;
11118 break;
11119 }
11120 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011121 return (fValid);
11122}
11123
Jeff Johnson295189b2012-06-20 16:38:30 -070011124//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070011125 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011126{
Jeff Johnsone7245742012-09-05 17:12:55 -070011127 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011128 tANI_U8 centerChn;
11129 tANI_U32 ChannelBondingMode;
Sandeep Puligilla60342762014-01-30 21:05:37 +053011130
Jeff Johnson295189b2012-06-20 16:38:30 -070011131 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
11132 {
11133 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
11134 }
11135 else
11136 {
11137 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
11138 }
11139 //Figure what the other side's CB mode
11140 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
11141 {
11142 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
11143 {
Leela Venkata Kiran Kumar Reddy Chirala10c5a2e2013-12-18 14:41:28 -080011144 // Check set as TKIP or not.
Praveen Kumar Sirisilla548cf372014-01-16 18:28:59 -080011145 if ((NULL != &(pIes->RSN.pwise_cipher_suites[0][0]) &&
Leela Venkata Kiran Kumar Reddy Chirala10c5a2e2013-12-18 14:41:28 -080011146 !memcmp( &(pIes->RSN.pwise_cipher_suites[0][0]),
11147 "\x00\x0f\xac\x02" ,4))
Praveen Kumar Sirisilla548cf372014-01-16 18:28:59 -080011148 || (((NULL != &(pIes->WPA)) &&
11149 (pIes->WPA.unicast_cipher_count == 1))
11150 && ((NULL != &(pIes->WPA.unicast_ciphers[0]))
11151 && memcmp(&(pIes->WPA.unicast_ciphers[0]),
11152 "\x00\x0f\xac\x02", 4))))
Leela Venkata Kiran Kumar Reddy Chirala10c5a2e2013-12-18 14:41:28 -080011153 {
11154 smsLog(pMac, LOGW, " No channel bonding in TKIP mode ");
11155 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11156 }
11157
11158 else if(pIes->HTInfo.present)
Jeff Johnson295189b2012-06-20 16:38:30 -070011159 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011160 /* This is called during INFRA STA/CLIENT and should use the merged value of
11161 * supported channel width and recommended tx width as per standard
11162 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011163 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070011164 pIes->HTCaps.supportedChannelWidthSet,
11165 pIes->HTInfo.recommendedTxWidthSet,
11166 pIes->HTInfo.secondaryChannelOffset);
11167
11168 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
11169 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070011170 else
Jeff Johnsone7245742012-09-05 17:12:55 -070011171 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11172 switch (eRet) {
11173 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
11174 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
11175 break;
11176 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
11177 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
11178 break;
11179 case PHY_SINGLE_CHANNEL_CENTERED:
11180 default:
11181 centerChn = primaryChn;
11182 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011183 }
Jeff Johnsone7245742012-09-05 17:12:55 -070011184 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070011185 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011186 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Jeff Johnsone7245742012-09-05 17:12:55 -070011187 //eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011188 }
11189 }
11190 }
11191 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011192 return eRet;
11193}
Jeff Johnson295189b2012-06-20 16:38:30 -070011194tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
11195{
11196 tANI_BOOLEAN fFound = FALSE;
11197 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011198 for( idx = 0; idx < pCipherList->numEntries; idx++ )
11199 {
11200 if( pCipherList->encryptionType[idx] == encryptionType )
11201 {
11202 fFound = TRUE;
11203 break;
11204 }
11205 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011206 return fFound;
11207}
Jeff Johnson295189b2012-06-20 16:38:30 -070011208tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
11209{
11210 tANI_BOOLEAN fFound = FALSE;
11211 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011212 for( idx = 0; idx < pAuthList->numEntries; idx++ )
11213 {
11214 if( pAuthList->authType[idx] == authType )
11215 {
11216 fFound = TRUE;
11217 break;
11218 }
11219 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011220 return fFound;
11221}
Jeff Johnson295189b2012-06-20 16:38:30 -070011222tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
11223{
11224 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11225 tCsrScanResultFilter *pScanFilter = NULL;
11226 eHalStatus status = eHAL_STATUS_SUCCESS;
11227
11228 if(pProfile1 && pProfile2)
11229 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011230 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
11231 if ( NULL == pScanFilter )
11232 status = eHAL_STATUS_FAILURE;
11233 else
11234 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011235 if(HAL_STATUS_SUCCESS(status))
11236 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011237 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011238 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
11239 if(HAL_STATUS_SUCCESS(status))
11240 {
11241 fCheck = eANI_BOOLEAN_FALSE;
11242 do
11243 {
11244 tANI_U32 i;
11245 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
11246 {
11247 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
11248 pScanFilter->SSIDs.SSIDList[i].SSID.length,
11249 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
11250 if ( fCheck ) break;
11251 }
11252 if(!fCheck)
11253 {
11254 break;
11255 }
11256 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
11257 || pProfile2->BSSType != pProfile1->BSSType
11258 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
11259 )
11260 {
11261 fCheck = eANI_BOOLEAN_FALSE;
11262 break;
11263 }
11264#ifdef WLAN_FEATURE_VOWIFI_11R
11265 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
11266 {
11267 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
11268 {
11269 fCheck = eANI_BOOLEAN_FALSE;
11270 break;
11271 }
11272 }
11273#endif
11274 //Match found
11275 fCheck = eANI_BOOLEAN_TRUE;
11276 }while(0);
11277 csrFreeScanFilter(pMac, pScanFilter);
11278 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011279 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011280 }
11281 }
11282
11283 return (fCheck);
11284}
11285
Jeff Johnson295189b2012-06-20 16:38:30 -070011286tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
11287{
11288 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11289 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011290 do
11291 {
11292 //Only check for static WEP
11293 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
11294 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
11295 {
11296 fCheck = eANI_BOOLEAN_TRUE;
11297 break;
11298 }
11299 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
11300 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
11301 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
11302 {
11303 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053011304 if (!vos_mem_compare(&pConnProfile->Keys.KeyMaterial[i],
11305 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
Jeff Johnson295189b2012-06-20 16:38:30 -070011306 {
11307 break;
11308 }
11309 }
11310 if( i == CSR_MAX_NUM_KEY)
11311 {
11312 fCheck = eANI_BOOLEAN_TRUE;
11313 }
11314 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011315 return (fCheck);
11316}
11317
Jeff Johnson295189b2012-06-20 16:38:30 -070011318//IBSS
11319
Jeff Johnson295189b2012-06-20 16:38:30 -070011320tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
11321{
11322 tANI_U8 channel = 0;
11323 tANI_U32 idx;
11324 tANI_U32 idxValidChannels;
11325 tANI_BOOLEAN fFound = FALSE;
11326 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11327
11328 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
11329 {
11330 channel = pMac->roam.configParam.AdHocChannel5G;
11331 if(!csrRoamIsChannelValid(pMac, channel))
11332 {
11333 channel = 0;
11334 }
11335 }
11336 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11337 {
11338 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
11339 {
11340 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11341 {
11342 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11343 {
11344 fFound = TRUE;
11345 channel = csrStartIbssChannels50[ idx ];
11346 }
11347 }
11348 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011349 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
11350 if (!fFound)
11351 {
11352 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
11353 {
11354 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idx ]) ) // the max channel# in 11g is 14
11355 {
11356 channel = csrStartIbssChannels50[ idx ];
11357 break;
11358 }
11359 }
11360 }
11361 }//if
11362
11363 return( channel );
11364}
11365
Jeff Johnson295189b2012-06-20 16:38:30 -070011366tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
11367{
11368 tANI_U8 channel = 1;
11369 tANI_U32 idx;
11370 tANI_U32 idxValidChannels;
11371 tANI_BOOLEAN fFound = FALSE;
11372 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11373
11374 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
11375 {
11376 channel = pMac->roam.configParam.AdHocChannel24;
11377 if(!csrRoamIsChannelValid(pMac, channel))
11378 {
11379 channel = 0;
11380 }
11381 }
11382
11383 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11384 {
11385 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
11386 {
11387 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11388 {
11389 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11390 {
11391 fFound = TRUE;
11392 channel = csrStartIbssChannels24[ idx ];
11393 }
11394 }
11395 }
11396 }
11397
11398 return( channel );
11399}
11400
Jeff Johnson295189b2012-06-20 16:38:30 -070011401static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
11402 tCsrRoamStartBssParams *pParam )
11403{
11404 eCsrCfgDot11Mode cfgDot11Mode;
11405 eCsrBand eBand;
11406 tANI_U8 channel = 0;
11407 tSirNwType nwType;
11408 tANI_U8 operationChannel = 0;
11409
11410 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
11411 {
11412 operationChannel = pProfile->ChannelInfo.ChannelList[0];
11413 }
11414
Jeff Johnson295189b2012-06-20 16:38:30 -070011415 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070011416
Jeff Johnson295189b2012-06-20 16:38:30 -070011417 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11418 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
11419 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
11420 )
11421 {
11422 /* This should never happen */
11423 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011424 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070011425 pProfile->csrPersona);
11426 VOS_ASSERT(0);
11427 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011428 switch( cfgDot11Mode )
11429 {
11430 case eCSR_CFG_DOT11_MODE_11G:
11431 nwType = eSIR_11G_NW_TYPE;
11432 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011433 case eCSR_CFG_DOT11_MODE_11B:
11434 nwType = eSIR_11B_NW_TYPE;
11435 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011436 case eCSR_CFG_DOT11_MODE_11A:
11437 nwType = eSIR_11A_NW_TYPE;
11438 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011439 default:
11440 case eCSR_CFG_DOT11_MODE_11N:
11441 case eCSR_CFG_DOT11_MODE_TAURUS:
11442 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
11443 if(eCSR_BAND_24 == eBand)
11444 {
11445 nwType = eSIR_11G_NW_TYPE;
11446 }
11447 else
11448 {
11449 nwType = eSIR_11A_NW_TYPE;
11450 }
11451 break;
11452 }
11453
11454 pParam->extendedRateSet.numRates = 0;
11455
11456 switch ( nwType )
11457 {
11458 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011459 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011460 case eSIR_11A_NW_TYPE:
11461
11462 pParam->operationalRateSet.numRates = 8;
11463
11464 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11465 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11466 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11467 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11468 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11469 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11470 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11471 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11472
11473 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11474 {
11475 channel = csrRoamGetIbssStartChannelNumber50( pMac );
11476 if( 0 == channel &&
11477 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
11478 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
11479 )
11480 {
11481 //We could not find a 5G channel by auto pick, let's try 2.4G channels
11482 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
11483 nwType = eSIR_11B_NW_TYPE;
11484 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11485 pParam->operationalRateSet.numRates = 4;
11486 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11487 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11488 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11489 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11490 }
11491 }
11492 else
11493 {
11494 channel = operationChannel;
11495 }
11496 break;
11497
11498 case eSIR_11B_NW_TYPE:
11499 pParam->operationalRateSet.numRates = 4;
11500 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11501 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11502 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11503 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070011504 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11505 {
11506 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11507 }
11508 else
11509 {
11510 channel = operationChannel;
11511 }
11512
11513 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011514 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070011515 /* For P2P Client and P2P GO, disable 11b rates */
11516 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11517 (pProfile->csrPersona == VOS_P2P_GO_MODE)
11518 )
11519 {
11520 pParam->operationalRateSet.numRates = 8;
11521
11522 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11523 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11524 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11525 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11526 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11527 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11528 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11529 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11530 }
11531 else
Jeff Johnson295189b2012-06-20 16:38:30 -070011532 {
11533 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070011534 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11535 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11536 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11537 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11538
11539 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070011540 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
11541 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
11542 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
11543 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
11544 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
11545 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
11546 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
11547 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
11548 }
11549
11550 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11551 {
11552 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11553 }
11554 else
11555 {
11556 channel = operationChannel;
11557 }
11558
11559 break;
11560 }
11561 pParam->operationChn = channel;
11562 pParam->sirNwType = nwType;
11563}
11564
Jeff Johnson295189b2012-06-20 16:38:30 -070011565static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
11566 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
11567{
11568
11569 if( pParam )
11570 {
11571 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070011572 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011573 pParam->operationChn = pBssDesc->channelId;
Kiet Lam64c1b492013-07-12 13:56:44 +053011574 vos_mem_copy(&pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011575
11576 if( pIes )
11577 {
11578 if(pIes->SuppRates.present)
11579 {
11580 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
11581 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
11582 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011583 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 -070011584 pIes->SuppRates.num_rates);
11585 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
11586 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011587 vos_mem_copy(pParam->operationalRateSet.rate, pIes->SuppRates.rates,
11588 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
Jeff Johnson295189b2012-06-20 16:38:30 -070011589 }
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011590 if (pIes->ExtSuppRates.present)
11591 {
11592 pParam->extendedRateSet.numRates = pIes->ExtSuppRates.num_rates;
11593 if(pIes->ExtSuppRates.num_rates > SIR_MAC_EXTENDED_RATE_EID_MAX)
11594 {
11595 smsLog(pMac, LOGE, FL("num_rates :%d is more than \
11596 SIR_MAC_RATESET_EID_MAX, resetting to \
11597 SIR_MAC_RATESET_EID_MAX"),
11598 pIes->ExtSuppRates.num_rates);
11599 pIes->ExtSuppRates.num_rates = SIR_MAC_EXTENDED_RATE_EID_MAX;
11600 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053011601 vos_mem_copy(pParam->extendedRateSet.rate,
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011602 pIes->ExtSuppRates.rates,
11603 sizeof(*pIes->ExtSuppRates.rates) * pIes->ExtSuppRates.num_rates);
11604 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011605 if( pIes->SSID.present )
11606 {
11607 pParam->ssId.length = pIes->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +053011608 vos_mem_copy(pParam->ssId.ssId, pIes->SSID.ssid,
11609 pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011610 }
11611 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070011612 }
11613 else
11614 {
11615 pParam->ssId.length = 0;
11616 pParam->operationalRateSet.numRates = 0;
11617 }
11618 }
11619}
11620
Jeff Johnson295189b2012-06-20 16:38:30 -070011621static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
11622{
11623 tANI_U8 MaxRate = 0;
11624 tANI_U32 i;
11625 tANI_U8 *pRate;
11626
11627 pRate = pSirRateSet->rate;
11628 for ( i = 0; i < pSirRateSet->numRates; i++ )
11629 {
11630 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
11631 }
11632
11633 // Save the max rate in the connected state information...
11634
11635 // modify LastRates variable as well
11636
11637 return;
11638}
11639
Jeff Johnson295189b2012-06-20 16:38:30 -070011640eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
11641 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
11642{
11643 eHalStatus status = eHAL_STATUS_SUCCESS;
11644 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070011645 // Set the roaming substate to 'Start BSS attempt'...
11646 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011647#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11648 //Need to figure out whether we need to log WDS???
11649 if( CSR_IS_IBSS( pProfile ) )
11650 {
11651 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011652 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11653 if(pIbssLog)
11654 {
11655 if(pBssDesc)
11656 {
11657 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
Kiet Lam64c1b492013-07-12 13:56:44 +053011658 vos_mem_copy(pIbssLog->bssid, pBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070011659 }
11660 else
11661 {
11662 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
11663 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011664 vos_mem_copy(pIbssLog->ssid, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011665 if(pProfile->ChannelInfo.numOfChannels == 0)
11666 {
11667 pIbssLog->channelSetting = AUTO_PICK;
11668 }
11669 else
11670 {
11671 pIbssLog->channelSetting = SPECIFIED;
11672 }
11673 pIbssLog->operatingChannel = pParam->operationChn;
11674 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11675 }
11676 }
11677#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
11678 //Put RSN information in for Starting BSS
11679 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
11680 pParam->pRSNIE = pProfile->pRSNReqIE;
11681
Jeff Johnson295189b2012-06-20 16:38:30 -070011682 pParam->privacy = pProfile->privacy;
11683 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
11684 pParam->authType = pProfile->csr80211AuthType;
11685 pParam->beaconInterval = pProfile->beaconInterval;
11686 pParam->dtimPeriod = pProfile->dtimPeriod;
11687 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
11688 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
11689 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
11690 {
11691 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
11692 {
11693 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
11694 }
11695 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011696 pParam->protEnabled = pProfile->protEnabled;
11697 pParam->obssProtEnabled = pProfile->obssProtEnabled;
11698 pParam->ht_protection = pProfile->cfg_protection;
11699 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080011700
Jeff Johnson295189b2012-06-20 16:38:30 -070011701 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
11702 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070011703 pParam->bssPersona = pProfile->csrPersona;
Chet Lanctot8cecea22014-02-11 19:09:36 -080011704
11705#ifdef WLAN_FEATURE_11W
11706 pParam->mfpCapable = (0 != pProfile->MFPCapable);
11707 pParam->mfpRequired = (0 != pProfile->MFPRequired);
11708#endif
11709
Jeff Johnson295189b2012-06-20 16:38:30 -070011710 // When starting an IBSS, start on the channel from the Profile.
11711 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070011712 return (status);
11713}
11714
Jeff Johnson295189b2012-06-20 16:38:30 -070011715static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070011716 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011717{
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011718 tANI_U8 Channel;
Jeff Johnsone7245742012-09-05 17:12:55 -070011719 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011720 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011721
11722 if(!pSession)
11723 {
11724 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11725 return;
11726 }
11727
Jeff Johnson295189b2012-06-20 16:38:30 -070011728 if( pBssDesc )
11729 {
11730 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
11731 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
11732 //The following code has to be do after that.
11733 //For WDS station, use selfMac as the self BSSID
11734 if( CSR_IS_WDS_STA( pProfile ) )
11735 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011736 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
11737 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011738 }
11739 }
11740 else
11741 {
11742 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070011743 //Use the first SSID
11744 if(pProfile->SSIDs.numOfSSIDs)
11745 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011746 vos_mem_copy(&pSession->bssParams.ssId, pProfile->SSIDs.SSIDList,
11747 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011748 }
11749 //For WDS station, use selfMac as the self BSSID
11750 if( CSR_IS_WDS_STA( pProfile ) )
11751 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011752 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
11753 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011754 }
11755 //Use the first BSSID
11756 else if( pProfile->BSSIDs.numOfBSSIDs )
11757 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011758 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid,
11759 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011760 }
11761 else
11762 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011763 vos_mem_set(&pSession->bssParams.bssid, sizeof(tCsrBssid), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011764 }
11765 }
11766 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070011767 //Set operating channel in pProfile which will be used
11768 //in csrRoamSetBssConfigCfg() to determine channel bonding
11769 //mode and will be configured in CFG later
11770 pProfile->operationChannel = Channel;
11771
11772 if(Channel == 0)
11773 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053011774 smsLog(pMac, LOGE, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070011775 }
11776 else
11777 {
11778
11779 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011780 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS( pProfile ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011781 {
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011782 if(CSR_IS_CHANNEL_24GHZ(Channel) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011783 {
11784 cbMode = pMac->roam.configParam.channelBondingMode24GHz;
11785 }
11786 else
11787 {
11788 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
11789 }
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011790 smsLog(pMac, LOG1, "## cbMode %d", cbMode);
Jeff Johnsone7245742012-09-05 17:12:55 -070011791 pBssConfig->cbMode = cbMode;
11792 pSession->bssParams.cbMode = cbMode;
11793 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011794 }
11795}
11796
Jeff Johnson295189b2012-06-20 16:38:30 -070011797static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
11798 tANI_BOOLEAN *pfSameIbss )
11799{
11800 eHalStatus status = eHAL_STATUS_SUCCESS;
11801 tANI_BOOLEAN fSameIbss = FALSE;
11802
11803 if ( csrIsConnStateIbss( pMac, sessionId ) )
11804 {
11805 // Check if any profile parameter has changed ? If any profile parameter
11806 // has changed then stop old BSS and start a new one with new parameters
11807 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
11808 {
11809 fSameIbss = TRUE;
11810 }
11811 else
11812 {
11813 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
11814 }
11815 }
11816 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
11817 {
11818 // Disassociate from the connected Infrastructure network...
11819 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
11820 }
11821 else
11822 {
11823 tBssConfigParam *pBssConfig;
11824
Kiet Lam64c1b492013-07-12 13:56:44 +053011825 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
11826 if ( NULL == pBssConfig )
11827 status = eHAL_STATUS_FAILURE;
11828 else
11829 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011830 if(HAL_STATUS_SUCCESS(status))
11831 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011832 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011833 // there is no Bss description before we start an IBSS so we need to adopt
11834 // all Bss configuration parameters from the Profile.
11835 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
11836 if(HAL_STATUS_SUCCESS(status))
11837 {
11838 //save dotMode
11839 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
11840 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070011841 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053011842 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
11843 NULL, pBssConfig,
11844 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011845 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011846
11847 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -070011848 }//Allocate memory
11849 }
11850
11851 if(pfSameIbss)
11852 {
11853 *pfSameIbss = fSameIbss;
11854 }
11855 return( status );
11856}
11857
Jeff Johnson295189b2012-06-20 16:38:30 -070011858static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
11859 tSirSmeNewBssInfo *pNewBss )
11860{
11861 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011862
11863 if(!pSession)
11864 {
11865 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11866 return;
11867 }
11868
Jeff Johnson295189b2012-06-20 16:38:30 -070011869 if( pNewBss )
11870 {
11871 // Set the operating channel.
11872 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
11873 // move the BSSId from the BSS description into the connected state information.
Kiet Lam64c1b492013-07-12 13:56:44 +053011874 vos_mem_copy(&pSession->connectedProfile.bssid, &(pNewBss->bssId),
11875 sizeof( tCsrBssid ));
Jeff Johnson295189b2012-06-20 16:38:30 -070011876 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011877 return;
11878}
11879
Jeff Johnson295189b2012-06-20 16:38:30 -070011880#ifdef FEATURE_WLAN_WAPI
11881eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
11882 tANI_U32 numItems )
11883{
11884 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11885 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011886 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11887 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011888 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011889 return status;
11890 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011891 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011892 pSession = CSR_GET_SESSION( pMac, sessionId );
11893 if(numItems <= CSR_MAX_BKID_ALLOWED)
11894 {
11895 status = eHAL_STATUS_SUCCESS;
11896 //numItems may be 0 to clear the cache
11897 pSession->NumBkidCache = (tANI_U16)numItems;
11898 if(numItems && pBKIDCache)
11899 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011900 vos_mem_copy(pSession->BkidCacheInfo, pBKIDCache,
11901 sizeof(tBkidCacheInfo) * numItems);
11902 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011903 }
11904 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011905 return (status);
11906}
Jeff Johnson295189b2012-06-20 16:38:30 -070011907eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
11908 tBkidCacheInfo *pBkidCache)
11909{
11910 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11911 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011912 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11913 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011914 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011915 return status;
11916 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011917 pSession = CSR_GET_SESSION( pMac, sessionId );
11918 if(pNum && pBkidCache)
11919 {
11920 if(pSession->NumBkidCache == 0)
11921 {
11922 *pNum = 0;
11923 status = eHAL_STATUS_SUCCESS;
11924 }
11925 else if(*pNum >= pSession->NumBkidCache)
11926 {
11927 if(pSession->NumBkidCache > CSR_MAX_PMKID_ALLOWED)
11928 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011929 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 -070011930 pSession->NumBkidCache);
11931 pSession->NumBkidCache = CSR_MAX_PMKID_ALLOWED;
11932 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011933 vos_mem_copy(pBkidCache, pSession->BkidCacheInfo,
11934 sizeof(tBkidCacheInfo) * pSession->NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070011935 *pNum = pSession->NumBkidCache;
11936 status = eHAL_STATUS_SUCCESS;
11937 }
11938 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011939 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070011940}
Jeff Johnson295189b2012-06-20 16:38:30 -070011941tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
11942{
11943 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070011944}
11945#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070011946eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
11947 tPmkidCacheInfo *pPMKIDCache, tANI_U32 numItems )
11948{
11949 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11950 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011951
11952 if(!pSession)
11953 {
11954 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11955 return eHAL_STATUS_FAILURE;
11956 }
11957
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011958 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011959 if(numItems <= CSR_MAX_PMKID_ALLOWED)
11960 {
11961#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11962 {
11963 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053011964 vos_mem_set(&secEvent,
11965 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011966 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
11967 secEvent.encryptionModeMulticast =
11968 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
11969 secEvent.encryptionModeUnicast =
11970 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053011971 vos_mem_copy(secEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070011972 secEvent.authMode =
11973 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
11974 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
11975 }
11976#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011977 status = eHAL_STATUS_SUCCESS;
11978 //numItems may be 0 to clear the cache
11979 pSession->NumPmkidCache = (tANI_U16)numItems;
11980 if(numItems && pPMKIDCache)
11981 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011982 vos_mem_copy(pSession->PmkidCacheInfo, pPMKIDCache,
11983 sizeof(tPmkidCacheInfo) * numItems);
11984 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011985 }
11986 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011987 return (status);
11988}
11989
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070011990eHalStatus csrRoamDelPMKIDfromCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
11991 tANI_U8 *pBSSId )
11992{
11993 eHalStatus status = eHAL_STATUS_FAILURE;
11994 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
11995 tANI_BOOLEAN fMatchFound = FALSE;
11996 tANI_U32 Index;
11997 if(!pSession)
11998 {
11999 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12000 return eHAL_STATUS_FAILURE;
12001 }
12002 do
12003 {
12004 for( Index=0; Index < pSession->NumPmkidCache; Index++ )
12005 {
Arif Hussaina7c8e412013-11-20 11:06:42 -080012006 smsLog(pMac, LOGW, "Delete PMKID for "
12007 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pBSSId));
Kiet Lamf2f201e2013-11-16 21:24:16 +053012008 if( vos_mem_compare( pBSSId, pSession->PmkidCacheInfo[Index].BSSID, sizeof(tCsrBssid) ) )
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012009 {
12010 fMatchFound = TRUE;
12011 break;
12012 }
12013 }
12014 if( !fMatchFound ) break;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053012015 vos_mem_set(pSession->PmkidCacheInfo[Index].BSSID, sizeof(tCsrBssid), 0);
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012016 status = eHAL_STATUS_SUCCESS;
12017 }
12018 while( 0 );
12019 smsLog(pMac, LOGW, "csrDelPMKID called return match = %d Status = %d",
12020 fMatchFound, status);
12021 return status;
12022}
Jeff Johnson295189b2012-06-20 16:38:30 -070012023tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
12024{
12025 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
12026}
12027
Jeff Johnson295189b2012-06-20 16:38:30 -070012028eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
12029{
12030 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12031 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012032
12033 if(!pSession)
12034 {
12035 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12036 return eHAL_STATUS_FAILURE;
12037 }
12038
Jeff Johnson295189b2012-06-20 16:38:30 -070012039 if(pNum && pPmkidCache)
12040 {
12041 if(pSession->NumPmkidCache == 0)
12042 {
12043 *pNum = 0;
12044 status = eHAL_STATUS_SUCCESS;
12045 }
12046 else if(*pNum >= pSession->NumPmkidCache)
12047 {
12048 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
12049 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012050 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 -070012051 pSession->NumPmkidCache);
12052 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
12053 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012054 vos_mem_copy(pPmkidCache, pSession->PmkidCacheInfo,
12055 sizeof(tPmkidCacheInfo) * pSession->NumPmkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012056 *pNum = pSession->NumPmkidCache;
12057 status = eHAL_STATUS_SUCCESS;
12058 }
12059 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012060 return (status);
12061}
12062
Jeff Johnson295189b2012-06-20 16:38:30 -070012063eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12064{
12065 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12066 tANI_U32 len;
12067 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012068
12069 if(!pSession)
12070 {
12071 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12072 return eHAL_STATUS_FAILURE;
12073 }
12074
Jeff Johnson295189b2012-06-20 16:38:30 -070012075 if(pLen)
12076 {
12077 len = *pLen;
12078 *pLen = pSession->nWpaRsnReqIeLength;
12079 if(pBuf)
12080 {
12081 if(len >= pSession->nWpaRsnReqIeLength)
12082 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012083 vos_mem_copy(pBuf, pSession->pWpaRsnReqIE,
12084 pSession->nWpaRsnReqIeLength);
12085 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012086 }
12087 }
12088 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012089 return (status);
12090}
12091
Jeff Johnson295189b2012-06-20 16:38:30 -070012092eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12093{
12094 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12095 tANI_U32 len;
12096 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012097
12098 if(!pSession)
12099 {
12100 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12101 return eHAL_STATUS_FAILURE;
12102 }
12103
Jeff Johnson295189b2012-06-20 16:38:30 -070012104 if(pLen)
12105 {
12106 len = *pLen;
12107 *pLen = pSession->nWpaRsnRspIeLength;
12108 if(pBuf)
12109 {
12110 if(len >= pSession->nWpaRsnRspIeLength)
12111 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012112 vos_mem_copy(pBuf, pSession->pWpaRsnRspIE,
12113 pSession->nWpaRsnRspIeLength);
12114 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012115 }
12116 }
12117 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012118 return (status);
12119}
Jeff Johnson295189b2012-06-20 16:38:30 -070012120#ifdef FEATURE_WLAN_WAPI
12121eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12122{
12123 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12124 tANI_U32 len;
12125 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012126
12127 if(!pSession)
12128 {
12129 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12130 return eHAL_STATUS_FAILURE;
12131 }
12132
Jeff Johnson295189b2012-06-20 16:38:30 -070012133 if(pLen)
12134 {
12135 len = *pLen;
12136 *pLen = pSession->nWapiReqIeLength;
12137 if(pBuf)
12138 {
12139 if(len >= pSession->nWapiReqIeLength)
12140 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012141 vos_mem_copy(pBuf, pSession->pWapiReqIE,
12142 pSession->nWapiReqIeLength);
12143 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012144 }
12145 }
12146 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012147 return (status);
12148}
Jeff Johnson295189b2012-06-20 16:38:30 -070012149eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12150{
12151 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12152 tANI_U32 len;
12153 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012154
12155 if(!pSession)
12156 {
12157 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12158 return eHAL_STATUS_FAILURE;
12159 }
12160
Jeff Johnson295189b2012-06-20 16:38:30 -070012161 if(pLen)
12162 {
12163 len = *pLen;
12164 *pLen = pSession->nWapiRspIeLength;
12165 if(pBuf)
12166 {
12167 if(len >= pSession->nWapiRspIeLength)
12168 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012169 vos_mem_copy(pBuf, pSession->pWapiRspIE,
12170 pSession->nWapiRspIeLength);
12171 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012172 }
12173 }
12174 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012175 return (status);
12176}
12177#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012178eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
12179{
12180 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
12181 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012182
12183 if(!pSession)
12184 {
12185 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12186 return (retStatus);
12187 }
12188
Jeff Johnson295189b2012-06-20 16:38:30 -070012189 if(CSR_IS_ROAMING(pSession))
12190 {
12191 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
12192 pSession->fRoaming = eANI_BOOLEAN_FALSE;
12193 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012194 return (retStatus);
12195}
12196
Jeff Johnson295189b2012-06-20 16:38:30 -070012197//This function remove the connected BSS from te cached scan result
12198eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
12199 tCsrRoamConnectedProfile *pConnProfile)
12200{
12201 eHalStatus status = eHAL_STATUS_FAILURE;
12202 tCsrScanResultFilter *pScanFilter = NULL;
12203 tListElem *pEntry;
12204 tCsrScanResult *pResult;
12205 tDot11fBeaconIEs *pIes;
12206 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070012207 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
12208 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
12209 {
12210 do
12211 {
12212 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
Kiet Lam64c1b492013-07-12 13:56:44 +053012213 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
12214 if ( NULL == pScanFilter )
12215 status = eHAL_STATUS_FAILURE;
12216 else
12217 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012218 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012219 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
12220 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
12221 if ( NULL == pScanFilter->BSSIDs.bssid )
12222 status = eHAL_STATUS_FAILURE;
12223 else
12224 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012225 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012226 vos_mem_copy(pScanFilter->BSSIDs.bssid, &pConnProfile->bssid,
12227 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012228 pScanFilter->BSSIDs.numOfBSSIDs = 1;
12229 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
12230 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012231 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
12232 if ( NULL == pScanFilter->SSIDs.SSIDList )
12233 status = eHAL_STATUS_FAILURE;
12234 else
12235 status = eHAL_STATUS_SUCCESS;
12236 if (!HAL_STATUS_SUCCESS(status)) break;
12237 vos_mem_copy(&pScanFilter->SSIDs.SSIDList[0].SSID,
12238 &pConnProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012239 }
12240 pScanFilter->authType.numEntries = 1;
12241 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
12242 pScanFilter->BSSType = pConnProfile->BSSType;
12243 pScanFilter->EncryptionType.numEntries = 1;
12244 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
12245 pScanFilter->mcEncryptionType.numEntries = 1;
12246 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
12247 //We ignore the channel for now, BSSID should be enough
12248 pScanFilter->ChannelInfo.numOfChannels = 0;
12249 //Also ignore the following fields
12250 pScanFilter->uapsd_mask = 0;
12251 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
12252 pScanFilter->countryCode[0] = 0;
12253 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012254 csrLLLock(&pMac->scan.scanResultList);
12255 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
12256 while( pEntry )
12257 {
12258 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
12259 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
12260 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
12261 pScanFilter, NULL, NULL, NULL, &pIes);
12262 //Release the IEs allocated by csrMatchBSS is needed
12263 if( !pResult->Result.pvIes )
12264 {
12265 //need to free the IEs since it is allocated by csrMatchBSS
Kiet Lam64c1b492013-07-12 13:56:44 +053012266 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012267 }
12268 if(fMatch)
12269 {
12270 //We found the one
12271 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
12272 {
12273 //Free the memory
12274 csrFreeScanResultEntry( pMac, pResult );
12275 }
12276 break;
12277 }
12278 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
12279 }//while
12280 csrLLUnlock(&pMac->scan.scanResultList);
12281 }while(0);
12282 if(pScanFilter)
12283 {
12284 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +053012285 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012286 }
12287 }
12288 return (status);
12289}
12290
Jeff Johnson295189b2012-06-20 16:38:30 -070012291//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070012292eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
12293{
12294 eHalStatus status = eHAL_STATUS_SUCCESS;
12295 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012296 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
12297 {
12298 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
12299 {
12300 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
12301 {
12302 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012303 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012304 status = eHAL_STATUS_CSR_WRONG_STATE;
12305 break;
12306 }
12307 if( csrIsConnStateInfra( pMac, sessionId ) )
12308 {
12309 if( chnId &&
12310 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
12311 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012312 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070012313 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
12314 status = eHAL_STATUS_CSR_WRONG_STATE;
12315 break;
12316 }
12317 }
12318 }
12319 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012320 return ( status );
12321}
12322
Jeff Johnson295189b2012-06-20 16:38:30 -070012323static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
12324{
12325 eHalStatus status = eHAL_STATUS_SUCCESS;
12326 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12327 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012328
12329 if(!pSession)
12330 {
12331 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12332 return eHAL_STATUS_FAILURE;
12333 }
12334
Jeff Johnson295189b2012-06-20 16:38:30 -070012335 if ( csrIsConnStateIbss( pMac, sessionId ) )
12336 {
12337 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
12338 }
12339 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
12340 {
12341 // Disassociate from the connected Infrastructure network...
12342 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
12343 }
12344 else
12345 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012346 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
12347 //Otherwise we need to add code to handle the
12348 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
12349 //send stop_bss to PE, before we can continue.
12350 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012351 vos_mem_set(&bssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012352 /* Assume HDD provide bssid in profile */
Kiet Lam64c1b492013-07-12 13:56:44 +053012353 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0],
12354 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012355 // there is no Bss description before we start an WDS so we need
12356 // to adopt all Bss configuration parameters from the Profile.
12357 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
12358 if(HAL_STATUS_SUCCESS(status))
12359 {
12360 //Save profile for late use
12361 csrFreeRoamProfile( pMac, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +053012362 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
12363 if (pSession->pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -070012364 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012365 vos_mem_set(pSession->pCurRoamProfile,
12366 sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012367 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
12368 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012369 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070012370 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012371 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
12372 NULL, &bssConfig,
12373 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012374 }
12375 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012376
Jeff Johnson295189b2012-06-20 16:38:30 -070012377 return( status );
12378}
12379
Jeff Johnson295189b2012-06-20 16:38:30 -070012380////////////////////Mail box
12381
Jeff Johnson295189b2012-06-20 16:38:30 -070012382//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
12383//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012384static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
12385 tSirBssDescription *pBssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -070012386 tANI_U8 *pBuf, tANI_U8 uapsdMask)
12387{
12388 tCsrChannelSet channelGroup;
12389 tSirMacCapabilityInfo *pAP_capabilityInfo;
12390 tAniBool fTmp;
12391 tANI_BOOLEAN found = FALSE;
12392 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012393 tANI_S8 pwrLimit = 0;
12394 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070012395 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
12396 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
12397 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
12398 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070012399 // 802.11h
12400 //We can do this because it is in HOST CPU order for now.
12401 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080012402 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
12403 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
12404 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012405 fTmp = (tAniBool)pal_cpu_to_be32(1);
12406 }
12407 else
12408 fTmp = (tAniBool)0;
12409
12410 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
Kiet Lam64c1b492013-07-12 13:56:44 +053012411 vos_mem_copy(pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool));
Jeff Johnson295189b2012-06-20 16:38:30 -070012412 pBuf += sizeof(tAniBool);
12413 *pBuf++ = MIN_STA_PWR_CAP_DBM; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012414 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070012415 // This is required for 11k test VoWiFi Ent: Test 2.
12416 // We need the power capabilities for Assoc Req.
12417 // This macro is provided by the halPhyCfg.h. We pick our
12418 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080012419 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
12420 if (0 != pwrLimit)
12421 {
12422 *pBuf++ = pwrLimit;
12423 }
12424 else
12425 {
12426 *pBuf++ = MAX_STA_PWR_CAP_DBM;
12427 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012428 size = sizeof(pMac->roam.validChannelList);
12429 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
12430 {
12431 *pBuf++ = (tANI_U8)size; //tSirSupChnl->numChnl
12432 for ( i = 0; i < size; i++)
12433 {
12434 *pBuf++ = pMac->roam.validChannelList[ i ]; //tSirSupChnl->channelList[ i ]
12435
12436 }
12437 }
12438 else
12439 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012440 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012441 *pBuf++ = 0; //tSirSupChnl->numChnl
12442 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012443 //Check whether it is ok to enter UAPSD
12444#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12445 if( btcIsReadyForUapsd(pMac) )
12446#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12447 {
12448 *pBuf++ = uapsdMask;
12449 }
12450#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12451 else
12452 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012453 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070012454 *pBuf++ = 0;
12455 }
12456#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12457
Jeff Johnson295189b2012-06-20 16:38:30 -070012458 // move the entire BssDescription into the join request.
Kiet Lam64c1b492013-07-12 13:56:44 +053012459 vos_mem_copy(pBuf, pBssDescription,
12460 pBssDescription->length + sizeof( pBssDescription->length ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012461 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
12462}
12463
Jeff Johnson295189b2012-06-20 16:38:30 -070012464/*
12465 * The communication between HDD and LIM is thru mailbox (MB).
12466 * Both sides will access the data structure "tSirSmeJoinReq".
12467 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
12468 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
12469 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
12470 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
12471 */
12472eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012473 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012474{
12475 eHalStatus status = eHAL_STATUS_SUCCESS;
12476 tSirSmeJoinReq *pMsg;
12477 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012478 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070012479 tANI_U16 msgLen, wTmp, ieLen;
12480 tSirMacRateSet OpRateSet;
12481 tSirMacRateSet ExRateSet;
12482 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12483 tANI_U32 dwTmp;
12484 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012485 tANI_U32 ucDot11Mode = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012486
12487 if(!pSession)
12488 {
12489 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12490 return eHAL_STATUS_FAILURE;
12491 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012492 /* To satisfy klockworks */
12493 if (NULL == pBssDescription)
12494 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012495 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012496 return eHAL_STATUS_FAILURE;
12497 }
12498
Jeff Johnson295189b2012-06-20 16:38:30 -070012499 do {
12500 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
12501 pSession->joinFailStatusCode.reasonCode = 0;
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -070012502 memcpy (&pSession->joinFailStatusCode.bssId, &pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012503 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
12504 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
12505 // IE fields, but the length field in the bssDescription needs to be interpreted to
12506 // determine length of the IE fields.
12507 //
12508 // So, take the size of the JoinReq, subtract the size of the bssDescription and
12509 // add in the length from the bssDescription (then add the size of the 'length' field
12510 // itself because that is NOT included in the length field).
12511 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
12512 pBssDescription->length + sizeof( pBssDescription->length ) +
12513 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 +053012514 pMsg = vos_mem_malloc(msgLen);
12515 if (NULL == pMsg)
12516 status = eHAL_STATUS_FAILURE;
12517 else
12518 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012519 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012520 vos_mem_set(pMsg, msgLen , 0);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012521 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012522 pMsg->length = pal_cpu_to_be16(msgLen);
12523 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012524 // sessionId
12525 *pBuf = (tANI_U8)sessionId;
12526 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012527 // transactionId
12528 *pBuf = 0;
12529 *( pBuf + 1 ) = 0;
12530 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012531 // ssId
12532 if( pIes->SSID.present && pIes->SSID.num_ssid )
12533 {
12534 // ssId len
12535 *pBuf = pIes->SSID.num_ssid;
12536 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053012537 vos_mem_copy(pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -070012538 pBuf += pIes->SSID.num_ssid;
12539 }
12540 else
12541 {
12542 *pBuf = 0;
12543 pBuf++;
12544 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012545 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053012546 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
12547 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012548 pBuf += sizeof(tSirMacAddr);
12549 // bsstype
12550 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
12551 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
Kiet Lam64c1b492013-07-12 13:56:44 +053012552 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070012553 pBuf += sizeof(tSirBssType);
12554 // dot11mode
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012555 ucDot11Mode = csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
12556 if (pBssDescription->channelId <= 14 &&
12557 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
12558 WNI_CFG_DOT11_MODE_11AC == ucDot11Mode)
12559 {
12560 //Need to disable VHT operation in 2.4 GHz band
12561 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
12562 }
12563 *pBuf = (tANI_U8)ucDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -070012564 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012565 //Persona
12566 *pBuf = (tANI_U8)pProfile->csrPersona;
12567 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070012568 //CBMode
12569 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
12570 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012571
12572 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -070012573 FL("CSR PERSONA=%d CSR CbMode %d"), pProfile->csrPersona, pSession->bssParams.cbMode);
12574
Jeff Johnson295189b2012-06-20 16:38:30 -070012575 // uapsdPerAcBitmask
12576 *pBuf = pProfile->uapsd_mask;
12577 pBuf++;
12578
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012579
12580
Jeff Johnson295189b2012-06-20 16:38:30 -070012581 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012582 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012583 {
12584 // OperationalRateSet
12585 if (OpRateSet.numRates) {
12586 *pBuf++ = OpRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012587 vos_mem_copy(pBuf, OpRateSet.rate, OpRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012588 pBuf += OpRateSet.numRates;
12589 } else *pBuf++ = 0;
12590 // ExtendedRateSet
12591 if (ExRateSet.numRates) {
12592 *pBuf++ = ExRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012593 vos_mem_copy(pBuf, ExRateSet.rate, ExRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012594 pBuf += ExRateSet.numRates;
12595 } else *pBuf++ = 0;
12596 }
12597 else
12598 {
12599 *pBuf++ = 0;
12600 *pBuf++ = 0;
12601 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012602 // rsnIE
12603 if ( csrIsProfileWpa( pProfile ) )
12604 {
12605 // Insert the Wpa IE into the join request
12606 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
12607 (tCsrWpaIe *)( wpaRsnIE ) );
12608 }
12609 else if( csrIsProfileRSN( pProfile ) )
12610 {
12611 // Insert the RSN IE into the join request
12612 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12613 (tCsrRSNIe *)( wpaRsnIE ) );
12614 }
12615#ifdef FEATURE_WLAN_WAPI
12616 else if( csrIsProfileWapi( pProfile ) )
12617 {
12618 // Insert the WAPI IE into the join request
12619 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12620 (tCsrWapiIe *)( wpaRsnIE ) );
12621 }
12622#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012623 else
12624 {
12625 ieLen = 0;
12626 }
12627 //remember the IE for future use
12628 if( ieLen )
12629 {
12630 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
12631 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012632 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 -070012633 ieLen = DOT11F_IE_RSN_MAX_LEN;
12634 }
12635#ifdef FEATURE_WLAN_WAPI
12636 if( csrIsProfileWapi( pProfile ) )
12637 {
12638 //Check whether we need to allocate more memory
12639 if(ieLen > pSession->nWapiReqIeLength)
12640 {
12641 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
12642 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012643 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012644 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012645 pSession->pWapiReqIE = vos_mem_malloc(ieLen);
12646 if (NULL == pSession->pWapiReqIE)
12647 status = eHAL_STATUS_FAILURE;
12648 else
12649 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012650 if(!HAL_STATUS_SUCCESS(status)) break;
12651 }
12652 pSession->nWapiReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012653 vos_mem_copy(pSession->pWapiReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012654 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012655 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012656 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012657 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012658 pBuf += ieLen;
12659 }
12660 else//should be WPA/WPA2 otherwise
12661#endif /* FEATURE_WLAN_WAPI */
12662 {
12663 //Check whether we need to allocate more memory
12664 if(ieLen > pSession->nWpaRsnReqIeLength)
12665 {
12666 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
12667 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012668 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012669 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012670 pSession->pWpaRsnReqIE = vos_mem_malloc(ieLen);
12671 if (NULL == pSession->pWpaRsnReqIE)
12672 status = eHAL_STATUS_FAILURE;
12673 else
12674 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012675 if(!HAL_STATUS_SUCCESS(status)) break;
12676 }
12677 pSession->nWpaRsnReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012678 vos_mem_copy(pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012679 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012680 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012681 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012682 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012683 pBuf += ieLen;
12684 }
12685 }
12686 else
12687 {
12688 //free whatever old info
12689 pSession->nWpaRsnReqIeLength = 0;
12690 if(pSession->pWpaRsnReqIE)
12691 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012692 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012693 pSession->pWpaRsnReqIE = NULL;
12694 }
12695#ifdef FEATURE_WLAN_WAPI
12696 pSession->nWapiReqIeLength = 0;
12697 if(pSession->pWapiReqIE)
12698 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012699 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012700 pSession->pWapiReqIE = NULL;
12701 }
12702#endif /* FEATURE_WLAN_WAPI */
12703 //length is two bytes
12704 *pBuf = 0;
12705 *(pBuf + 1) = 0;
12706 pBuf += 2;
12707 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012708#ifdef FEATURE_WLAN_ESE
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012709 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012710 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012711 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070012712 //length is two bytes
12713 *pBuf = 0;
12714 *(pBuf + 1) = 0;
12715 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012716 }
12717 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012718 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012719 // cckmIE
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012720 if( csrIsProfileESE( pProfile ) )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012721 {
12722 // Insert the CCKM IE into the join request
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012723#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070012724 ieLen = pSession->suppCckmIeInfo.cckmIeLen;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080012725 vos_mem_copy((void *) (wpaRsnIE),
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070012726 pSession->suppCckmIeInfo.cckmIe, ieLen);
12727#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012728 ieLen = csrConstructEseCckmIe( pMac,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012729 pSession,
12730 pProfile,
12731 pBssDescription,
12732 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070012733 pSession->nWpaRsnReqIeLength,
12734 (void *)( wpaRsnIE ) );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012735#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012736 }
12737 else
12738 {
12739 ieLen = 0;
12740 }
12741 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
12742 if( ieLen )
12743 {
12744 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
12745 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012746 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012747 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012748 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012749 pBuf += ieLen;
12750 }
12751 else
12752 {
12753 //Indicate you have no CCKM IE
12754 //length is two bytes
12755 *pBuf = 0;
12756 *(pBuf + 1) = 0;
12757 pBuf += 2;
12758 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012759 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012760#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -070012761 // addIEScan
Agarwal Ashish4f616132013-12-30 23:32:50 +053012762 if (pProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070012763 {
12764 ieLen = pProfile->nAddIEScanLength;
Agarwal Ashish4f616132013-12-30 23:32:50 +053012765 memset(pSession->addIEScan, 0 , pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070012766 pSession->nAddIEScanLength = ieLen;
Agarwal Ashish4f616132013-12-30 23:32:50 +053012767 vos_mem_copy(pSession->addIEScan, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012768 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012769 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012770 pBuf += sizeof(tANI_U16);
Agarwal Ashish4f616132013-12-30 23:32:50 +053012771 vos_mem_copy(pBuf, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012772 pBuf += ieLen;
12773 }
12774 else
12775 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053012776 memset(pSession->addIEScan, 0, pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070012777 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012778 *pBuf = 0;
12779 *(pBuf + 1) = 0;
12780 pBuf += 2;
12781 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012782 // addIEAssoc
12783 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
12784 {
12785 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070012786 if(ieLen > pSession->nAddIEAssocLength)
12787 {
12788 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
Kiet Lam64c1b492013-07-12 13:56:44 +053012789 {
12790 vos_mem_free(pSession->pAddIEAssoc);
12791 }
12792 pSession->pAddIEAssoc = vos_mem_malloc(ieLen);
12793 if (NULL == pSession->pAddIEAssoc)
12794 status = eHAL_STATUS_FAILURE;
12795 else
12796 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012797 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012798 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012799 pSession->nAddIEAssocLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012800 vos_mem_copy(pSession->pAddIEAssoc, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012801 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012802 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012803 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012804 vos_mem_copy(pBuf, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012805 pBuf += ieLen;
12806 }
12807 else
12808 {
12809 pSession->nAddIEAssocLength = 0;
12810 if(pSession->pAddIEAssoc)
12811 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012812 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070012813 pSession->pAddIEAssoc = NULL;
12814 }
12815 *pBuf = 0;
12816 *(pBuf + 1) = 0;
12817 pBuf += 2;
12818 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012819
12820 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012821 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012822 //Unmask any AC in reassoc that is ACM-set
12823 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
12824 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012825 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012826 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
12827 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012828#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012829 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012830#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012831 uapsd_mask &= ~(acm_mask);
12832 }
12833 else
12834 {
12835 uapsd_mask = 0;
12836 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012837 }
12838 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012839
Jeff Johnson295189b2012-06-20 16:38:30 -070012840 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012841 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012842 pBuf += sizeof(tANI_U32);
12843
Jeff Johnson295189b2012-06-20 16:38:30 -070012844 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012845 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012846 pBuf += sizeof(tANI_U32);
Chet Lanctot186b5732013-03-18 10:26:30 -070012847#ifdef WLAN_FEATURE_11W
12848 //MgmtEncryption
12849 if (pProfile->MFPEnabled)
12850 {
12851 dwTmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
12852 }
12853 else
12854 {
12855 dwTmp = pal_cpu_to_be32(eSIR_ED_NONE);
12856 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012857 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Chet Lanctot186b5732013-03-18 10:26:30 -070012858 pBuf += sizeof(tANI_U32);
12859#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012860#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012861 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053012862 if (csrIsProfile11r( pProfile )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012863#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala09dd66b2013-04-01 17:13:01 +053012864 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012865 (pIes->ESEVersion.present) && (pMac->roam.configParam.isEseIniFeatureEnabled))
Saurabh Gupta775073c2013-02-14 13:31:36 +053012866#endif
12867 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012868 {
12869 // is11Rconnection;
12870 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012871 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool)) ;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012872 pBuf += sizeof(tAniBool);
12873 }
12874 else
12875 {
12876 // is11Rconnection;
12877 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012878 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012879 pBuf += sizeof(tAniBool);
12880 }
12881#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012882#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012883
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012884 // isESEFeatureIniEnabled
12885 if (TRUE == pMac->roam.configParam.isEseIniFeatureEnabled)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012886 {
12887 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012888 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012889 pBuf += sizeof(tAniBool);
12890 }
12891 else
12892 {
12893 dwTmp = pal_cpu_to_be32(FALSE);
Srinivas Girigowda18112782013-11-27 12:21:19 -080012894 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012895 pBuf += sizeof(tAniBool);
12896 }
12897
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012898 /* A profile can not be both ESE and 11R. But an 802.11R AP
12899 * may be advertising support for ESE as well. So if we are
12900 * associating Open or explicitly ESE then we will get ESE.
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012901 * If we are associating explictly 11R only then we will get
12902 * 11R.
12903 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012904 if ((csrIsProfileESE(pProfile) ||
12905 ((pIes->ESEVersion.present)
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012906 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012907 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
12908 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
12909 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -070012910#ifdef WLAN_FEATURE_11W
12911 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
12912#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012913 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012914 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012915 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012916 // isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012917 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012918 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012919 pBuf += sizeof(tAniBool);
12920 }
12921 else
12922 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012923 //isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012924 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012925 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012926 pBuf += sizeof(tAniBool);
12927 }
12928
12929 if (eWNI_SME_JOIN_REQ == messageType)
12930 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012931 tESETspecInfo eseTspec;
12932 // ESE-Tspec IEs in the ASSOC request is presently not supported
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012933 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012934 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
12935 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
12936 pBuf += sizeof(tESETspecInfo);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012937 }
12938 else if (eWNI_SME_REASSOC_REQ == messageType)
12939 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012940 if ((csrIsProfileESE(pProfile) ||
12941 ((pIes->ESEVersion.present)
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012942 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012943 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
12944 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
12945 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -070012946#ifdef WLAN_FEATURE_11W
12947 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
12948#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012949 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012950 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070012951 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012952 tESETspecInfo eseTspec;
12953 // ESE Tspec information
12954 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
12955 eseTspec.numTspecs = sme_QosESERetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &eseTspec.tspec[0]);
12956 *pBuf = eseTspec.numTspecs;
Jeff Johnson295189b2012-06-20 16:38:30 -070012957 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070012958 // Copy the TSPEC information only if present
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012959 if (eseTspec.numTspecs) {
12960 vos_mem_copy(pBuf, (void*)&eseTspec.tspec[0],
12961 (eseTspec.numTspecs*sizeof(tTspecInfo)));
Jeff Johnson295189b2012-06-20 16:38:30 -070012962 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012963 pBuf += sizeof(eseTspec.tspec);
Jeff Johnson295189b2012-06-20 16:38:30 -070012964 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012965 else
Jeff Johnson295189b2012-06-20 16:38:30 -070012966 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012967 tESETspecInfo eseTspec;
12968 // ESE-Tspec IEs in the ASSOC request is presently not supported
Jeff Johnson295189b2012-06-20 16:38:30 -070012969 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012970 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
12971 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
12972 pBuf += sizeof(tESETspecInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070012973 }
12974 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012975#endif // FEATURE_WLAN_ESE
12976#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070012977 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012978 if (pMac->roam.configParam.isFastTransitionEnabled
12979#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053012980 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012981#endif
12982 )
Jeff Johnson295189b2012-06-20 16:38:30 -070012983 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012984 dwTmp = pal_cpu_to_be32(TRUE);
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);
Jeff Johnson295189b2012-06-20 16:38:30 -070012987 }
12988 else
12989 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012990 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012991 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012992 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070012993 }
12994#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070012995#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053012996 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070012997 {
12998 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012999 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013000 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013001 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070013002 }
13003 else
13004 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013005 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013006 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013007 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070013008 }
13009#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013010
13011 // txLdpcIniFeatureEnabled
13012 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
13013 pBuf++;
13014
Kiran4a17ebe2013-01-31 10:43:43 -080013015 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
13016 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
13017 {
13018 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
13019 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
13020 csrApplyPower2Current(pMac);
13021 }
13022
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080013023#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080013024 // txBFIniFeatureEnabled
13025 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
13026 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080013027
13028 // txBFCsnValue
13029 *pBuf = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
13030 pBuf++;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080013031#endif
krunal soni5afa96c2013-09-06 22:19:02 -070013032 *pBuf = (tANI_U8)pMac->roam.configParam.isAmsduSupportInAMPDU;
13033 pBuf++;
13034
Sandeep Puligillaaea98a22013-12-04 13:36:32 +053013035 // WME
13036 if(pMac->roam.roamSession[sessionId].fWMMConnection)
13037 {
13038 //WME enabled
13039 dwTmp = pal_cpu_to_be32(TRUE);
13040 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13041 pBuf += sizeof(tAniBool);
13042 }
13043 else
13044 {
13045 dwTmp = pal_cpu_to_be32(FALSE);
13046 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13047 pBuf += sizeof(tAniBool);
13048 }
13049
13050 // QOS
13051 if(pMac->roam.roamSession[sessionId].fQOSConnection)
13052 {
13053 //QOS enabled
13054 dwTmp = pal_cpu_to_be32(TRUE);
13055 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13056 pBuf += sizeof(tAniBool);
13057 }
13058 else
13059 {
13060 dwTmp = pal_cpu_to_be32(FALSE);
13061 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13062 pBuf += sizeof(tAniBool);
13063 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013064 //BssDesc
13065 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
13066 (tANI_U8)pProfile->uapsd_mask);
krunal soni5afa96c2013-09-06 22:19:02 -070013067
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013068 status = palSendMBMessage(pMac->hHdd, pMsg );
13069 if(!HAL_STATUS_SUCCESS(status))
13070 {
13071 break;
13072 }
13073 else
13074 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013075#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013076 if (eWNI_SME_JOIN_REQ == messageType)
13077 {
13078 //Tush-QoS: notify QoS module that join happening
13079 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
13080 }
13081 else if (eWNI_SME_REASSOC_REQ == messageType)
13082 {
13083 //Tush-QoS: notify QoS module that reassoc happening
13084 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
13085 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013086#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013087 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013088 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013089 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013090}
13091
Jeff Johnson295189b2012-06-20 16:38:30 -070013092//
13093eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13094{
13095 eHalStatus status = eHAL_STATUS_SUCCESS;
13096 tSirSmeDisassocReq *pMsg;
13097 tANI_U8 *pBuf;
13098 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013099 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13100 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13101 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013102 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013103 pMsg = vos_mem_malloc(sizeof(tSirSmeDisassocReq));
13104 if (NULL == pMsg)
13105 status = eHAL_STATUS_FAILURE;
13106 else
13107 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013108 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013109 vos_mem_set(pMsg, sizeof( tSirSmeDisassocReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013110 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
13111 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013112 pBuf = &pMsg->sessionId;
13113 // sessionId
13114 *pBuf++ = (tANI_U8)sessionId;
13115 // transactionId
13116 *pBuf = 0;
13117 *( pBuf + 1 ) = 0;
13118 pBuf += sizeof(tANI_U16);
13119
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053013120 if ( (pSession->pCurRoamProfile != NULL) &&
13121 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
13122 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013123 {
13124 // Set the bssid address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013125 vos_mem_copy((tSirMacAddr *)pBuf, pSession->selfMacAddr,
13126 sizeof( tSirMacAddr ));
13127 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013128 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070013129 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013130 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
13131 //perMacAddr is passed as bssId for softAP
13132 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013133 pBuf = pBuf + sizeof ( tSirMacAddr );
13134 }
13135 else
13136 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013137 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013138 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
13139 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013140 pBuf = pBuf + sizeof ( tSirMacAddr );
Kiet Lam64c1b492013-07-12 13:56:44 +053013141 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ));
13142 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013143 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070013144 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013145 if(!HAL_STATUS_SUCCESS(status))
13146 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013147 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013148 break;
13149 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013150 // reasonCode
13151 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013152 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
13153 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013154 if(!HAL_STATUS_SUCCESS(status))
13155 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013156 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013157 break;
13158 }
13159 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013160 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
13161 Here we should not send the disassoc over the air to the AP */
13162 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
13163#ifdef WLAN_FEATURE_VOWIFI_11R
13164 && csrRoamIs11rAssoc(pMac)
13165#endif
13166 )
13167 {
13168 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
13169 }
13170 pBuf += sizeof(tANI_U8);
13171 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013172 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013173 return( status );
13174}
Jeff Johnson295189b2012-06-20 16:38:30 -070013175eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
13176{
13177 eHalStatus status = eHAL_STATUS_SUCCESS;
13178 tSirSmeTkipCntrMeasReq *pMsg;
13179 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013180 do
13181 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013182 pMsg = vos_mem_malloc(sizeof( tSirSmeTkipCntrMeasReq ));
13183 if ( NULL == pMsg )
13184 status = eHAL_STATUS_FAILURE;
13185 else
13186 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013187 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013188 vos_mem_set(pMsg, sizeof( tSirSmeTkipCntrMeasReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013189 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
13190 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013191 pBuf = &pMsg->sessionId;
13192 // sessionId
13193 *pBuf++ = (tANI_U8)sessionId;
13194 // transactionId
13195 *pBuf = 0;
13196 *( pBuf + 1 ) = 0;
13197 pBuf += sizeof(tANI_U16);
13198 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053013199 vos_mem_copy(pMsg->bssId, bssId, sizeof( tSirMacAddr ));
13200 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013201 pBuf = pBuf + sizeof ( tSirMacAddr );
13202 // bEnable
13203 *pBuf = (tANI_BOOLEAN)bEnable;
13204 if(!HAL_STATUS_SUCCESS(status))
13205 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013206 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013207 break;
13208 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013209 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013210 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013211 return( status );
13212}
Jeff Johnson295189b2012-06-20 16:38:30 -070013213eHalStatus
13214csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
13215 VOS_MODULE_ID modId, tSirMacAddr bssId,
13216 void *pUsrContext, void *pfnSapEventCallback,
13217 tANI_U8 *pAssocStasBuf )
13218{
13219 eHalStatus status = eHAL_STATUS_SUCCESS;
13220 tSirSmeGetAssocSTAsReq *pMsg;
13221 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
13222 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013223 do
13224 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013225 pMsg = vos_mem_malloc(sizeof( tSirSmeGetAssocSTAsReq ));
13226 if ( NULL == pMsg )
13227 status = eHAL_STATUS_FAILURE;
13228 else
13229 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013230 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013231 vos_mem_set(pMsg, sizeof( tSirSmeGetAssocSTAsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013232 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013233 pBuf = (tANI_U8 *)&pMsg->bssId;
13234 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013235 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013236 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013237 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013238 // modId
13239 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013240 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013241 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013242 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080013243 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void *));
13244 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013245 // pfnSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080013246 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void*));
13247 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013248 // pAssocStasBuf
krunal soni4f802b22014-02-11 17:01:13 -080013249 vos_mem_copy(pBuf, pAssocStasBuf, sizeof(void*));
13250 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013251 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013252 status = palSendMBMessage( pMac->hHdd, pMsg );
13253 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013254 return( status );
13255 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013256eHalStatus
13257csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
13258 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
13259 {
13260 eHalStatus status = eHAL_STATUS_SUCCESS;
13261 tSirSmeGetWPSPBCSessionsReq *pMsg;
13262 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
krunal soni4f802b22014-02-11 17:01:13 -080013263
Jeff Johnson295189b2012-06-20 16:38:30 -070013264 do
13265 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013266 pMsg = vos_mem_malloc(sizeof(tSirSmeGetWPSPBCSessionsReq));
13267 if ( NULL == pMsg )
13268 status = eHAL_STATUS_FAILURE;
13269 else
13270 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013271 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013272 vos_mem_set(pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013273 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013274 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
lukez3c809222013-05-03 10:23:02 -070013275 VOS_ASSERT(pBuf);
13276
Jeff Johnson295189b2012-06-20 16:38:30 -070013277 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013278 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080013279 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void*));
13280 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070013281 // pSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080013282 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void *));
13283 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070013284 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013285 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013286 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013287 // MAC Address of STA in WPS session
Kiet Lam64c1b492013-07-12 13:56:44 +053013288 vos_mem_copy((tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
Jeff Johnson295189b2012-06-20 16:38:30 -070013289 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070013290 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013291 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013292 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013293 return( status );
13294}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013295
13296eHalStatus
13297csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
13298{
13299 tpSirChangeBIParams pMsg;
13300 tANI_U16 len = 0;
13301 eHalStatus status = eHAL_STATUS_SUCCESS;
13302 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13303
13304 if(!pSession)
13305 {
13306 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13307 return eHAL_STATUS_FAILURE;
13308 }
13309
13310 //NO need to update the Beacon Params if update beacon parameter flag is not set
13311 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
13312 return eHAL_STATUS_SUCCESS;
13313
13314 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
13315
13316 /* Create the message and send to lim */
13317 len = sizeof(tSirChangeBIParams);
Kiet Lam64c1b492013-07-12 13:56:44 +053013318 pMsg = vos_mem_malloc(len);
13319 if ( NULL == pMsg )
13320 status = eHAL_STATUS_FAILURE;
13321 else
13322 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013323 if(HAL_STATUS_SUCCESS(status))
13324 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013325 vos_mem_set(pMsg, sizeof(tSirChangeBIParams), 0);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013326 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
13327 pMsg->length = len;
13328
13329 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013330 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
13331 sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -080013332 smsLog( pMac, LOG1, FL("CSR Attempting to change BI for Bssid= "MAC_ADDRESS_STR),
13333 MAC_ADDR_ARRAY(pMsg->bssId));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013334 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013335 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013336 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
13337 status = palSendMBMessage(pMac->hHdd, pMsg);
13338 }
13339 return status;
13340}
13341
Jeff Johnson295189b2012-06-20 16:38:30 -070013342eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13343{
13344 eHalStatus status = eHAL_STATUS_SUCCESS;
13345 tSirSmeDeauthReq *pMsg;
13346 tANI_U8 *pBuf;
13347 tANI_U16 wTmp;
13348 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13349 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13350 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013351 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013352 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthReq ));
13353 if ( NULL == pMsg )
13354 status = eHAL_STATUS_FAILURE;
13355 else
13356 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013357 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013358 vos_mem_set(pMsg, sizeof( tSirSmeDeauthReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013359 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
13360 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
13361 //sessionId
13362 pBuf = &pMsg->sessionId;
13363 *pBuf++ = (tANI_U8)sessionId;
13364
13365 //tansactionId
13366 *pBuf = 0;
13367 *(pBuf + 1 ) = 0;
13368 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013369 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070013370 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070013371 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
13372 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013373 vos_mem_copy( (tSirMacAddr *)pBuf, pSession->selfMacAddr,
13374 sizeof( pMsg->peerMacAddr ) );
13375 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013376 pBuf = pBuf + sizeof(tSirMacAddr);
13377 }
13378 else
13379 {
13380 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013381 vos_mem_copy( (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13382 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013383 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013384 }
13385 if(!HAL_STATUS_SUCCESS(status))
13386 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013387 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013388 break;
13389 }
13390 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013391 vos_mem_copy( (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13392 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013393 pBuf = pBuf + sizeof(tSirMacAddr);
13394 if(!HAL_STATUS_SUCCESS(status))
13395 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013396 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013397 break;
13398 }
13399 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013400 vos_mem_copy( pBuf, &wTmp,sizeof( tANI_U16 ) );
13401 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013402 if(!HAL_STATUS_SUCCESS(status))
13403 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013404 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013405 break;
13406 }
13407 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013408 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013409 return( status );
13410}
13411
Jeff Johnson295189b2012-06-20 16:38:30 -070013412eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
13413{
13414 eHalStatus status = eHAL_STATUS_SUCCESS;
13415 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013416 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013417 pMsg = vos_mem_malloc(sizeof( tSirSmeDisassocCnf ));
13418 if ( NULL == pMsg )
13419 status = eHAL_STATUS_FAILURE;
13420 else
13421 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013422 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013423 vos_mem_set(pMsg, sizeof( tSirSmeDisassocCnf), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013424 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
13425 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13426 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013427 vos_mem_copy(pMsg->peerMacAddr, pDisassocInd->peerMacAddr,
13428 sizeof(pMsg->peerMacAddr));
13429 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013430 if(!HAL_STATUS_SUCCESS(status))
13431 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013432 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013433 break;
13434 }
13435//To test reconn
Kiet Lam64c1b492013-07-12 13:56:44 +053013436 vos_mem_copy(pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
13437 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013438 if(!HAL_STATUS_SUCCESS(status))
13439 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013440 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013441 break;
13442 }
13443//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070013444 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013445 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013446 return( status );
13447}
13448
Jeff Johnson295189b2012-06-20 16:38:30 -070013449eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
13450{
13451 eHalStatus status = eHAL_STATUS_SUCCESS;
13452 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013453 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013454 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthCnf ));
13455 if ( NULL == pMsg )
13456 status = eHAL_STATUS_FAILURE;
13457 else
13458 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013459 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013460 vos_mem_set(pMsg, sizeof( tSirSmeDeauthCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013461 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
13462 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13463 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013464 vos_mem_copy(pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
13465 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013466 if(!HAL_STATUS_SUCCESS(status))
13467 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013468 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013469 break;
13470 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013471 vos_mem_copy(pMsg->peerMacAddr, pDeauthInd->peerMacAddr,
13472 sizeof(pMsg->peerMacAddr));
13473 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013474 if(!HAL_STATUS_SUCCESS(status))
13475 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013476 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013477 break;
13478 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013479 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013480 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013481 return( status );
13482}
Jeff Johnson295189b2012-06-20 16:38:30 -070013483eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
13484{
13485 eHalStatus status = eHAL_STATUS_SUCCESS;
13486 tSirSmeAssocCnf *pMsg;
13487 tANI_U8 *pBuf;
13488 tSirResultCodes statusCode;
13489 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013490 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013491 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocCnf ));
13492 if ( NULL == pMsg )
13493 status = eHAL_STATUS_FAILURE;
13494 else
13495 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013496 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013497 vos_mem_set(pMsg, sizeof( tSirSmeAssocCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013498 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
13499 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013500 pBuf = (tANI_U8 *)&pMsg->statusCode;
13501 if(HAL_STATUS_SUCCESS(Halstatus))
13502 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13503 else
13504 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053013505 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes));
Jeff Johnson295189b2012-06-20 16:38:30 -070013506 pBuf += sizeof(tSirResultCodes);
13507 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013508 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13509 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013510 pBuf += sizeof (tSirMacAddr);
13511 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013512 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13513 sizeof(tSirMacAddr));
13514 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013515 pBuf += sizeof (tSirMacAddr);
13516 // aid
13517 wTmp = pal_cpu_to_be16(pAssocInd->aid);
Kiet Lam64c1b492013-07-12 13:56:44 +053013518 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013519 pBuf += sizeof (tANI_U16);
13520 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013521 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13522 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013523 pBuf += sizeof (tSirMacAddr);
13524 // alternateChannelId
13525 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070013526 status = palSendMBMessage( pMac->hHdd, pMsg );
13527 if(!HAL_STATUS_SUCCESS(status))
13528 {
13529 //pMsg is freed by palSendMBMessage
13530 break;
13531 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013532 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013533 return( status );
13534}
Jeff Johnson295189b2012-06-20 16:38:30 -070013535eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
13536 tpSirSmeAssocInd pAssocInd,
13537 eHalStatus Halstatus,
13538 tANI_U8 sessionId)
13539{
13540 tSirMsgQ msgQ;
Jeff Johnson295189b2012-06-20 16:38:30 -070013541 tSirSmeAssocIndToUpperLayerCnf *pMsg;
13542 tANI_U8 *pBuf;
13543 tSirResultCodes statusCode;
13544 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013545 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013546 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocIndToUpperLayerCnf ));
13547 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13548 vos_mem_set(pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ), 0);
Jeff Johnsone7245742012-09-05 17:12:55 -070013549
Jeff Johnson295189b2012-06-20 16:38:30 -070013550 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
13551 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
13552
13553 pMsg->sessionId = sessionId;
13554
13555 pBuf = (tANI_U8 *)&pMsg->statusCode;
13556 if(HAL_STATUS_SUCCESS(Halstatus))
13557 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13558 else
13559 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053013560 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes)) ;
Jeff Johnson295189b2012-06-20 16:38:30 -070013561 pBuf += sizeof(tSirResultCodes);
13562 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013563 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013564 pBuf += sizeof (tSirMacAddr);
13565 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013566 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13567 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013568 pBuf += sizeof (tSirMacAddr);
13569 // StaId
13570 wTmp = pal_cpu_to_be16(pAssocInd->staId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013571 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013572 pBuf += sizeof (tANI_U16);
13573 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013574 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013575 pBuf += sizeof (tSirMacAddr);
13576 // alternateChannelId
13577 *pBuf = 11;
13578 pBuf += sizeof (tANI_U8);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013579 // Instead of copying roam Info, we just copy only WmmEnabled, RsnIE information
Jeff Johnson295189b2012-06-20 16:38:30 -070013580 //Wmm
13581 *pBuf = pAssocInd->wmmEnabledSta;
13582 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013583 //RSN IE
Kiet Lam64c1b492013-07-12 13:56:44 +053013584 vos_mem_copy((tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070013585 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070013586 //Additional IE
Kiet Lam64c1b492013-07-12 13:56:44 +053013587 vos_mem_copy((void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
Jeff Johnson295189b2012-06-20 16:38:30 -070013588 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070013589 //reassocReq
13590 *pBuf = pAssocInd->reassocReq;
13591 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013592 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
13593 msgQ.bodyptr = pMsg;
13594 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013595 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013596 } while( 0 );
Kiet Lam64c1b492013-07-12 13:56:44 +053013597 return( eHAL_STATUS_SUCCESS );
Jeff Johnson295189b2012-06-20 16:38:30 -070013598}
Jeff Johnson295189b2012-06-20 16:38:30 -070013599
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013600eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -070013601 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
13602 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
13603 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
13604 tANI_U8 *pKeyRsc )
13605{
13606 tSirSmeSetContextReq *pMsg;
13607 tANI_U16 msgLen;
13608 eHalStatus status = eHAL_STATUS_FAILURE;
13609 tAniEdType tmpEdType;
13610 tAniKeyDirection tmpDirection;
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +053013611 tANI_U8 *pBuf = NULL;
13612 tANI_U8 *p = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013613 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013614 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070013615 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013616 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
13617 // key set. Since we only support upto one key, we always allocate memory for 1 key
13618 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
13619 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
13620 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
13621 ( sizeof( pMsg->keyMaterial.key ) );
13622
Kiet Lam64c1b492013-07-12 13:56:44 +053013623 pMsg = vos_mem_malloc(msgLen);
13624 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13625 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013626 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
13627 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013628 //sessionId
13629 pBuf = &pMsg->sessionId;
13630 *pBuf = (tANI_U8)sessionId;
13631 pBuf++;
13632 // transactionId
13633 *pBuf = 0;
13634 *(pBuf + 1) = 0;
13635 pBuf += sizeof(tANI_U16);
13636 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013637 vos_mem_copy(pBuf, (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013638
13639 pBuf += sizeof(tSirMacAddr);
13640
13641 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013642 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
13643 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013644
13645 pBuf += sizeof(tSirMacAddr);
13646
13647 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013648 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
13649 // in the tSirKeyMaterial keyMaterial; field).
13650 //
13651 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
13652 // shorter than this max size. Is LIM interpreting this ok ?
13653 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 -070013654 // set pMsg->keyMaterial.edType
13655 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013656 vos_mem_copy(p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013657 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070013658 // set the pMsg->keyMaterial.numKeys field
13659 *p = numKeys;
13660 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070013661 // set pSirKey->keyId = keyId;
13662 *p = keyId;
13663 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013664 // set pSirKey->unicast = (tANI_U8)fUnicast;
13665 *p = (tANI_U8)fUnicast;
13666 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070013667 // set pSirKey->keyDirection = aniKeyDirection;
13668 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
Kiet Lam64c1b492013-07-12 13:56:44 +053013669 vos_mem_copy(p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection));
Jeff Johnson295189b2012-06-20 16:38:30 -070013670 p += sizeof(tAniKeyDirection);
13671 // pSirKey->keyRsc = ;;
Kiet Lam64c1b492013-07-12 13:56:44 +053013672 vos_mem_copy(p, pKeyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -070013673 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070013674 // set pSirKey->paeRole
13675 *p = paeRole; // 0 is Supplicant
13676 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013677 // set pSirKey->keyLength = keyLength;
13678 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013679 if ( keyLength && pKey )
13680 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013681 vos_mem_copy(p, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013682 if(keyLength == 16)
13683 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013684 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 -070013685 keyId, edType, pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
13686 pKey[5], pKey[6], pKey[7], pKey[8],
13687 pKey[9], pKey[10], pKey[11], pKey[12], pKey[13], pKey[14], pKey[15]);
13688 }
13689 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013690 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013691 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013692 return( status );
13693}
13694
Jeff Johnson295189b2012-06-20 16:38:30 -070013695eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
13696 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
13697{
13698 eHalStatus status;
13699 tSirSmeStartBssReq *pMsg;
13700 tANI_U8 *pBuf = NULL;
13701 tANI_U8 *wTmpBuf = NULL;
13702 tANI_U16 msgLen, wTmp;
13703 tANI_U32 dwTmp;
13704 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070013705 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070013706 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070013707 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013708
13709 if(!pSession)
13710 {
13711 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13712 return eHAL_STATUS_FAILURE;
13713 }
13714
Jeff Johnson295189b2012-06-20 16:38:30 -070013715 do {
13716 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
13717 pSession->joinFailStatusCode.reasonCode = 0;
13718 msgLen = sizeof(tSirSmeStartBssReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053013719 pMsg = vos_mem_malloc(msgLen);
13720 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13721 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013722 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013723 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013724 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013725 //sessionId
13726 *pBuf = (tANI_U8)sessionId;
13727 pBuf++;
13728 // transactionId
13729 *pBuf = 0;
13730 *(pBuf + 1) = 0;
13731 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013732 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053013733 vos_mem_copy(pBuf, pParam->bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013734 pBuf += sizeof(tSirMacAddr);
13735 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013736 vos_mem_copy(pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013737 pBuf += sizeof(tSirMacAddr);
13738 // beaconInterval
13739 if( pBssDesc && pBssDesc->beaconInterval )
13740 {
13741 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
13742 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013743 else if(pParam->beaconInterval)
13744 {
13745 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
13746 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013747 else
13748 {
13749 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
13750 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -070013751 if(csrIsconcurrentsessionValid (pMac, sessionId,
13752 pParam->bssPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -070013753 == eHAL_STATUS_SUCCESS )
13754 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013755 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070013756 pParam->bssPersona);
13757 //Update the beacon Interval
13758 pParam->beaconInterval = wTmp;
13759 }
13760 else
13761 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013762 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070013763 status = eHAL_STATUS_FAILURE;
Kiet Lam64c1b492013-07-12 13:56:44 +053013764 vos_mem_free(pMsg);
Jeff Johnsone7245742012-09-05 17:12:55 -070013765 return status;
13766 }
13767
Kiet Lam64c1b492013-07-12 13:56:44 +053013768 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013769 pBuf += sizeof(tANI_U16);
13770 // dot11mode
13771 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
13772 pBuf += 1;
13773 // bssType
13774 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013775 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013776 pBuf += sizeof(tSirBssType);
13777 // ssId
13778 if( pParam->ssId.length )
13779 {
13780 // ssId len
13781 *pBuf = pParam->ssId.length;
13782 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053013783 vos_mem_copy(pBuf, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070013784 pBuf += pParam->ssId.length;
13785 }
13786 else
13787 {
13788 *pBuf = 0;
13789 pBuf++;
13790 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013791 // set the channel Id
13792 *pBuf = pParam->operationChn;
13793 pBuf++;
13794 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070013795 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013796 vos_mem_copy(pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState));
Jeff Johnsone7245742012-09-05 17:12:55 -070013797 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070013798
Jeff Johnson295189b2012-06-20 16:38:30 -070013799 // Set privacy
13800 *pBuf = pParam->privacy;
13801 pBuf++;
13802
13803 //Set Uapsd
13804 *pBuf = pParam->ApUapsdEnable;
13805 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013806 //Set SSID hidden
13807 *pBuf = pParam->ssidHidden;
13808 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013809 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
13810 pBuf++;
13811
13812 //Ht protection Enable/Disable
13813 *pBuf = (tANI_U8)pParam->protEnabled;
13814 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013815 //Enable Beacons to Receive for OBSS protection Enable/Disable
13816 *pBuf = (tANI_U8)pParam->obssProtEnabled;
13817 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013818 //set cfg related to protection
13819 wTmp = pal_cpu_to_be16( pParam->ht_protection );
Kiet Lam64c1b492013-07-12 13:56:44 +053013820 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013821 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013822 // Set Auth type
13823 authType = pal_cpu_to_be32(pParam->authType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013824 vos_mem_copy(pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013825 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013826 // Set DTIM
13827 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
Kiet Lam64c1b492013-07-12 13:56:44 +053013828 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013829 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013830 // Set wps_state
13831 *pBuf = pParam->wps_state;
13832 pBuf++;
krunal sonie9002db2013-11-25 14:24:17 -080013833 // set isCoalesingInIBSSAllowed
13834 *pBuf = pMac->isCoalesingInIBSSAllowed;
13835 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013836 //Persona
13837 *pBuf = (tANI_U8)pParam->bssPersona;
13838 pBuf++;
13839
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080013840 //txLdpcIniFeatureEnabled
13841 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
13842 pBuf++;
krunal soni4f087d22013-07-29 16:32:26 -070013843
Chet Lanctot8cecea22014-02-11 19:09:36 -080013844#ifdef WLAN_FEATURE_11W
13845 // Set MFP capable/required
13846 *pBuf = (tANI_U8)pParam->mfpCapable;
13847 pBuf++;
13848 *pBuf = (tANI_U8)pParam->mfpRequired;
13849 pBuf++;
13850#endif
13851
krunal soni4f087d22013-07-29 16:32:26 -070013852 // set RSN IE
Jeff Johnson295189b2012-06-20 16:38:30 -070013853 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
13854 {
13855 status = eHAL_STATUS_INVALID_PARAMETER;
Kiet Lam64c1b492013-07-12 13:56:44 +053013856 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013857 break;
13858 }
13859 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
Kiet Lam64c1b492013-07-12 13:56:44 +053013860 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013861 pBuf += sizeof(tANI_U16);
13862 if( wTmp )
13863 {
13864 wTmp = pParam->nRSNIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +053013865 vos_mem_copy(pBuf, pParam->pRSNIE, wTmp);
Jeff Johnson295189b2012-06-20 16:38:30 -070013866 pBuf += wTmp;
13867 }
13868 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013869 vos_mem_copy(pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013870 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070013871 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
13872 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053013873 vos_mem_copy(pBuf, pParam->operationalRateSet.rate,
13874 pParam->operationalRateSet.numRates );
Jeff Johnson295189b2012-06-20 16:38:30 -070013875 pBuf += pParam->operationalRateSet.numRates ;
13876 *pBuf++ = pParam->extendedRateSet.numRates;
13877 if(0 != pParam->extendedRateSet.numRates)
13878 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013879 vos_mem_copy(pBuf, pParam->extendedRateSet.rate,
13880 pParam->extendedRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070013881 pBuf += pParam->extendedRateSet.numRates;
13882 }
krunal sonie9002db2013-11-25 14:24:17 -080013883
Jeff Johnson295189b2012-06-20 16:38:30 -070013884 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
13885 pMsg->length = pal_cpu_to_be16(msgLen);
13886
13887 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013888 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013889 return( status );
13890}
13891
Jeff Johnson295189b2012-06-20 16:38:30 -070013892eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
13893{
13894 eHalStatus status = eHAL_STATUS_FAILURE;
13895 tSirSmeStopBssReq *pMsg;
13896 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13897 tANI_U8 *pBuf;
13898 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013899
13900 if(!pSession)
13901 {
13902 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13903 return eHAL_STATUS_FAILURE;
13904 }
13905
Jeff Johnson295189b2012-06-20 16:38:30 -070013906 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013907 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
13908 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13909 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013910 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13911 pBuf = &pMsg->sessionId;
13912 //sessionId
13913 *pBuf = (tANI_U8)sessionId;
13914 pBuf++;
13915 // transactionId
13916 *pBuf = 0;
13917 pBuf += sizeof(tANI_U16);
13918 //reason code
13919 *pBuf = 0;
13920 pBuf += sizeof(tSirResultCodes);
13921 // bssid
13922 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13923 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13924 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013925 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->selfMacAddr,
13926 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013927 }
13928 else
13929 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013930 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
13931 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013932 }
13933 pBuf += sizeof(tSirMacAddr);
13934 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
13935 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013936 status = palSendMBMessage( pMac->hHdd, pMsg );
13937#if 0
Kiet Lam64c1b492013-07-12 13:56:44 +053013938 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
13939 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13940 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013941 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13942 pMsg->reasonCode = 0;
13943 // bssid
13944 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13945 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13946 {
13947 pbBssid = (tANI_U8 *)&pSession->selfMacAddr;
13948 }
13949 else
13950 {
13951 pbBssid = (tANI_U8 *)&pSession->connectedProfile.bssid;
13952 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013953 vos_mem_copy(&pMsg->bssId, pbBssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013954 pMsg->transactionId = 0;
13955 pMsg->sessionId = (tANI_U8)sessionId;
13956 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeStopBssReq ));
13957 status = palSendMBMessage( pMac->hHdd, pMsg );
13958#endif
13959 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013960 return( status );
13961}
13962
Jeff Johnson295189b2012-06-20 16:38:30 -070013963eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
13964 tCsrRoamModifyProfileFields *pModProfileFields,
13965 tANI_U32 *pRoamId, v_BOOL_t fForce)
13966{
Jeff Johnson295189b2012-06-20 16:38:30 -070013967 eHalStatus status = eHAL_STATUS_FAILURE;
13968 tANI_U32 roamId = 0;
13969 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013970 if((csrIsConnStateConnected(pMac, sessionId)) &&
Kiet Lam64c1b492013-07-12 13:56:44 +053013971 (fForce || (!vos_mem_compare( &pModProfileFields,
13972 &pSession->connectedProfile.modifyProfileFields,
13973 sizeof(tCsrRoamModifyProfileFields)))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013974 {
13975 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
13976 if(pRoamId)
13977 {
13978 *pRoamId = roamId;
13979 }
13980
Jeff Johnson295189b2012-06-20 16:38:30 -070013981 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
13982 eCsrSmeIssuedReassocToSameAP, roamId,
13983 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013984 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013985 return status;
13986}
Jeff Johnson295189b2012-06-20 16:38:30 -070013987static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
13988{
13989 eHalStatus status = eHAL_STATUS_SUCCESS;
13990 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +053013991 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013992 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
13993 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
13994 return (status);
13995}
Jeff Johnson295189b2012-06-20 16:38:30 -070013996eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
13997{
13998 eHalStatus status = eHAL_STATUS_SUCCESS;
13999 tListElem *pEntry = NULL;
14000 tSmeCmd *pCommand = NULL;
14001 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014002 do
14003 {
14004 if(pMsg == NULL)
14005 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014006 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014007 status = eHAL_STATUS_FAILURE;
14008 break;
14009 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014010 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
14011 if(pEntry)
14012 {
14013 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14014 if(eSmeCommandAddStaSession == pCommand->command)
14015 {
14016 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014017 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014018 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070014019 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014020 //Remove this command out of the active list
14021 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
14022 {
14023 //Now put this command back on the avilable command list
14024 csrReleaseCommand(pMac, pCommand);
14025 }
14026 smeProcessPendingQueue( pMac );
14027 }
14028 else
14029 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014030 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 -070014031 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014032 status = eHAL_STATUS_FAILURE;
14033 break;
14034 }
14035 }
14036 else
14037 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014038 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 -070014039 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014040 status = eHAL_STATUS_FAILURE;
14041 break;
14042 }
14043 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014044 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014045}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014046eHalStatus csrSendMBAddSelfStaReqMsg(tpAniSirGlobal pMac,
14047 tAddStaForSessionCmd *pAddStaReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070014048{
14049 tSirSmeAddStaSelfReq *pMsg;
14050 tANI_U16 msgLen;
14051 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014052 do {
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014053 msgLen = sizeof(tSirSmeAddStaSelfReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053014054 pMsg = vos_mem_malloc(msgLen);
14055 if ( NULL == pMsg ) break;
14056 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014057 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
14058 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014059 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053014060 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr,
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014061 (tANI_U8 *)&pAddStaReq->selfMacAddr, sizeof(tSirMacAddr));
14062
14063 pMsg->currDeviceMode = pAddStaReq->currDeviceMode;
14064
Arif Hussain24bafea2013-11-15 15:10:03 -080014065 smsLog( pMac, LOG1, FL("selfMac="MAC_ADDRESS_STR),
14066 MAC_ADDR_ARRAY(pMsg->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014067 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014068 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014069 return( status );
14070}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014071eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac,
14072 tANI_U32 sessionId,
14073 tSirMacAddr sessionMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -070014074{
14075 eHalStatus status = eHAL_STATUS_SUCCESS;
14076 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014077 pCommand = csrGetCommandBuffer(pMac);
14078 if(NULL == pCommand)
14079 {
14080 status = eHAL_STATUS_RESOURCES;
14081 }
14082 else
14083 {
14084 pCommand->command = eSmeCommandAddStaSession;
14085 pCommand->sessionId = (tANI_U8)sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053014086 vos_mem_copy(pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr,
14087 sizeof( tSirMacAddr ) );
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014088 pCommand->u.addStaSessionCmd.currDeviceMode = pMac->sme.currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070014089 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
14090 if( !HAL_STATUS_SUCCESS( status ) )
14091 {
14092 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014093 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014094 }
14095 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014096 return (status);
14097}
Jeff Johnson295189b2012-06-20 16:38:30 -070014098eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14099{
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014100 return csrSendMBAddSelfStaReqMsg(pMac, &pCommand->u.addStaSessionCmd);
Jeff Johnson295189b2012-06-20 16:38:30 -070014101}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014102eHalStatus csrRoamOpenSession(tpAniSirGlobal pMac,
14103 csrRoamCompleteCallback callback,
14104 void *pContext, tANI_U8 *pSelfMacAddr,
14105 tANI_U8 *pbSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -070014106{
14107 eHalStatus status = eHAL_STATUS_SUCCESS;
14108 tANI_U32 i;
14109 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070014110 *pbSessionId = CSR_SESSION_ID_INVALID;
14111 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14112 {
14113 if( !CSR_IS_SESSION_VALID( pMac, i ) )
14114 {
14115 pSession = CSR_GET_SESSION( pMac, i );
14116 status = eHAL_STATUS_SUCCESS;
14117 pSession->sessionActive = eANI_BOOLEAN_TRUE;
14118 pSession->sessionId = (tANI_U8)i;
14119 pSession->callback = callback;
14120 pSession->pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053014121 vos_mem_copy(&pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070014122 *pbSessionId = (tANI_U8)i;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014123 status = vos_timer_init(&pSession->hTimerRoaming, VOS_TIMER_TYPE_SW,
14124 csrRoamRoamingTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070014125 &pSession->roamingTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014126 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014127 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014128 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014129 break;
14130 }
14131#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014132 status = vos_timer_init(&pSession->hTimerJoinRetry, VOS_TIMER_TYPE_SW,
14133 csrRoamJoinRetryTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070014134 &pSession->joinRetryTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014135 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014136 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014137 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014138 break;
14139 }
14140#endif
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014141 status = csrIssueAddStaForSessionReq (pMac, i, pSelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014142 break;
14143 }
14144 }
14145 if( CSR_ROAM_SESSION_MAX == i )
14146 {
14147 //No session is available
14148 status = eHAL_STATUS_RESOURCES;
14149 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014150 return ( status );
14151}
Jeff Johnson295189b2012-06-20 16:38:30 -070014152eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
14153{
14154 eHalStatus status = eHAL_STATUS_SUCCESS;
14155 tListElem *pEntry = NULL;
14156 tSmeCmd *pCommand = NULL;
14157 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014158 do
14159 {
14160 if(pMsg == NULL)
14161 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014162 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014163 status = eHAL_STATUS_FAILURE;
14164 break;
14165 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014166 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
14167 if(pEntry)
14168 {
14169 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14170 if(eSmeCommandDelStaSession == pCommand->command)
14171 {
14172 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070014173 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014174 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014175 //This session is done.
14176 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014177 if(pCommand->u.delStaSessionCmd.callback)
14178 {
14179
14180 status = sme_ReleaseGlobalLock( &pMac->sme );
14181 if ( HAL_STATUS_SUCCESS( status ) )
14182 {
14183 pCommand->u.delStaSessionCmd.callback(
14184 pCommand->u.delStaSessionCmd.pContext);
14185 status = sme_AcquireGlobalLock( &pMac->sme );
14186 if (! HAL_STATUS_SUCCESS( status ) )
14187 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014188 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014189 return status;
14190 }
14191 }
14192 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014193 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014194 }
14195 }
14196
14197 //Remove this command out of the active list
14198 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
14199 {
14200 //Now put this command back on the avilable command list
14201 csrReleaseCommand(pMac, pCommand);
14202 }
14203 smeProcessPendingQueue( pMac );
14204 }
14205 else
14206 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014207 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 -070014208 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014209 status = eHAL_STATUS_FAILURE;
14210 break;
14211 }
14212 }
14213 else
14214 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014215 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 -070014216 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014217 status = eHAL_STATUS_FAILURE;
14218 break;
14219 }
14220 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014221 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014222}
Jeff Johnson295189b2012-06-20 16:38:30 -070014223eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
14224{
14225 tSirSmeDelStaSelfReq *pMsg;
14226 tANI_U16 msgLen;
14227 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014228 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070014229 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
14230 sizeof( tSirBssType )*/;
Kiet Lam64c1b492013-07-12 13:56:44 +053014231 pMsg = vos_mem_malloc(msgLen);
14232 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14233 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014234 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
14235 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014236 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053014237 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr,
14238 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014239 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014240 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014241 return( status );
14242}
Jeff Johnson295189b2012-06-20 16:38:30 -070014243eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
14244 tSirMacAddr sessionMacAddr,
14245 csrRoamSessionCloseCallback callback,
14246 void *pContext)
14247{
14248 eHalStatus status = eHAL_STATUS_SUCCESS;
14249 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014250 pCommand = csrGetCommandBuffer(pMac);
14251 if(NULL == pCommand)
14252 {
14253 status = eHAL_STATUS_RESOURCES;
14254 }
14255 else
14256 {
14257 pCommand->command = eSmeCommandDelStaSession;
14258 pCommand->sessionId = (tANI_U8)sessionId;
14259 pCommand->u.delStaSessionCmd.callback = callback;
14260 pCommand->u.delStaSessionCmd.pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053014261 vos_mem_copy(pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr,
14262 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014263 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
14264 if( !HAL_STATUS_SUCCESS( status ) )
14265 {
14266 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014267 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014268 }
14269 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014270 return (status);
14271}
Jeff Johnson295189b2012-06-20 16:38:30 -070014272eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14273{
14274 return csrSendMBDelSelfStaReqMsg( pMac,
14275 pCommand->u.delStaSessionCmd.selfMacAddr );
14276}
Jeff Johnson295189b2012-06-20 16:38:30 -070014277static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
14278{
14279 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
14280 tListElem *pEntry, *pNext;
14281 tSmeCmd *pCommand;
14282 tDblLinkList localList;
14283
14284 vos_mem_zero(&localList, sizeof(tDblLinkList));
14285 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
14286 {
14287 smsLog(pMac, LOGE, FL(" failed to open list"));
14288 return;
14289 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014290 csrLLLock(pList);
14291 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
14292 while(pEntry != NULL)
14293 {
14294 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
14295 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14296 if(pCommand->sessionId == sessionId)
14297 {
14298 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
14299 {
14300 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
14301 }
14302 }
14303 pEntry = pNext;
14304 }
14305 csrLLUnlock(pList);
14306
14307 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
14308 {
14309 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14310 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
14311 }
14312 csrLLClose(&localList);
14313}
14314
Jeff Johnson295189b2012-06-20 16:38:30 -070014315void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
14316{
14317 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14318 {
14319 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014320 csrRoamStop(pMac, sessionId);
14321 csrFreeConnectBssDesc(pMac, sessionId);
14322 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
14323 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014324 vos_timer_destroy(&pSession->hTimerRoaming);
Jeff Johnson295189b2012-06-20 16:38:30 -070014325#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014326 vos_timer_destroy(&pSession->hTimerJoinRetry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014327#endif
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014328 purgeSmeSessionCmdList(pMac, sessionId, &pMac->sme.smeCmdPendingList);
14329 if (pMac->fScanOffload)
14330 {
14331 purgeSmeSessionCmdList(pMac, sessionId,
14332 &pMac->sme.smeScanCmdPendingList);
14333 }
14334
Jeff Johnson295189b2012-06-20 16:38:30 -070014335 purgeCsrSessionCmdList(pMac, sessionId);
14336 csrInitSession(pMac, sessionId);
14337 }
14338}
14339
Jeff Johnson295189b2012-06-20 16:38:30 -070014340eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
14341 tANI_BOOLEAN fSync,
14342 csrRoamSessionCloseCallback callback,
14343 void *pContext )
14344{
14345 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014346 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14347 {
14348 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14349 if(fSync)
14350 {
14351 csrCleanupSession(pMac, sessionId);
14352 }
14353 else
14354 {
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014355 purgeSmeSessionCmdList(pMac, sessionId,
14356 &pMac->sme.smeCmdPendingList);
14357 if (pMac->fScanOffload)
14358 {
14359 purgeSmeSessionCmdList(pMac, sessionId,
14360 &pMac->sme.smeScanCmdPendingList);
14361 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014362 purgeCsrSessionCmdList(pMac, sessionId);
14363 status = csrIssueDelStaForSessionReq( pMac, sessionId,
14364 pSession->selfMacAddr, callback, pContext);
14365 }
14366 }
14367 else
14368 {
14369 status = eHAL_STATUS_INVALID_PARAMETER;
14370 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014371 return ( status );
14372}
14373
Jeff Johnson295189b2012-06-20 16:38:30 -070014374static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
14375{
14376 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014377
14378 if(!pSession)
14379 {
14380 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14381 return;
14382 }
14383
Jeff Johnson295189b2012-06-20 16:38:30 -070014384 pSession->sessionActive = eANI_BOOLEAN_FALSE;
14385 pSession->sessionId = CSR_SESSION_ID_INVALID;
14386 pSession->callback = NULL;
14387 pSession->pContext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014388 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
14389 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
14390 csrFreeRoamProfile( pMac, sessionId );
14391 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
14392 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
14393 csrFreeConnectBssDesc(pMac, sessionId);
14394 csrScanEnable(pMac);
Kiet Lam64c1b492013-07-12 13:56:44 +053014395 vos_mem_set(&pSession->selfMacAddr, sizeof(tCsrBssid), 0);
14396 if (pSession->pWpaRsnReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014397 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014398 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014399 pSession->pWpaRsnReqIE = NULL;
14400 }
14401 pSession->nWpaRsnReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014402 if (pSession->pWpaRsnRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014403 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014404 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014405 pSession->pWpaRsnRspIE = NULL;
14406 }
14407 pSession->nWpaRsnRspIeLength = 0;
14408#ifdef FEATURE_WLAN_WAPI
Kiet Lam64c1b492013-07-12 13:56:44 +053014409 if (pSession->pWapiReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014410 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014411 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014412 pSession->pWapiReqIE = NULL;
14413 }
14414 pSession->nWapiReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014415 if (pSession->pWapiRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014416 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014417 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014418 pSession->pWapiRspIE = NULL;
14419 }
14420 pSession->nWapiRspIeLength = 0;
14421#endif /* FEATURE_WLAN_WAPI */
Agarwal Ashish4f616132013-12-30 23:32:50 +053014422 if (pSession->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070014423 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053014424 memset(pSession->addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH);
Jeff Johnson295189b2012-06-20 16:38:30 -070014425 }
14426 pSession->nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053014427
Kiet Lam64c1b492013-07-12 13:56:44 +053014428 if (pSession->pAddIEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070014429 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014430 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070014431 pSession->pAddIEAssoc = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053014432 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014433 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014434}
14435
Jeff Johnson295189b2012-06-20 16:38:30 -070014436eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
14437{
14438 eHalStatus status = eHAL_STATUS_FAILURE;
14439 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070014440 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14441 {
14442 if( CSR_IS_SESSION_VALID( pMac, i ) )
14443 {
14444 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
14445 {
14446 //Found it
14447 status = eHAL_STATUS_SUCCESS;
14448 *pSessionId = i;
14449 break;
14450 }
14451 }
14452 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014453 return( status );
14454}
14455
Jeff Johnson295189b2012-06-20 16:38:30 -070014456//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
14457//session because for IBSS, the bssid changes.
14458static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
14459{
14460 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
14461 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070014462 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14463 {
14464 if( CSR_IS_SESSION_VALID( pMac, i ) )
14465 {
14466 pSession = CSR_GET_SESSION( pMac, i );
14467 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
14468 {
14469 //Found it
14470 nRet = i;
14471 break;
14472 }
14473 }
14474 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014475 return (nRet);
14476}
Jeff Johnson295189b2012-06-20 16:38:30 -070014477static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
14478{
14479 /* Update the current BSS info in ho control block based on connected
14480 profile info from pmac global structure */
14481
Arif Hussain24bafea2013-11-15 15:10:03 -080014482 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= "MAC_ADDRESS_STR,
14483 MAC_ADDR_ARRAY(bssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070014484 /* Check for user misconfig of RSSI trigger threshold */
14485 pMac->roam.configParam.vccRssiThreshold =
14486 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
14487 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
14488 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070014489 /* Check for user misconfig of UL MAC Loss trigger threshold */
14490 pMac->roam.configParam.vccUlMacLossThreshold =
14491 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
14492 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014493#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14494 {
14495 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014496 /* Indicate the neighbor roal algorithm about the connect indication */
14497 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
14498 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
14499 }
14500#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014501}
14502
Jeff Johnson295189b2012-06-20 16:38:30 -070014503static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
14504{
14505 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014506
14507 if(!pSession)
14508 {
14509 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14510 return;
14511 }
14512
Jeff Johnson295189b2012-06-20 16:38:30 -070014513 //Only to handle the case for Handover on infra link
14514 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
14515 {
14516 return;
14517 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014518 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
14519 csrRoamDeregStatisticsReq(pMac);
14520 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14521#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14522 /* Indicate the neighbor roal algorithm about the disconnect indication */
14523 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
14524#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070014525
14526 //Remove this code once SLM_Sessionization is supported
14527 //BMPS_WORKAROUND_NOT_NEEDED
14528 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070014529 csrIsInfraApStarted( pMac ) &&
14530 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070014531 {
14532 pMac->roam.configParam.doBMPSWorkaround = 0;
14533 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014534}
14535
Jeff Johnson295189b2012-06-20 16:38:30 -070014536void csrRoamTlStatsTimerHandler(void *pv)
14537{
14538 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
14539 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014540 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14541
Jeff Johnsone7245742012-09-05 17:12:55 -070014542 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
14543
Jeff Johnson295189b2012-06-20 16:38:30 -070014544#if 0
14545 // TODO Persession .???
14546 //req TL for stats
14547 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
14548 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014549 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014550 }
14551 else
14552 {
14553 //save in SME
14554 csrRoamSaveStatsFromTl(pMac, tlStats);
14555 }
14556#endif
14557 if(!pMac->roam.tlStatsReqInfo.timerRunning)
14558 {
14559 if(pMac->roam.tlStatsReqInfo.periodicity)
14560 {
14561 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014562 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
14563 pMac->roam.tlStatsReqInfo.periodicity);
14564 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014565 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014566 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014567 return;
14568 }
14569 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
14570 }
14571 }
14572}
Jeff Johnson295189b2012-06-20 16:38:30 -070014573void csrRoamPeStatsTimerHandler(void *pv)
14574{
14575 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
14576 eHalStatus status;
14577 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
14578 VOS_STATUS vosStatus;
14579 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070014580 pPeStatsReqListEntry->timerRunning = FALSE;
14581 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
14582 {
14583 // If we entered here, meaning the timer could not be successfully
14584 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
14585
14586 /* Destroy the timer */
14587 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
14588 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14589 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014590 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014591 }
14592
14593 // Free the entry
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014594 vos_mem_free(pPeStatsReqListEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014595 pPeStatsReqListEntry = NULL;
14596 }
14597 else
14598 {
14599 if(!pPeStatsReqListEntry->rspPending)
14600 {
14601 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
14602 pPeStatsReqListEntry->staId);
14603 if(!HAL_STATUS_SUCCESS(status))
14604 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014605 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014606 }
14607 else
14608 {
14609 pPeStatsReqListEntry->rspPending = TRUE;
14610 }
14611 }
14612
14613 //send down a req
14614 if(pPeStatsReqListEntry->periodicity &&
14615 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
14616 {
14617 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
14618 if(ePMC_FULL_POWER == powerState)
14619 {
14620 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
14621 {
14622 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
14623 }
14624 }
14625 else
14626 {
14627 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
14628 {
14629 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
14630 }
14631 }
14632 //start timer
14633 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
14634 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14635 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014636 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014637 return;
14638 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014639 pPeStatsReqListEntry->timerRunning = TRUE;
14640
14641 }
14642
14643 }
14644}
Jeff Johnson295189b2012-06-20 16:38:30 -070014645void csrRoamStatsClientTimerHandler(void *pv)
14646{
14647 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070014648 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
14649 {
14650#if 0
14651 // TODO Stats fix for multisession
14652 //start the timer
14653 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
14654
14655 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14656 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014657 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014658 }
14659#endif
14660 }
14661#if 0
14662 //send up the stats report
14663 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
14664 pStaEntry->staId, pStaEntry->pContext);
14665#endif
14666}
14667
14668
14669
Jeff Johnson295189b2012-06-20 16:38:30 -070014670eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
14671{
14672 tAniGetPEStatsReq *pMsg;
14673 eHalStatus status = eHAL_STATUS_SUCCESS;
Kiet Lam64c1b492013-07-12 13:56:44 +053014674 pMsg = vos_mem_malloc(sizeof(tAniGetPEStatsReq));
14675 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070014676 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053014677 smsLog(pMac, LOGE, FL( "Failed to allocate mem for stats req "));
Kiet Lam64c1b492013-07-12 13:56:44 +053014678 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014679 }
14680 // need to initiate a stats request to PE
14681 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_STATISTICS_REQ);
14682 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
14683 pMsg->staId = staId;
14684 pMsg->statsMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070014685 status = palSendMBMessage(pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070014686 if(!HAL_STATUS_SUCCESS(status))
14687 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053014688 smsLog(pMac, LOG1, FL("Failed to send down the stats req "));
Jeff Johnson295189b2012-06-20 16:38:30 -070014689 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014690 return status;
14691}
Jeff Johnson295189b2012-06-20 16:38:30 -070014692void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
14693{
14694 tAniGetPEStatsRsp *pSmeStatsRsp;
14695 eHalStatus status = eHAL_STATUS_FAILURE;
14696 tListElem *pEntry = NULL;
14697 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
14698 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
14699 tANI_U32 tempMask = 0;
14700 tANI_U8 counter = 0;
14701 tANI_U8 *pStats = NULL;
14702 tANI_U32 length = 0;
14703 v_PVOID_t pvosGCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014704 v_S7_t rssi = 0, snr = 0;
14705 tANI_U32 *pRssi = NULL, *pSnr = NULL;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014706 tANI_U32 linkCapacity;
Jeff Johnson295189b2012-06-20 16:38:30 -070014707 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
14708 if(pSmeStatsRsp->rc)
14709 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014710 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014711 goto post_update;
14712 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014713 tempMask = pSmeStatsRsp->statsMask;
14714 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070014715 /* subtract all statistics from this length, and after processing the entire
14716 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
14717 * in this 'stats' message.
14718 */
14719 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070014720 //new stats info from PE, fill up the stats strucutres in PMAC
14721 while(tempMask)
14722 {
14723 if(tempMask & 1)
14724 {
14725 switch(counter)
14726 {
14727 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014728 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014729 vos_mem_copy((tANI_U8 *)&pMac->roam.summaryStatsInfo,
14730 pStats, sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014731 pStats += sizeof(tCsrSummaryStatsInfo);
14732 length -= sizeof(tCsrSummaryStatsInfo);
14733 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014734 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014735 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014736 vos_mem_copy((tANI_U8 *)&pMac->roam.classAStatsInfo,
14737 pStats, sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014738 pStats += sizeof(tCsrGlobalClassAStatsInfo);
14739 length -= sizeof(tCsrGlobalClassAStatsInfo);
14740 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014741 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014742 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014743 vos_mem_copy((tANI_U8 *)&pMac->roam.classBStatsInfo,
14744 pStats, sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014745 pStats += sizeof(tCsrGlobalClassBStatsInfo);
14746 length -= sizeof(tCsrGlobalClassBStatsInfo);
14747 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014748 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014749 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014750 vos_mem_copy((tANI_U8 *)&pMac->roam.classCStatsInfo,
14751 pStats, sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014752 pStats += sizeof(tCsrGlobalClassCStatsInfo);
14753 length -= sizeof(tCsrGlobalClassCStatsInfo);
14754 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014755 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014756 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014757 if( CSR_MAX_STA > pSmeStatsRsp->staId )
14758 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014759 vos_mem_copy((tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
14760 pStats, sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014761 }
14762 else
14763 {
14764 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014765 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014766 VOS_ASSERT( 0 );
14767 }
14768 if(!HAL_STATUS_SUCCESS(status))
14769 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014770 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014771 }
14772 pStats += sizeof(tCsrPerStaStatsInfo);
14773 length -= sizeof(tCsrPerStaStatsInfo);
14774 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014775 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014776 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014777 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014778 }
14779 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014780 tempMask >>=1;
14781 counter++;
14782 }
14783 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
14784 if (length != 0)
14785 {
14786 pRssi = (tANI_U32*)pStats;
14787 rssi = (v_S7_t)*pRssi;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014788 pStats += sizeof(tANI_U32);
14789 length -= sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070014790 }
14791 else
14792 {
14793 /* If riva is not sending rssi, continue to use the hack */
14794 rssi = RSSI_HACK_BMPS;
14795 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014796
Jeff Johnson295189b2012-06-20 16:38:30 -070014797 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014798
14799 if (length != 0)
14800 {
14801 linkCapacity = *(tANI_U32*)pStats;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014802 pStats += sizeof(tANI_U32);
14803 length -= sizeof(tANI_U32);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014804 }
14805 else
14806 {
14807 linkCapacity = 0;
14808 }
14809
14810 WDA_UpdateLinkCapacity(pvosGCtx, pSmeStatsRsp->staId, linkCapacity);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014811
14812 if (length != 0)
14813 {
14814 pSnr = (tANI_U32*)pStats;
14815 snr = (v_S7_t)*pSnr;
14816 }
14817 else
14818 {
14819 snr = SNR_HACK_BMPS;
14820 }
14821
14822 WDA_UpdateSnrBmps(pvosGCtx, pSmeStatsRsp->staId, snr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014823post_update:
14824 //make sure to update the pe stats req list
14825 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
14826 if(pEntry)
14827 {
14828 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
14829 pPeStaEntry->rspPending = FALSE;
14830
14831 }
14832 //check the one timer cases
14833 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
14834 if(pEntry)
14835 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014836 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014837 if(pTempStaEntry->timerExpired)
14838 {
14839 //send up the stats report
14840 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
14841 pTempStaEntry->staId, pTempStaEntry->pContext);
14842 //also remove from the client list
14843 csrRoamRemoveStatListEntry(pMac, pEntry);
14844 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014845 }
14846 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014847}
Jeff Johnson295189b2012-06-20 16:38:30 -070014848tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14849{
14850 tListElem *pEntry = NULL;
14851 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014852 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014853 if(!pEntry)
14854 {
14855 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014856 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070014857 return NULL;
14858 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014859 while( pEntry )
14860 {
14861 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014862 if(pTempStaEntry->statsMask == statsMask)
14863 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014864 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014865 break;
14866 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014867 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
14868 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014869 return pEntry;
14870}
14871
Jeff Johnson295189b2012-06-20 16:38:30 -070014872tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
14873 tANI_BOOLEAN update)
14874{
14875 tListElem *pEntry;
14876 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014877 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014878 if(!pEntry)
14879 {
14880 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014881 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014882 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014883 return NULL;
14884 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014885 while( pEntry )
14886 {
14887 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014888 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
14889 (pTempStaEntry->statsMask == pStaEntry->statsMask))
14890 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014891 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014892 if(update)
14893 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014894 pTempStaEntry->periodicity = pStaEntry->periodicity;
14895 pTempStaEntry->callback = pStaEntry->callback;
14896 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070014897 }
14898 break;
14899 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014900 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14901 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014902 return pEntry;
14903}
Jeff Johnson295189b2012-06-20 16:38:30 -070014904tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14905{
14906 tListElem *pEntry;
14907 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014908 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014909 if(!pEntry)
14910 {
14911 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014912 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014913 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014914 return NULL;
14915 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014916 while( pEntry )
14917 {
14918 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014919 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
14920 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014921 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014922 break;
14923 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014924 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14925 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014926 return pEntry;
14927}
Jeff Johnson295189b2012-06-20 16:38:30 -070014928eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
14929 csrRoamLinkQualityIndCallback callback,
14930 void *pContext)
14931{
14932 pMac->roam.linkQualityIndInfo.callback = callback;
14933 pMac->roam.linkQualityIndInfo.context = pContext;
14934 if( NULL == callback )
14935 {
14936 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
14937 }
14938 else
14939 {
14940 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070014941 /* do we need to invoke the callback to notify client of initial value ?? */
14942 }
14943 return eHAL_STATUS_SUCCESS;
14944}
Jeff Johnson295189b2012-06-20 16:38:30 -070014945void csrRoamVccTrigger(tpAniSirGlobal pMac)
14946{
14947 eCsrRoamLinkQualityInd newVccLinkQuality;
14948 tANI_U32 ul_mac_loss = 0;
14949 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014950 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
14951 /*-------------------------------------------------------------------------
14952 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070014953 Check for a change in link quality and notify client if necessary
14954 -------------------------------------------------------------------------*/
14955 ul_mac_loss_trigger_threshold =
14956 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014957 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014958 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014959 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070014960 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
14961 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014962 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070014963 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14964 }
14965 else
14966 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014967 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070014968 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
14969 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014970 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
14971 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070014972 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
14973 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014974 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070014975 if(NULL != pMac->roam.linkQualityIndInfo.callback)
14976 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014977 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070014978 newVccLinkQuality );
14979
14980 /* we now invoke the callback once to notify client of initial value */
14981 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
14982 pMac->roam.linkQualityIndInfo.context );
14983 //event: EVENT_WLAN_VCC
14984 }
14985 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014986 pMac->roam.vccLinkQuality = newVccLinkQuality;
14987
Jeff Johnson295189b2012-06-20 16:38:30 -070014988}
Jeff Johnson295189b2012-06-20 16:38:30 -070014989VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
14990 v_U8_t rssiNotification,
14991 void * context)
14992{
14993 tpAniSirGlobal pMac = PMAC_STRUCT( context );
14994 eCsrRoamLinkQualityInd newVccLinkQuality;
14995 // TODO : Session info unavailable
14996 tANI_U32 sessionId = 0;
14997 VOS_STATUS status = VOS_STATUS_SUCCESS;
14998 /*-------------------------------------------------------------------------
14999 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070015000 Check for a change in link quality and notify client if necessary
15001 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015002 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015003 pMac->roam.configParam.vccRssiThreshold);
15004 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
15005 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015006 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070015007 return VOS_STATUS_SUCCESS;
15008 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015009 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
15010 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015011 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070015012 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
15013 }
15014 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
15015 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015016 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070015017 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
15018 }
15019 else
15020 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015021 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070015022 //Set to this so the code below won't do anything
15023 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070015024 VOS_ASSERT(0);
15025 }
15026
Jeff Johnson295189b2012-06-20 16:38:30 -070015027 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
15028 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015029 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070015030 if(NULL != pMac->roam.linkQualityIndInfo.callback)
15031 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015032 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015033 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070015034 /* we now invoke the callback once to notify client of initial value */
15035 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
15036 pMac->roam.linkQualityIndInfo.context );
15037 //event: EVENT_WLAN_VCC
15038 }
15039 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015040 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070015041 return status;
15042}
Jeff Johnson295189b2012-06-20 16:38:30 -070015043tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
15044 tDblLinkList *pStaList,
15045 tCsrStatsClientReqInfo *pStaEntry)
15046{
15047 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015048 //if same entity requested for same set of stats with different periodicity &
15049 // callback update it
15050 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
15051 {
15052
Kiet Lam64c1b492013-07-12 13:56:44 +053015053 pNewStaEntry = vos_mem_malloc(sizeof(tCsrStatsClientReqInfo));
15054 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015055 {
15056 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015057 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070015058 return NULL;
15059 }
15060
Jeff Johnson295189b2012-06-20 16:38:30 -070015061 pNewStaEntry->callback = pStaEntry->callback;
15062 pNewStaEntry->pContext = pStaEntry->pContext;
15063 pNewStaEntry->periodicity = pStaEntry->periodicity;
15064 pNewStaEntry->requesterId = pStaEntry->requesterId;
15065 pNewStaEntry->statsMask = pStaEntry->statsMask;
15066 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
15067 pNewStaEntry->pMac = pStaEntry->pMac;
15068 pNewStaEntry->staId = pStaEntry->staId;
15069 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
15070
15071 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
15072 }
15073 return pNewStaEntry;
15074}
15075
Jeff Johnson295189b2012-06-20 16:38:30 -070015076tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
15077 tDblLinkList *pStaList,
15078 tCsrPeStatsReqInfo *pStaEntry)
15079{
15080 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053015081 pNewStaEntry = vos_mem_malloc(sizeof(tCsrPeStatsReqInfo));
15082 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015083 {
15084 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015085 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070015086 return NULL;
15087 }
15088
Jeff Johnson295189b2012-06-20 16:38:30 -070015089 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
15090 pNewStaEntry->numClient = pStaEntry->numClient;
15091 pNewStaEntry->periodicity = pStaEntry->periodicity;
15092 pNewStaEntry->statsMask = pStaEntry->statsMask;
15093 pNewStaEntry->pMac = pStaEntry->pMac;
15094 pNewStaEntry->staId = pStaEntry->staId;
15095 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
15096 pNewStaEntry->rspPending = pStaEntry->rspPending;
15097
15098 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015099 return pNewStaEntry;
15100}
Jeff Johnson295189b2012-06-20 16:38:30 -070015101eHalStatus csrGetRssi(tpAniSirGlobal pMac,
15102 tCsrRssiCallback callback,
15103 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
15104{
15105 eHalStatus status = eHAL_STATUS_SUCCESS;
15106 vos_msg_t msg;
15107 tANI_U32 sessionId;
15108
15109 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015110 smsLog(pMac, LOG2, FL("called"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015111 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
15112 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070015113 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015114 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053015115 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015116 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015117 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
15118
15119 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
15120 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
15121 pMsg->sessionId = sessionId;
15122 pMsg->staId = staId;
15123 pMsg->rssiCallback = callback;
15124 pMsg->pDevContext = pContext;
15125 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070015126 msg.type = eWNI_SME_GET_RSSI_REQ;
15127 msg.bodyptr = pMsg;
15128 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015129 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
15130 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015131 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053015132 vos_mem_free((void *)pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015133 status = eHAL_STATUS_FAILURE;
15134 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015135 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015136 return status;
15137}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015138
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015139eHalStatus csrGetSnr(tpAniSirGlobal pMac,
15140 tCsrSnrCallback callback,
15141 tANI_U8 staId, tCsrBssid bssId,
15142 void *pContext)
15143{
15144 eHalStatus status = eHAL_STATUS_SUCCESS;
15145 vos_msg_t msg;
15146 tANI_U32 sessionId;
15147
15148 tAniGetSnrReq *pMsg;
15149
15150 smsLog(pMac, LOG2, FL("called"));
15151
15152 pMsg =(tAniGetSnrReq *)vos_mem_malloc(sizeof(tAniGetSnrReq));
15153 if (NULL == pMsg )
15154 {
15155 smsLog(pMac, LOGE, "%s: failed to allocate mem for req",__func__);
15156 return status;
15157 }
15158
15159 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
15160
15161 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_SNR_REQ);
15162 pMsg->msgLen = (tANI_U16)sizeof(tAniGetSnrReq);
15163 pMsg->sessionId = sessionId;
15164 pMsg->staId = staId;
15165 pMsg->snrCallback = callback;
15166 pMsg->pDevContext = pContext;
15167 msg.type = eWNI_SME_GET_SNR_REQ;
15168 msg.bodyptr = pMsg;
15169 msg.reserved = 0;
15170
15171 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
15172 {
15173 smsLog(pMac, LOGE, "%s failed to post msg to self", __func__);
15174 vos_mem_free((v_VOID_t *)pMsg);
15175 status = eHAL_STATUS_FAILURE;
15176 }
15177
15178 smsLog(pMac, LOG2, FL("returned"));
15179 return status;
15180}
15181
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015182#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015183eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
15184 tCsrRssiCallback callback,
15185 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
15186{
15187 eHalStatus status = eHAL_STATUS_SUCCESS;
15188 tAniGetRssiReq *pMsg;
15189
Kiet Lam64c1b492013-07-12 13:56:44 +053015190 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
15191 if ( NULL == pMsg )
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015192 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015193 smsLog(pMac, LOGE, FL("Failed to allocate mem for req"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015194 return eHAL_STATUS_FAILURE;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015195 }
15196 // need to initiate a stats request to PE
15197 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
15198 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
15199 pMsg->staId = staId;
15200 pMsg->rssiCallback = callback;
15201 pMsg->pDevContext = pContext;
15202 pMsg->pVosContext = pVosContext;
15203 status = palSendMBMessage(pMac->hHdd, pMsg );
15204 if(!HAL_STATUS_SUCCESS(status))
15205 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015206 smsLog(pMac, LOGE, FL(" Failed to send down get rssi req"));
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070015207 //pMsg is freed by palSendMBMessage
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015208 status = eHAL_STATUS_FAILURE;
15209 }
15210 return status;
15211}
15212#endif
15213
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015214
15215
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015216#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015217eHalStatus csrGetTsmStats(tpAniSirGlobal pMac,
15218 tCsrTsmStatsCallback callback,
15219 tANI_U8 staId,
15220 tCsrBssid bssId,
15221 void *pContext,
15222 void* pVosContext,
15223 tANI_U8 tid)
15224{
15225 eHalStatus status = eHAL_STATUS_SUCCESS;
15226 tAniGetTsmStatsReq *pMsg = NULL;
15227
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015228 pMsg = (tAniGetTsmStatsReq*)vos_mem_malloc(sizeof(tAniGetTsmStatsReq));
15229 if (NULL == pMsg)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015230 {
15231 smsLog(pMac, LOGE, "csrGetTsmStats: failed to allocate mem for req");
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015232 return eHAL_STATUS_FAILED_ALLOC;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015233 }
15234 // need to initiate a stats request to PE
15235 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_TSM_STATS_REQ);
15236 pMsg->msgLen = (tANI_U16)sizeof(tAniGetTsmStatsReq);
15237 pMsg->staId = staId;
15238 pMsg->tid = tid;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015239 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015240 pMsg->tsmStatsCallback = callback;
15241 pMsg->pDevContext = pContext;
15242 pMsg->pVosContext = pVosContext;
15243 status = palSendMBMessage(pMac->hHdd, pMsg );
15244 if(!HAL_STATUS_SUCCESS(status))
15245 {
15246 smsLog(pMac, LOG1, " csrGetTsmStats: failed to send down the rssi req");
15247 //pMsg is freed by palSendMBMessage
15248 status = eHAL_STATUS_FAILURE;
15249 }
15250 return status;
15251}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015252#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015253
15254
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053015255/* ---------------------------------------------------------------------------
15256 \fn csrGetTLSTAState
15257 \helper function to get teh TL STA State whenever the function is called.
15258
15259 \param staId - The staID to be passed to the TL
15260 to get the relevant TL STA State
15261 \return the state as tANI_U16
15262 ---------------------------------------------------------------------------*/
15263tANI_U16 csrGetTLSTAState(tpAniSirGlobal pMac, tANI_U8 staId)
15264{
15265 WLANTL_STAStateType tlSTAState;
15266 tlSTAState = WLANTL_STA_INIT;
15267
15268 //request TL for STA State
15269 if ( !VOS_IS_STATUS_SUCCESS(WLANTL_GetSTAState(pMac->roam.gVosContext, staId, &tlSTAState)) )
15270 {
15271 smsLog(pMac, LOGE, FL("csrGetTLSTAState:couldn't get the STA state from TL"));
15272 }
15273
15274 return tlSTAState;
15275}
15276
Jeff Johnson295189b2012-06-20 16:38:30 -070015277eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
15278 tANI_U32 statsMask,
15279 tCsrStatsCallback callback,
15280 tANI_U32 periodicity, tANI_BOOLEAN cache,
15281 tANI_U8 staId, void *pContext)
15282{
15283 tCsrStatsClientReqInfo staEntry;
15284 tCsrStatsClientReqInfo *pStaEntry = NULL;
15285 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
15286 tListElem *pEntry = NULL;
15287 tANI_BOOLEAN found = FALSE;
15288 eHalStatus status = eHAL_STATUS_SUCCESS;
15289 tANI_BOOLEAN insertInClientList = FALSE;
15290 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070015291 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070015292
15293 if( csrIsAllSessionDisconnected(pMac) )
15294 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015295 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070015296 return eHAL_STATUS_FAILURE;
15297 }
Hanumantha Reddy Pothula449aadf2014-02-07 13:53:35 +053015298
15299 if (csrNeighborMiddleOfRoaming((tHalHandle)pMac))
15300 {
15301 smsLog(pMac, LOG1, FL("in the middle of roaming states"));
15302 return eHAL_STATUS_FAILURE;
15303 }
15304
Jeff Johnson295189b2012-06-20 16:38:30 -070015305 if((!statsMask) && (!callback))
15306 {
15307 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015308 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070015309 return eHAL_STATUS_FAILURE;
15310 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015311 //for the search list method for deregister
15312 staEntry.requesterId = requesterId;
15313 staEntry.statsMask = statsMask;
15314 //requester wants to deregister or just an error
15315 if((statsMask) && (!callback))
15316 {
15317 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
15318 if(!pEntry)
15319 {
15320 //msg
15321 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015322 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015323 return eHAL_STATUS_FAILURE;
15324 }
15325 else
15326 {
15327 //clean up & return
15328 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070015329 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015330 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015331 pStaEntry->pPeStaEntry->numClient--;
15332 //check if we need to delete the entry from peStatsReqList too
15333 if(!pStaEntry->pPeStaEntry->numClient)
15334 {
15335 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
15336 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015337 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070015338
Jeff Johnson295189b2012-06-20 16:38:30 -070015339 //check if we need to stop the tl stats timer too
15340 pMac->roam.tlStatsReqInfo.numClient--;
15341 if(!pMac->roam.tlStatsReqInfo.numClient)
15342 {
15343 if(pMac->roam.tlStatsReqInfo.timerRunning)
15344 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015345 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
15346 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015347 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015348 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015349 return eHAL_STATUS_FAILURE;
15350 }
15351 }
15352 pMac->roam.tlStatsReqInfo.periodicity = 0;
15353 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
15354 }
15355 vos_timer_stop( &pStaEntry->timer );
Jeff Johnson295189b2012-06-20 16:38:30 -070015356 // Destroy the vos timer...
15357 vosStatus = vos_timer_destroy( &pStaEntry->timer );
15358 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15359 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015360 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to destroy Client req timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015361 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015362 csrRoamRemoveStatListEntry(pMac, pEntry);
15363 pStaEntry = NULL;
15364 return eHAL_STATUS_SUCCESS;
15365 }
15366 }
15367
15368 if(cache && !periodicity)
15369 {
15370 //return the cached stats
15371 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15372 }
15373 else
15374 {
15375 //add the request in the client req list
15376 staEntry.callback = callback;
15377 staEntry.pContext = pContext;
15378 staEntry.periodicity = periodicity;
15379 staEntry.pPeStaEntry = NULL;
15380 staEntry.staId = staId;
15381 staEntry.pMac = pMac;
15382 staEntry.timerExpired = FALSE;
15383
15384
Jeff Johnson295189b2012-06-20 16:38:30 -070015385 //if periodic report requested with non cached result from PE/TL
15386 if(periodicity)
15387 {
15388
15389 //if looking for stats from PE
15390 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15391 {
15392
15393 //check if same request made already & waiting for rsp
15394 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
15395 periodicity, &found, staId);
15396 if(!pPeStaEntry)
15397 {
15398 //bail out, maxed out on number of req for PE
15399 return eHAL_STATUS_FAILURE;
15400 }
15401 else
15402 {
15403 staEntry.pPeStaEntry = pPeStaEntry;
15404 }
15405
15406 }
15407 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
15408 if(statsMask & (1 << eCsrGlobalClassDStats))
15409 {
15410 if(cache && pMac->roam.tlStatsReqInfo.numClient)
15411 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015412 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015413 }
15414 else
15415 {
15416
15417 //update periodicity
15418 if(pMac->roam.tlStatsReqInfo.periodicity)
15419 {
15420 pMac->roam.tlStatsReqInfo.periodicity =
15421 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
15422 }
15423 else
15424 {
15425 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
15426 }
15427 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
15428 {
15429 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
15430 }
15431
15432 if(!pMac->roam.tlStatsReqInfo.timerRunning)
15433 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015434 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015435 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015436 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015437 //req TL for class D stats
15438 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
15439 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015440 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015441 }
15442 else
15443 {
15444 //save in SME
15445 csrRoamSaveStatsFromTl(pMac, pTlStats);
15446 }
15447 vos_mem_free(pTlStats);
15448 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015449 }
15450 else
15451 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015452 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015453 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015454
Jeff Johnson295189b2012-06-20 16:38:30 -070015455 if(pMac->roam.tlStatsReqInfo.periodicity)
15456 {
15457 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015458 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
15459 pMac->roam.tlStatsReqInfo.periodicity);
15460 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015461 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015462 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015463 return eHAL_STATUS_FAILURE;
15464 }
15465 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
15466 }
15467 }
15468 }
15469 pMac->roam.tlStatsReqInfo.numClient++;
15470 }
15471
15472 insertInClientList = TRUE;
15473 }
15474 //if one time report requested with non cached result from PE/TL
15475 else if(!cache && !periodicity)
15476 {
15477 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15478 {
15479 //send down a req
15480 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
15481 if(!HAL_STATUS_SUCCESS(status))
15482 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015483 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015484 }
15485 //so that when the stats rsp comes back from PE we respond to upper layer
15486 //right away
15487 staEntry.timerExpired = TRUE;
15488 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015489 }
15490 if(statsMask & (1 << eCsrGlobalClassDStats))
15491 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015492 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015493 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015494 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015495 //req TL for class D stats
15496 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
15497 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015498 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015499 }
15500 else
15501 {
15502 //save in SME
15503 csrRoamSaveStatsFromTl(pMac, pTlStats);
15504 }
15505 vos_mem_free(pTlStats);
15506 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015507 }
15508 else
15509 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015510 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015511 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015512
15513 }
15514 //if looking for stats from TL only
15515 if(!insertInClientList)
15516 {
15517 //return the stats
15518 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15519 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015520 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015521 if(insertInClientList)
15522 {
15523 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
15524 if(!pStaEntry)
15525 {
15526 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015527 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015528 return eHAL_STATUS_FAILURE;
15529 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015530 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070015531 //Init & start timer if needed
15532 if(periodicity)
15533 {
15534 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
15535 csrRoamStatsClientTimerHandler, pStaEntry );
15536 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15537 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015538 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015539 return eHAL_STATUS_FAILURE;
15540 }
15541 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
15542 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15543 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015544 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015545 return eHAL_STATUS_FAILURE;
15546 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015547 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015548 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015549 }
15550 return eHAL_STATUS_SUCCESS;
15551}
15552
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015553#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
15554
15555static tSirRetStatus
15556csrRoamScanOffloadPopulateMacHeader(tpAniSirGlobal pMac,
15557 tANI_U8* pBD,
15558 tANI_U8 type,
15559 tANI_U8 subType,
15560 tSirMacAddr peerAddr,
15561 tSirMacAddr selfMacAddr)
15562{
15563 tSirRetStatus statusCode = eSIR_SUCCESS;
15564 tpSirMacMgmtHdr pMacHdr;
15565
15566 /* Prepare MAC management header */
15567 pMacHdr = (tpSirMacMgmtHdr) (pBD);
15568
15569 /* Prepare FC */
15570 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
15571 pMacHdr->fc.type = type;
15572 pMacHdr->fc.subType = subType;
15573
15574 /* Prepare Address 1 */
Kiet Lam64c1b492013-07-12 13:56:44 +053015575 vos_mem_copy((tANI_U8 *) pMacHdr->da, (tANI_U8 *) peerAddr,
15576 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015577
15578 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
15579
15580 /* Prepare Address 3 */
Kiet Lam64c1b492013-07-12 13:56:44 +053015581 vos_mem_copy((tANI_U8 *) pMacHdr->bssId, (tANI_U8 *) peerAddr,
15582 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015583 return statusCode;
15584} /*** csrRoamScanOffloadPopulateMacHeader() ***/
15585
15586static tSirRetStatus
15587csrRoamScanOffloadPrepareProbeReqTemplate(tpAniSirGlobal pMac,
15588 tANI_U8 nChannelNum,
15589 tANI_U32 dot11mode,
15590 tSirMacAddr selfMacAddr,
15591 tANI_U8 *pFrame,
15592 tANI_U16 *pusLen)
15593{
15594 tDot11fProbeRequest pr;
15595 tANI_U32 nStatus, nBytes, nPayload;
15596 tSirRetStatus nSirStatus;
15597 /*Bcast tx*/
15598 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
15599 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
15600
15601
Kiet Lam64c1b492013-07-12 13:56:44 +053015602 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015603
15604 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
15605
15606 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
15607 {
15608 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
15609 }
15610
15611
15612 if (IS_DOT11_MODE_HT(dot11mode))
15613 {
15614 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
15615 }
15616
15617
15618 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
15619 if ( DOT11F_FAILED( nStatus ) )
15620 {
15621 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15622 "Failed to calculate the packed size f"
15623 "or a Probe Request (0x%08x).\n", nStatus );
15624
15625
15626 nPayload = sizeof( tDot11fProbeRequest );
15627 }
15628 else if ( DOT11F_WARNED( nStatus ) )
15629 {
15630 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15631 "There were warnings while calculating"
15632 "the packed size for a Probe Request ("
15633 "0x%08x).\n", nStatus );
15634 }
15635
15636 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
15637
15638 /* Prepare outgoing frame*/
Kiet Lam64c1b492013-07-12 13:56:44 +053015639 vos_mem_set(pFrame, nBytes , 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015640
15641
15642 nSirStatus = csrRoamScanOffloadPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015643 SIR_MAC_MGMT_PROBE_REQ, bssId,selfMacAddr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015644
15645 if ( eSIR_SUCCESS != nSirStatus )
15646 {
15647 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15648 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
15649 nSirStatus );
15650 return nSirStatus;
15651 }
15652
15653
15654 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
15655 sizeof( tSirMacMgmtHdr ),
15656 nPayload, &nPayload );
15657 if ( DOT11F_FAILED( nStatus ) )
15658 {
15659 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15660 "Failed to pack a Probe Request (0x%08x).\n", nStatus );
15661 return eSIR_FAILURE;
15662 }
15663 else if ( DOT11F_WARNED( nStatus ) )
15664 {
15665 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce8ad512013-10-30 12:34:42 -070015666 "There were warnings while packing a Probe Request (0x%08x).\n",
15667 nStatus );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015668 }
15669
15670 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
15671 return eSIR_SUCCESS;
15672}
15673
15674eHalStatus csrRoamOffloadScan(tpAniSirGlobal pMac, tANI_U8 command, tANI_U8 reason)
15675{
15676 vos_msg_t msg;
15677 tSirRoamOffloadScanReq *pRequestBuf;
15678 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
15679 tCsrRoamSession *pSession;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015680 tANI_U8 i,j,num_channels = 0, ucDot11Mode;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015681 tANI_U8 *ChannelList = NULL;
15682 tANI_U32 sessionId;
15683 eHalStatus status = eHAL_STATUS_SUCCESS;
15684 tpCsrChannelInfo currChannelListInfo;
Srinivas Girigowda56076852013-08-20 14:00:50 -070015685 tANI_U32 host_channels = 0;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015686 tANI_U8 ChannelCacheStr[128] = {0};
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015687 eCsrBand eBand;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015688 tSirBssDescription *pBssDesc = NULL;
15689 tDot11fBeaconIEs *pIes = NULL;
15690 tANI_U8 minRate = 0, dataRate;
Varun Reddy Yeturu52231ea2014-02-06 12:00:56 -080015691 tANI_U8 operationChannel = 0;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015692
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015693 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
15694
Srinivas Girigowda830bbd02013-06-13 19:44:16 -070015695 if (0 == csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015696 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015697 smsLog( pMac, LOGE,"isRoamOffloadScanEnabled not set");
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015698 return eHAL_STATUS_FAILURE;
15699 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015700
15701 if ((VOS_TRUE == bRoamScanOffloadStarted) && (ROAM_SCAN_OFFLOAD_START == command))
15702 {
15703 smsLog( pMac, LOGE,"Roam Scan Offload is already started");
15704 return eHAL_STATUS_FAILURE;
15705 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015706 status = csrRoamGetSessionIdFromBSSID(pMac,
15707 (tCsrBssid *)pNeighborRoamInfo->currAPbssid,
15708 &sessionId);
15709 /*The Dynamic Config Items Update may happen even if the state is in INIT.
15710 * It is important to ensure that the command is passed down to the FW only
15711 * if the Infra Station is in a connected state.A connected station could also be
15712 * in a PREAUTH or REASSOC states.So, consider not sending the command down in INIT state.
15713 * We also have to ensure that if there is a STOP command we always have to inform Riva,
15714 * irrespective of whichever state we are in.*/
15715 if ((pMac->roam.neighborRoamInfo.neighborRoamState == eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
15716 (command != ROAM_SCAN_OFFLOAD_STOP))
15717 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053015718 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
15719 FL("Scan Command not sent to FW with state = %s and cmd=%d\n"),
15720 macTraceGetNeighbourRoamState(
15721 pMac->roam.neighborRoamInfo.neighborRoamState), command);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015722 return eHAL_STATUS_FAILURE;
15723 }
15724
15725 if ( !HAL_STATUS_SUCCESS( status ) )
15726 {
15727 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to find the sessionId for Roam Offload scan request", __func__);
15728 return eHAL_STATUS_FAILURE;
15729 }
15730 pSession = CSR_GET_SESSION( pMac, sessionId );
krunal soni587bf012014-02-04 12:35:11 -080015731 if (NULL == pSession)
15732 {
15733 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15734 "%s:pSession is null", __func__);
15735 return eHAL_STATUS_FAILURE;
15736 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015737 pBssDesc = pSession->pConnectBssDesc;
15738 if (pBssDesc == NULL)
15739 {
15740 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: pBssDesc not found for current session", __func__);
15741 return eHAL_STATUS_FAILURE;
15742 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015743 pRequestBuf = vos_mem_malloc(sizeof(tSirRoamOffloadScanReq));
15744 if (NULL == pRequestBuf)
15745 {
15746 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to allocate memory for Roam Offload scan request", __func__);
15747 return eHAL_STATUS_FAILED_ALLOC;
15748 }
15749
Kiet Lam64c1b492013-07-12 13:56:44 +053015750 vos_mem_zero(pRequestBuf, sizeof(tSirRoamOffloadScanReq));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015751 /* If command is STOP, then pass down ScanOffloadEnabled as Zero.This will handle the case of
15752 * host driver reloads, but Riva still up and running*/
15753 if(command == ROAM_SCAN_OFFLOAD_STOP)
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015754 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015755 pRequestBuf->RoamScanOffloadEnabled = 0;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015756 /*For a STOP Command, there is no need to
15757 * go through filling up all the below parameters
15758 * since they are not required for the STOP command*/
15759 goto send_roam_scan_offload_cmd;
15760 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015761 else
15762 pRequestBuf->RoamScanOffloadEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
Kiet Lam64c1b492013-07-12 13:56:44 +053015763 vos_mem_copy(pRequestBuf->ConnectedNetwork.currAPbssid,
15764 pNeighborRoamInfo->currAPbssid,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015765 sizeof(tCsrBssid));
15766 pRequestBuf->ConnectedNetwork.ssId.length =
15767 pMac->roam.roamSession[sessionId].connectedProfile.SSID.length;
15768 vos_mem_copy(pRequestBuf->ConnectedNetwork.ssId.ssId,
15769 pMac->roam.roamSession[sessionId].connectedProfile.SSID.ssId,
15770 pRequestBuf->ConnectedNetwork.ssId.length);
15771 pRequestBuf->ConnectedNetwork.authentication =
15772 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
15773 pRequestBuf->ConnectedNetwork.encryption =
15774 pMac->roam.roamSession[sessionId].connectedProfile.EncryptionType;
15775 pRequestBuf->ConnectedNetwork.mcencryption =
15776 pMac->roam.roamSession[sessionId].connectedProfile.mcEncryptionType;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015777 if (pNeighborRoamInfo->cfgParams.neighborLookupThreshold)
15778 {
15779 pRequestBuf->LookupThreshold =
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015780 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborLookupThreshold * (-1);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015781 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
15782 }
15783 else
15784 {
15785 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Calculate Adaptive Threshold");
15786 operationChannel = pSession->connectedProfile.operationChannel;
15787
15788 if (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
15789 {
15790 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15791 "%s: csrGetParsedBssDescriptionIEs failed", __func__);
15792 vos_mem_free(pRequestBuf);
15793 return eHAL_STATUS_FAILURE;
15794 }
Kaushik, Sushant5874d032014-02-20 17:22:36 +053015795 if(NULL == pIes)
15796 {
15797 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15798 "%s : pIes is Null", __func__);
15799 return eHAL_STATUS_FAILURE;
15800 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015801 if (pIes->SuppRates.present)
15802 {
15803 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Number \t Rate");
15804 /*Check for both basic rates and extended rates.*/
15805 for (i = 0; i < pIes->SuppRates.num_rates; i++)
15806 {
15807 /*Check if the Rate is Mandatory or Not*/
15808 if (csrRatesIsDot11RateSupported(pMac, pIes->SuppRates.rates[i])
15809 && (pIes->SuppRates.rates[i] & 0x80))
15810 {
15811 /*Retrieve the actual data rate*/
15812 dataRate = (pIes->SuppRates.rates[i] & 0x7F)/2;
15813 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
15814 if (minRate == 0)
15815 minRate = dataRate;
15816 else
15817 minRate = (minRate < dataRate) ? minRate:dataRate;
15818 }
15819 }
15820
15821 if (pIes->ExtSuppRates.present)
15822 {
15823 for (i = 0; i < pIes->ExtSuppRates.num_rates; i++)
15824 {
15825 /*Check if the Rate is Mandatory or Not*/
15826 if (csrRatesIsDot11RateSupported(pMac, pIes->ExtSuppRates.rates[i])
15827 && (pIes->ExtSuppRates.rates[i] & 0x80))
15828 {
15829 /*Retrieve the actual data rate*/
15830 dataRate = (pIes->ExtSuppRates.rates[i] & 0x7F)/2;
15831 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
15832 if (minRate == 0)
15833 minRate = dataRate;
15834 else
15835 minRate = (minRate < dataRate) ? minRate:dataRate;
15836 }
15837 }
15838 }
15839 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "MinRate = %d", minRate);
15840 }
15841 else
15842 {
15843 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15844 "%s: Supp Rates not present in pIes", __func__);
15845 vos_mem_free(pRequestBuf);
15846 return eHAL_STATUS_FAILURE;
15847 }
15848 if (NULL != pIes)
15849 {
15850 vos_mem_free(pIes);
15851 pIes = NULL;
15852 }
15853 switch (minRate)
15854 {
15855 case 1:
15856 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_1MBPS;
15857 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_1MBPS;
15858 break;
15859 case 2:
15860 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_2MBPS;
15861 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_2MBPS;
15862 break;
15863 case 5:
15864 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_5_5MBPS;
15865 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_5_5MBPS;
15866 break;
15867 case 6:
15868 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
15869 {
15870 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_2G;
15871 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_2G;
15872 }
15873 else
15874 {
15875 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_5G;
15876 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_5G;
15877 }
15878 break;
15879 case 11:
15880 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_11MBPS;
15881 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_11MBPS;
15882 break;
15883 case 12:
15884 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
15885 {
15886 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_2G;
15887 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_2G;
15888 }
15889 else
15890 {
15891 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_5G;
15892 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_5G;
15893 }
15894 break;
15895 case 24:
15896 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
15897 {
15898 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_2G;
15899 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_2G;
15900 }
15901 else
15902 {
15903 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_5G;
15904 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_5G;
15905 }
15906 break;
15907 default:
15908 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_DEFAULT;
15909 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
15910 break;
15911 }
15912 }
15913 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
15914 "Chnl=%d,MinRate=%d,RxSenThr=%d,LookupThr=%d",
15915 operationChannel, minRate,
15916 pRequestBuf->RxSensitivityThreshold,
15917 pRequestBuf->LookupThreshold);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015918 pRequestBuf->RoamRssiDiff =
15919 pMac->roam.configParam.RoamRssiDiff;
15920 pRequestBuf->Command = command;
15921 pRequestBuf->StartScanReason = reason;
15922 pRequestBuf->NeighborScanTimerPeriod =
15923 pNeighborRoamInfo->cfgParams.neighborScanPeriod;
15924 pRequestBuf->NeighborRoamScanRefreshPeriod =
15925 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod;
15926 pRequestBuf->NeighborScanChannelMinTime =
15927 pNeighborRoamInfo->cfgParams.minChannelScanTime;
15928 pRequestBuf->NeighborScanChannelMaxTime =
15929 pNeighborRoamInfo->cfgParams.maxChannelScanTime;
15930 pRequestBuf->EmptyRefreshScanPeriod =
15931 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -080015932 /* MAWC feature */
15933 pRequestBuf->MAWCEnabled =
15934 pMac->roam.configParam.MAWCEnabled;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015935#ifdef FEATURE_WLAN_ESE
15936 pRequestBuf->IsESEEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015937#endif
15938 if (
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015939#ifdef FEATURE_WLAN_ESE
15940 ((pNeighborRoamInfo->isESEAssoc) &&
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015941 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived ==
15942 eANI_BOOLEAN_FALSE)) ||
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015943 (pNeighborRoamInfo->isESEAssoc == eANI_BOOLEAN_FALSE) ||
15944#endif // ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015945 currChannelListInfo->numOfChannels == 0)
15946 {
15947
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015948 /*Retrieve the Channel Cache either from ini or from the Occupied Channels list.
15949 * Give Preference to INI Channels.*/
15950 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
15951 {
15952 ChannelList = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
15953 /*The INI channels need to be filtered with respect to the current
15954 * band that is supported.*/
15955 eBand = pMac->roam.configParam.bandCapability;
15956 if ((eCSR_BAND_24 != eBand) && (eCSR_BAND_5G != eBand) && (eCSR_BAND_ALL != eBand))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015957 {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015958 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15959 "Invalid band, No operation carried out (Band %d)", eBand);
15960 vos_mem_free(pRequestBuf);
15961 return eHAL_STATUS_FAILURE;
15962 }
15963 for (i=0; i<pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels; i++)
15964 {
15965 if(((eCSR_BAND_24 == eBand) && CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
15966 ((eCSR_BAND_5G == eBand) && CSR_IS_CHANNEL_5GHZ(*ChannelList)) ||
15967 (eCSR_BAND_ALL == eBand))
15968 {
15969 if(!CSR_IS_CHANNEL_DFS(*ChannelList) &&
15970 csrRoamIsChannelValid(pMac, *ChannelList) &&
15971 *ChannelList && (num_channels < SIR_ROAM_MAX_CHANNELS))
15972 {
15973 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
15974 }
15975 }
15976 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015977 }
15978 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
15979 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015980 }
15981 else
15982 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015983 ChannelList = pMac->scan.occupiedChannels.channelList;
15984 for(i=0; i<pMac->scan.occupiedChannels.numChannels; i++)
15985 {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015986 if(!CSR_IS_CHANNEL_DFS(*ChannelList) &&
15987 *ChannelList && (num_channels < SIR_ROAM_MAX_CHANNELS))
15988 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015989 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015990 }
15991 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015992 }
15993 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
15994 /* If the profile changes as to what it was earlier, inform the FW through
15995 * FLUSH as ChannelCacheType in which case, the FW will flush the occupied channels
15996 * for the earlier profile and try to learn them afresh.*/
15997 if (reason == REASON_FLUSH_CHANNEL_LIST)
15998 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
15999 else {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016000 if (csrNeighborRoamIsNewConnectedProfile(pMac))
16001 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
16002 else
16003 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016004 }
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016005 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016006 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016007#ifdef FEATURE_WLAN_ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016008 else
16009 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016010 /* If ESE is enabled, and a neighbor Report is received,then
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016011 * Ignore the INI Channels or the Occupied Channel List. Consider
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016012 * the channels in the neighbor list sent by the ESE AP.*/
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016013 if (currChannelListInfo->numOfChannels != 0)
16014 {
16015 ChannelList = currChannelListInfo->ChannelList;
16016 for (i=0;i<currChannelListInfo->numOfChannels;i++)
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016017 {
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016018 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
16019 {
16020 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
16021 }
16022 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016023 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016024 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16025 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
16026 }
16027 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016028#endif
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016029 for (i = 0, j = 0; i < pRequestBuf->ConnectedNetwork.ChannelCount; i++)
16030 {
16031 j += snprintf(ChannelCacheStr + j, sizeof(ChannelCacheStr) - j," %d",
16032 pRequestBuf->ConnectedNetwork.ChannelCache[i]);
16033 }
16034 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
16035 "ChnlCacheType:%d, No of Chnls:%d,Channels: %s",
16036 pRequestBuf->ChannelCacheType,
16037 pRequestBuf->ConnectedNetwork.ChannelCount,
16038 ChannelCacheStr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016039 num_channels = 0;
16040 ChannelList = NULL;
16041
16042 /* Maintain the Valid Channels List*/
Srinivas Girigowda56076852013-08-20 14:00:50 -070016043 host_channels = sizeof(pMac->roam.validChannelList);
16044 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &host_channels)))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016045 {
Srinivas Girigowda56076852013-08-20 14:00:50 -070016046 ChannelList = pMac->roam.validChannelList;
16047 pMac->roam.numValidChannels = host_channels;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016048 }
Srinivas Girigowda56076852013-08-20 14:00:50 -070016049 else
16050 {
16051 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16052 "%s:Failed to get the valid channel list", __func__);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -070016053 vos_mem_free(pRequestBuf);
Srinivas Girigowda56076852013-08-20 14:00:50 -070016054 return eHAL_STATUS_FAILURE;
16055 }
16056 for(i=0; i<pMac->roam.numValidChannels; i++)
16057 {
16058 if(!CSR_IS_CHANNEL_DFS(*ChannelList) && *ChannelList)
16059 {
16060 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
16061 }
16062 ChannelList++;
16063 }
16064 pRequestBuf->ValidChannelCount = num_channels;
16065
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016066 pRequestBuf->MDID.mdiePresent =
16067 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent;
16068 pRequestBuf->MDID.mobilityDomain =
16069 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mobilityDomain;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016070 pRequestBuf->nProbes = pMac->roam.configParam.nProbes;
16071
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016072 pRequestBuf->HomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016073 /* Home Away Time should be at least equal to (MaxDwell time + (2*RFS)),
16074 * where RFS is the RF Switching time. It is twice RFS to consider the
16075 * time to go off channel and return to the home channel. */
16076 if (pRequestBuf->HomeAwayTime < (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)))
16077 {
16078 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
16079 "%s: Invalid config, Home away time(%d) is less than (twice RF switching time + channel max time)(%d)"
16080 " Hence enforcing home away time to disable (0)",
16081 __func__, pRequestBuf->HomeAwayTime,
16082 (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)));
16083 pRequestBuf->HomeAwayTime = 0;
16084 }
16085 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,"HomeAwayTime:%d",pRequestBuf->HomeAwayTime);
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070016086
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016087 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
16088 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
16089 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
16090 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_24G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
16091 pRequestBuf->p24GProbeTemplate, &pRequestBuf->us24GProbeTemplateLen);
16092
16093 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_5G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
16094 pRequestBuf->p5GProbeTemplate, &pRequestBuf->us5GProbeTemplateLen);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016095send_roam_scan_offload_cmd:
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016096 msg.type = WDA_ROAM_SCAN_OFFLOAD_REQ;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016097 msg.reserved = 0;
16098 msg.bodyptr = pRequestBuf;
16099 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
16100 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016101 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_ROAM_SCAN_OFFLOAD_REQ message to WDA", __func__);
16102 vos_mem_free(pRequestBuf);
16103 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016104 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016105 else
16106 {
16107 if (ROAM_SCAN_OFFLOAD_START == command)
16108 bRoamScanOffloadStarted = VOS_TRUE;
16109 else if (ROAM_SCAN_OFFLOAD_STOP == command)
16110 bRoamScanOffloadStarted = VOS_FALSE;
16111 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016112
16113 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Roam Scan Offload Command %d, Reason %d", command, reason);
16114 return status;
16115}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016116
16117eHalStatus csrRoamOffloadScanRspHdlr(tpAniSirGlobal pMac, tANI_U8 reason)
16118{
16119 switch(reason)
16120 {
16121 case 0:
16122 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with failure status");
16123 break;
16124 case REASON_OS_REQUESTED_ROAMING_NOW:
16125 csrNeighborRoamProceedWithHandoffReq(pMac);
16126 break;
16127 default:
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -070016128 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 -070016129 }
16130 return eHAL_STATUS_SUCCESS;
16131}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016132#endif
16133
Jeff Johnson295189b2012-06-20 16:38:30 -070016134tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
16135 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
16136{
16137 tANI_BOOLEAN found = FALSE;
16138 eHalStatus status = eHAL_STATUS_SUCCESS;
16139 tCsrPeStatsReqInfo staEntry;
16140 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
16141 tListElem *pStaEntry = NULL;
16142 VOS_STATUS vosStatus;
16143 tPmcPowerState powerState;
16144 *pFound = FALSE;
16145
16146 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
16147 if(pStaEntry)
16148 {
16149 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
16150 if(pTempStaEntry->periodicity)
16151 {
16152 pTempStaEntry->periodicity =
16153 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
16154 }
16155 else
16156 {
16157 pTempStaEntry->periodicity = periodicity;
16158 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016159 pTempStaEntry->numClient++;
16160 found = TRUE;
16161 }
16162 else
16163 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016164 vos_mem_set(&staEntry, sizeof(tCsrPeStatsReqInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016165 staEntry.numClient = 1;
16166 staEntry.periodicity = periodicity;
16167 staEntry.pMac = pMac;
16168 staEntry.rspPending = FALSE;
16169 staEntry.staId = staId;
16170 staEntry.statsMask = statsMask;
16171 staEntry.timerRunning = FALSE;
16172 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
16173 if(!pTempStaEntry)
16174 {
16175 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016176 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070016177 return NULL;
16178 }
16179 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016180 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
16181 if(ePMC_FULL_POWER == powerState)
16182 {
16183 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
16184 {
16185 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
16186 }
16187 }
16188 else
16189 {
16190 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
16191 {
16192 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
16193 }
16194 }
16195 if(!pTempStaEntry->timerRunning)
16196 {
16197 //send down a req in case of one time req, for periodic ones wait for timer to expire
16198 if(!pTempStaEntry->rspPending &&
16199 !pTempStaEntry->periodicity)
16200 {
16201 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
16202 if(!HAL_STATUS_SUCCESS(status))
16203 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016204 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016205 }
16206 else
16207 {
16208 pTempStaEntry->rspPending = TRUE;
16209 }
16210 }
16211 if(pTempStaEntry->periodicity)
16212 {
16213 if(!found)
16214 {
16215
16216 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
16217 csrRoamPeStatsTimerHandler, pTempStaEntry );
16218 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16219 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016220 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016221 return NULL;
16222 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016223 }
16224 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016225 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070016226 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
16227 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16228 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016229 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016230 return NULL;
16231 }
16232 pTempStaEntry->timerRunning = TRUE;
16233 }
16234 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016235 *pFound = found;
16236 return pTempStaEntry;
16237}
16238
Jeff Johnson295189b2012-06-20 16:38:30 -070016239/*
16240 pStaEntry is no longer invalid upon the return of this function.
16241*/
16242static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
16243{
16244 if(pEntry)
16245 {
16246 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
16247 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016248 vos_mem_free(GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070016249 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016250 }
16251 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016252
16253void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
16254{
16255 tListElem *pEntry;
16256 tCsrPeStatsReqInfo *pTempStaEntry;
16257 VOS_STATUS vosStatus;
16258 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016259 if(!pEntry)
16260 {
16261 //list empty
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016262 smsLog(pMac, LOGE, FL(" List empty, no stats req for PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016263 return;
16264 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016265 while( pEntry )
16266 {
16267 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016268 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
16269 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016270 smsLog(pMac, LOGW, FL("Match found"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016271 if(pTempStaEntry->timerRunning)
16272 {
16273 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
16274 /* If we are not able to stop the timer here, just remove
16275 * the entry from the linked list. Destroy the timer object
16276 * and free the memory in the timer CB
16277 */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016278 if ( vosStatus == VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -070016279 {
16280 /* the timer is successfully stopped */
16281 pTempStaEntry->timerRunning = FALSE;
16282
16283 /* Destroy the timer */
16284 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
16285 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16286 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016287 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016288 }
16289 }
16290 else
16291 {
16292 // the timer could not be stopped. Hence destroy and free the
16293 // memory for the PE stat entry in the timer CB.
16294 pTempStaEntry->timerStopFailed = TRUE;
16295 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016296 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016297
16298 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
16299 {
16300 // Only free the memory if we could stop the timer successfully
16301 if(!pTempStaEntry->timerStopFailed)
16302 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016303 vos_mem_free(pTempStaEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070016304 pTempStaEntry = NULL;
16305 }
16306 break;
16307 }
16308
16309 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
16310 }
16311 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016312 return;
16313}
16314
16315
Jeff Johnsone7245742012-09-05 17:12:55 -070016316void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070016317{
16318
Jeff Johnsone7245742012-09-05 17:12:55 -070016319 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
16320 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
16321 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
16322 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
16323 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
16324 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
16325 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070016326 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070016327 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
16328 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
16329 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
16330 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
16331 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
16332 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070016333 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070016334 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
16335 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070016336
16337}
16338
Jeff Johnson295189b2012-06-20 16:38:30 -070016339void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
16340 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
16341{
16342 tANI_U8 stats[500];
16343 tANI_U8 *pStats = NULL;
16344 tANI_U32 tempMask = 0;
16345 tANI_U8 counter = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016346 if(!callback)
16347 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016348 smsLog(pMac, LOGE, FL("Cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016349 return;
16350 }
16351 if(!statsMask)
16352 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016353 smsLog(pMac, LOGE, FL("Cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016354 return;
16355 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016356 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070016357 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070016358 while(tempMask)
16359 {
16360 if(tempMask & 1)
16361 {
16362 //new stats info from PE, fill up the stats strucutres in PMAC
16363 switch(counter)
16364 {
16365 case eCsrSummaryStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016366 smsLog( pMac, LOG2, FL("Summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016367 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
16368 sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016369 pStats += sizeof(tCsrSummaryStatsInfo);
16370 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016371 case eCsrGlobalClassAStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016372 smsLog( pMac, LOG2, FL("ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016373 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
16374 sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016375 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016376 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016377 case eCsrGlobalClassBStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016378 smsLog( pMac, LOG2, FL("ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016379 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
16380 sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016381 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016382 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016383 case eCsrGlobalClassCStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016384 smsLog( pMac, LOG2, FL("ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016385 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
16386 sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016387 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016388 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016389 case eCsrGlobalClassDStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016390 smsLog( pMac, LOG2, FL("ClassD stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016391 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
16392 sizeof(tCsrGlobalClassDStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016393 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016394 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016395 case eCsrPerStaStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016396 smsLog( pMac, LOG2, FL("PerSta stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016397 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
16398 sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016399 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016400 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016401 default:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016402 smsLog( pMac, LOGE, FL("Unknown stats type and counter %d"), counter);
Jeff Johnson295189b2012-06-20 16:38:30 -070016403 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016404 }
16405 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016406 tempMask >>=1;
16407 counter++;
16408 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016409 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070016410}
16411
Jeff Johnson295189b2012-06-20 16:38:30 -070016412eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
16413{
16414 tListElem *pEntry = NULL;
16415 tListElem *pPrevEntry = NULL;
16416 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
16417 eHalStatus status = eHAL_STATUS_SUCCESS;
16418 VOS_STATUS vosStatus;
16419 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016420 if(!pEntry)
16421 {
16422 //list empty
16423 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016424 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070016425 return status;
16426 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016427 while( pEntry )
16428 {
16429 if(pPrevEntry)
16430 {
16431 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16432 //send up the stats report
16433 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16434 pTempStaEntry->staId, pTempStaEntry->pContext);
16435 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16436 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016437 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016438 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
16439 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016440 pTempStaEntry->pPeStaEntry->numClient--;
16441 //check if we need to delete the entry from peStatsReqList too
16442 if(!pTempStaEntry->pPeStaEntry->numClient)
16443 {
16444 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
16445 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016446 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016447 //check if we need to stop the tl stats timer too
16448 pMac->roam.tlStatsReqInfo.numClient--;
16449 if(!pMac->roam.tlStatsReqInfo.numClient)
16450 {
16451 if(pMac->roam.tlStatsReqInfo.timerRunning)
16452 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016453 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
16454 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016455 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016456 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016457 //we will continue
16458 }
16459 }
16460 pMac->roam.tlStatsReqInfo.periodicity = 0;
16461 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
16462 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016463 if (pTempStaEntry->periodicity)
16464 {
16465 //While creating StaEntry in csrGetStatistics,
16466 //Initializing and starting timer only when periodicity is set.
16467 //So Stop and Destroy timer only when periodicity is set.
16468
Jeff Johnsone7245742012-09-05 17:12:55 -070016469 vos_timer_stop( &pTempStaEntry->timer );
16470 // Destroy the vos timer...
16471 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
16472 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16473 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016474 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070016475 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016476 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016477
Jeff Johnson295189b2012-06-20 16:38:30 -070016478
16479 pPrevEntry = pEntry;
16480 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
16481 }
16482 //the last one
16483 if(pPrevEntry)
16484 {
16485 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16486 //send up the stats report
16487 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16488 pTempStaEntry->staId, pTempStaEntry->pContext);
16489 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16490 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016491 return status;
16492
16493}
16494
Jeff Johnson295189b2012-06-20 16:38:30 -070016495eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
16496 tRequestFullPowerReason *pReason,
16497 tANI_BOOLEAN *pfNeedPower )
16498{
16499 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
16500 tRequestFullPowerReason reason = eSME_REASON_OTHER;
16501 tPmcState pmcState;
16502 eHalStatus status = eHAL_STATUS_SUCCESS;
16503 // TODO : Session info unavailable
16504 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016505 if( pfNeedPower )
16506 {
16507 *pfNeedPower = eANI_BOOLEAN_FALSE;
16508 }
16509 //We only handle CSR commands
16510 if( !(eSmeCsrCommandMask & pCommand->command) )
16511 {
16512 return eHAL_STATUS_SUCCESS;
16513 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016514 //Check PMC state first
16515 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070016516 switch( pmcState )
16517 {
16518 case REQUEST_IMPS:
16519 case IMPS:
16520 if( eSmeCommandScan == pCommand->command )
16521 {
16522 switch( pCommand->u.scanCmd.reason )
16523 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016524#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
16525 case eCsrScanGetLfrResult:
16526#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016527 case eCsrScanGetResult:
16528 case eCsrScanBGScanAbort:
16529 case eCsrScanBGScanEnable:
16530 case eCsrScanGetScanChnInfo:
16531 //Internal process, no need for full power
16532 fNeedFullPower = eANI_BOOLEAN_FALSE;
16533 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016534 default:
16535 //Other scans are real scan, ask for power
16536 fNeedFullPower = eANI_BOOLEAN_TRUE;
16537 break;
16538 } //switch
16539 }
16540 else
16541 {
16542 //ask for power for roam and status change
16543 fNeedFullPower = eANI_BOOLEAN_TRUE;
16544 }
16545 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016546 case REQUEST_BMPS:
16547 case BMPS:
16548 case REQUEST_START_UAPSD:
16549 case UAPSD:
16550 //We treat WOWL same as BMPS
16551 case REQUEST_ENTER_WOWL:
16552 case WOWL:
16553 if( eSmeCommandRoam == pCommand->command )
16554 {
16555 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
16556 tCsrScanResult *pScanResult;
16557 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070016558 switch ( pCommand->u.roamCmd.roamReason )
16559 {
16560 case eCsrForcedDisassoc:
16561 case eCsrForcedDisassocMICFailure:
16562 reason = eSME_LINK_DISCONNECTED_BY_HDD;
16563 fNeedFullPower = eANI_BOOLEAN_TRUE;
16564 break;
16565 case eCsrSmeIssuedDisassocForHandoff:
16566 case eCsrForcedDeauth:
16567 case eCsrHddIssuedReassocToSameAP:
16568 case eCsrSmeIssuedReassocToSameAP:
16569 fNeedFullPower = eANI_BOOLEAN_TRUE;
16570 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016571 case eCsrCapsChange:
16572 fNeedFullPower = eANI_BOOLEAN_TRUE;
16573 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016574 default:
16575 //Check whether the profile is already connected. If so, no need for full power
16576 //Note: IBSS is ignored for now because we don't support powersave in IBSS
16577 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
16578 {
16579 //Only need to check the first one
16580 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
16581 if( pEntry )
16582 {
16583 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
16584#if 0
16585 // TODO : Session Specific info pConnectBssDesc
16586 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
16587 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
16588 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
16589 {
16590 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
16591 // with Authenticating first. To force this, stop the current association (Disassociate) and
16592 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
16593 // a new Association.
16594 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
16595 {
16596 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
16597 {
16598 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
16599 //No need for full power
16600 //Set the flag so the code later can avoid to do the above
16601 //check again.
16602 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
16603 break;
16604 }
16605 }
16606 }
16607#endif
16608 }
16609 }
16610 //If we are here, full power is needed
16611 fNeedFullPower = eANI_BOOLEAN_TRUE;
16612 break;
16613 }
16614 }
16615 else if( eSmeCommandWmStatusChange == pCommand->command )
16616 {
16617 //need full power for all
16618 fNeedFullPower = eANI_BOOLEAN_TRUE;
16619 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
16620 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016621#ifdef FEATURE_WLAN_TDLS
16622 else if( eSmeCommandTdlsAddPeer == pCommand->command )
16623 {
16624 //TDLS link is getting established. need full power
16625 fNeedFullPower = eANI_BOOLEAN_TRUE;
16626 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
16627 }
16628#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016629 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016630 case REQUEST_STOP_UAPSD:
16631 case REQUEST_EXIT_WOWL:
16632 if( eSmeCommandRoam == pCommand->command )
16633 {
16634 fNeedFullPower = eANI_BOOLEAN_TRUE;
16635 switch ( pCommand->u.roamCmd.roamReason )
16636 {
16637 case eCsrForcedDisassoc:
16638 case eCsrForcedDisassocMICFailure:
16639 reason = eSME_LINK_DISCONNECTED_BY_HDD;
16640 break;
16641 default:
16642 break;
16643 }
16644 }
16645 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016646 case STOPPED:
16647 case REQUEST_STANDBY:
16648 case STANDBY:
16649 case LOW_POWER:
16650 //We are not supposed to do anything
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016651 smsLog( pMac, LOGE, FL( " cannot process because PMC is in stopped/standby state %d" ), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070016652 status = eHAL_STATUS_FAILURE;
16653 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016654 case FULL_POWER:
16655 case REQUEST_FULL_POWER:
16656 default:
16657 //No need to ask for full power. This has to be FULL_POWER state
16658 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016659 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070016660 if( pReason )
16661 {
16662 *pReason = reason;
16663 }
16664 if( pfNeedPower )
16665 {
16666 *pfNeedPower = fNeedFullPower;
16667 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016668 return ( status );
16669}
16670
Jeff Johnson295189b2012-06-20 16:38:30 -070016671static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
16672{
16673 eHalStatus status = eHAL_STATUS_SUCCESS;
16674 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
16675 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070016676 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070016677 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
16678 {
16679 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
16680 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016681 return ( status );
16682}
16683
Jeff Johnson295189b2012-06-20 16:38:30 -070016684tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
16685{
16686 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070016687 if( pCmd )
16688 {
16689 pMac->roam.sPendingCommands++;
16690 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016691 return ( pCmd );
16692}
16693
Jeff Johnson295189b2012-06-20 16:38:30 -070016694void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
16695{
16696 if (pMac->roam.sPendingCommands > 0)
16697 {
16698 //All command allocated through csrGetCommandBuffer need to
16699 //decrement the pending count when releasing.
16700 pMac->roam.sPendingCommands--;
16701 smeReleaseCommand( pMac, pCommand );
16702 }
16703 else
16704 {
16705 smsLog(pMac, LOGE, FL( "no pending commands"));
16706 VOS_ASSERT(0);
16707 }
16708}
16709
Jeff Johnson295189b2012-06-20 16:38:30 -070016710//Return SUCCESS is the command is queued, failed
16711eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
16712{
16713 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016714 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
16715 {
16716 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
16717 pCommand->u.scanCmd.reason);
16718 return eHAL_STATUS_CSR_WRONG_STATE;
16719 }
16720
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016721 if ((pMac->fScanOffload) && (pCommand->command == eSmeCommandScan))
16722 {
16723 csrLLInsertTail(&pMac->sme.smeScanCmdPendingList,
16724 &pCommand->Link, LL_ACCESS_LOCK);
16725 // process the command queue...
16726 smeProcessPendingQueue(pMac);
16727 status = eHAL_STATUS_SUCCESS;
16728 goto end;
16729 }
16730
Jeff Johnson295189b2012-06-20 16:38:30 -070016731 //We can call request full power first before putting the command into pending Q
16732 //because we are holding SME lock at this point.
16733 status = csrRequestFullPower( pMac, pCommand );
16734 if( HAL_STATUS_SUCCESS( status ) )
16735 {
16736 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070016737 //make sure roamCmdPendingList is not empty first
16738 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
16739 if( fNoCmdPending )
16740 {
16741 smePushCommand( pMac, pCommand, fHighPriority );
16742 }
16743 else
16744 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016745 //Other commands are waiting for PMC callback, queue the new command to the pending Q
Jeff Johnson295189b2012-06-20 16:38:30 -070016746 //no list lock is needed since SME lock is held
16747 if( !fHighPriority )
16748 {
16749 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16750 }
16751 else {
16752 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16753 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016754 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016755 }
16756 else if( eHAL_STATUS_PMC_PENDING == status )
16757 {
16758 //no list lock is needed since SME lock is held
16759 if( !fHighPriority )
16760 {
16761 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16762 }
16763 else {
16764 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16765 }
16766 //Let caller know the command is queue
16767 status = eHAL_STATUS_SUCCESS;
16768 }
16769 else
16770 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016771 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
Jeff Johnson295189b2012-06-20 16:38:30 -070016772 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016773 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070016774 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016775end:
Jeff Johnson295189b2012-06-20 16:38:30 -070016776 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070016777}
Jeff Johnson295189b2012-06-20 16:38:30 -070016778eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
16779{
16780 eHalStatus status = eHAL_STATUS_SUCCESS;
16781 tSirUpdateAPWPSIEsReq *pMsg;
16782 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
16783
16784 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16785 if (NULL == pSession)
16786 {
16787 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
16788 return eHAL_STATUS_FAILURE;
16789 }
16790
Jeff Johnson295189b2012-06-20 16:38:30 -070016791 do
16792 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016793 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
16794 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
16795 vos_mem_set(pMsg, sizeof(tSirUpdateAPWPSIEsReq), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016796 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
16797
16798 pBuf = (tANI_U8 *)&pMsg->transactionId;
lukez3c809222013-05-03 10:23:02 -070016799 VOS_ASSERT(pBuf);
16800
Jeff Johnson295189b2012-06-20 16:38:30 -070016801 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070016802 // transactionId
16803 *pBuf = 0;
16804 *( pBuf + 1 ) = 0;
16805 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070016806 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053016807 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
16808 sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070016809 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070016810 //sessionId
16811 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070016812 // APWPSIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053016813 vos_mem_copy((tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
Jeff Johnson295189b2012-06-20 16:38:30 -070016814 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070016815 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070016816 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016817 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070016818 return ( status );
16819}
Jeff Johnson295189b2012-06-20 16:38:30 -070016820eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
16821{
16822 eHalStatus status = eHAL_STATUS_SUCCESS;
16823 tSirUpdateAPWPARSNIEsReq *pMsg;
16824 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016825 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16826 if (NULL == pSession)
16827 {
16828 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
16829 return eHAL_STATUS_FAILURE;
16830 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016831 do
16832 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016833 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPARSNIEsReq));
16834 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
16835 vos_mem_set(pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016836 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070016837 pBuf = (tANI_U8 *)&pMsg->transactionId;
16838 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070016839 // transactionId
16840 *pBuf = 0;
16841 *( pBuf + 1 ) = 0;
16842 pBuf += sizeof(tANI_U16);
lukez3c809222013-05-03 10:23:02 -070016843 VOS_ASSERT(pBuf);
16844
Jeff Johnson295189b2012-06-20 16:38:30 -070016845 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053016846 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
16847 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070016848 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070016849 // sessionId
16850 *pBuf++ = (tANI_U8)sessionId;
16851
16852 // APWPARSNIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053016853 vos_mem_copy((tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070016854 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070016855 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070016856 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016857 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070016858 return ( status );
16859}
Jeff Johnson295189b2012-06-20 16:38:30 -070016860
16861#ifdef WLAN_FEATURE_VOWIFI_11R
16862//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
16863eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
16864{
16865 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
16866 tpSirFTPreAuthReq pftPreAuthReq;
16867 tANI_U16 auth_req_len = 0;
16868 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070016869 auth_req_len = sizeof(tSirFTPreAuthReq);
16870 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
Kiet Lam64c1b492013-07-12 13:56:44 +053016871 if (NULL == pftPreAuthReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070016872 {
16873 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
16874 return eHAL_STATUS_RESOURCES;
16875 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016876 // Save the SME Session ID here. We need it while processing the preauth response
16877 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070016878 vos_mem_zero(pftPreAuthReq, auth_req_len);
16879
16880 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
16881 sizeof(pBssDescription->length) + pBssDescription->length);
16882
16883 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
16884
16885 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
16886
Kiet Lam64c1b492013-07-12 13:56:44 +053016887 vos_mem_copy((void *)&pftPreAuthReq->currbssId,
16888 (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
16889 vos_mem_copy((void *)&pftPreAuthReq->preAuthbssId,
16890 (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070016891
Jeff Johnson295189b2012-06-20 16:38:30 -070016892#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080016893 if (csrRoamIs11rAssoc(pMac) &&
16894 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070016895 {
16896 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
Kiet Lam64c1b492013-07-12 13:56:44 +053016897 vos_mem_copy(pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
16898 pMac->ft.ftSmeContext.auth_ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -070016899 }
16900 else
16901#endif
16902 {
16903 pftPreAuthReq->ft_ies_length = 0;
16904 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070016905 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
16906 sizeof(pBssDescription->length) + pBssDescription->length);
16907 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070016908 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
16909}
Jeff Johnson295189b2012-06-20 16:38:30 -070016910/*--------------------------------------------------------------------------
16911 * This will receive and process the FT Pre Auth Rsp from the current
16912 * associated ap.
16913 *
16914 * This will invoke the hdd call back. This is so that hdd can now
16915 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
16916 ------------------------------------------------------------------------*/
16917void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
16918{
16919 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
16920 eHalStatus status = eHAL_STATUS_SUCCESS;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016921#if defined(FEATURE_WLAN_LFR) || defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016922 tCsrRoamInfo roamInfo;
16923#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016924
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070016925#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080016926 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070016927 if (status != eHAL_STATUS_SUCCESS) {
16928 /*
16929 * Bail out if pre-auth was not even processed.
16930 */
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016931 smsLog(pMac, LOGE,FL("Preauth was not processed: %d SessionID: %d"),
16932 status, pFTPreAuthRsp->smeSessionId);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070016933 return;
16934 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016935#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016936 /* The below function calls/timers should be invoked only if the pre-auth is successful */
16937 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
16938 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070016939 // Implies a success
16940 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070016941 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
16942 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
Tushnim Bhattacharyya8436d772013-06-26 23:03:29 -070016943 /* No need to notify qos module if this is a non 11r roam*/
16944 if (csrRoamIs11rAssoc(pMac))
16945 {
16946 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
16947 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016948 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
16949 * actual transition from the current to handoff AP is triggered */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016950 status = vos_timer_start(&pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
16951 60);
Jeff Johnson295189b2012-06-20 16:38:30 -070016952 if (eHAL_STATUS_SUCCESS != status)
16953 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016954 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070016955 return;
16956 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016957 // Save the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053016958 vos_mem_copy((void *)&pMac->ft.ftSmeContext.preAuthbssId,
16959 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070016960 if (csrRoamIs11rAssoc(pMac))
16961 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
16962 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
16963
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016964#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
16965 if (csrRoamIsESEAssoc(pMac))
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070016966 {
16967 /* read TSF */
16968 csrRoamReadTSF(pMac, (tANI_U8 *)roamInfo.timestamp);
16969
16970 // Save the bssid from the received response
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080016971 vos_mem_copy((void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070016972 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_CCKM_PREAUTH_NOTIFY, 0);
16973 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016974#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016975#ifdef FEATURE_WLAN_LFR
16976 // If Legacy Fast Roaming is enabled, signal the supplicant
16977 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053016978 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016979 {
16980 // Save the bssid from the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053016981 vos_mem_copy((void *)&roamInfo.bssid,
16982 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016983 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
16984 }
16985
16986#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016987
16988 // Done with it, init it.
16989 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
16990}
16991#endif
16992#ifdef FEATURE_WLAN_BTAMP_UT_RF
16993void csrRoamJoinRetryTimerHandler(void *pv)
16994{
16995 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
16996 tpAniSirGlobal pMac = pInfo->pMac;
16997 tANI_U32 sessionId = pInfo->sessionId;
16998 tCsrRoamSession *pSession;
16999
17000 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
17001 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017002 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070017003 pSession = CSR_GET_SESSION( pMac, sessionId );
17004 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
17005 {
17006 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
17007 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017008 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070017009 }
17010 }
17011 }
17012}
Jeff Johnson295189b2012-06-20 16:38:30 -070017013eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
17014{
17015 eHalStatus status = eHAL_STATUS_FAILURE;
17016 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
17017
17018 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
17019 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017020 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070017021 pSession->maxRetryCount--;
17022 pSession->joinRetryTimerInfo.pMac = pMac;
17023 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017024 status = vos_timer_start(&pSession->hTimerJoinRetry, interval/PAL_TIMER_TO_MS_UNIT);
17025 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070017026 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017027 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070017028 }
17029 }
17030 else
17031 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017032 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070017033 pSession->maxRetryCount);
17034 }
17035
17036 return (status);
17037}
Jeff Johnson295189b2012-06-20 16:38:30 -070017038eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
17039{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017040 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070017041 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
17042 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017043 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerJoinRetry));
Jeff Johnson295189b2012-06-20 16:38:30 -070017044 }
17045
17046 return eHAL_STATUS_SUCCESS;
17047}
17048#endif
17049
17050
17051/*
17052 pBuf points to the beginning of the message
17053 LIM packs disassoc rsp as below,
17054 messageType - 2 bytes
17055 messageLength - 2 bytes
17056 sessionId - 1 byte
17057 transactionId - 2 bytes (tANI_U16)
17058 reasonCode - 4 bytes (sizeof(tSirResultCodes))
17059 peerMacAddr - 6 bytes
17060 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
17061*/
17062static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
17063{
17064 if(pBuf && pRsp)
17065 {
17066 pBuf += 4; //skip type and length
17067 pRsp->sessionId = *pBuf++;
17068 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
17069 pBuf += 2;
17070 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
17071 pBuf += 4;
17072 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
17073 }
17074}
17075
Jeff Johnsond13512a2012-07-17 11:42:19 -070017076eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
17077{
17078 static uNvTables nvTables;
17079 eHalStatus status = eHAL_STATUS_SUCCESS;
17080 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
17081
17082 /* read the country code from NV and use it */
17083 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
17084 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017085 vos_mem_copy(pCountry, nvTables.defaultCountryTable.countryCode,
17086 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017087 return status;
17088 }
17089 else
17090 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017091 vos_mem_copy(pCountry, "XXX", WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017092 status = eHAL_STATUS_FAILURE;
17093 return status;
17094 }
17095}
17096
17097eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
17098{
Kiet Lam64c1b492013-07-12 13:56:44 +053017099 vos_mem_copy(pCountry, pMac->scan.countryCode11d, WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017100 return eHAL_STATUS_SUCCESS;
17101}
schang86c22c42013-03-13 18:41:24 -070017102
17103eHalStatus csrSetTxPower(tpAniSirGlobal pMac, v_U8_t sessionId, v_U8_t mW)
17104{
17105 tSirSetTxPowerReq *pMsg = NULL;
17106 eHalStatus status = eHAL_STATUS_SUCCESS;
17107 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17108
17109 if (!pSession)
17110 {
17111 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17112 return eHAL_STATUS_FAILURE;
17113 }
17114
Kiet Lam64c1b492013-07-12 13:56:44 +053017115 pMsg = vos_mem_malloc(sizeof(tSirSetTxPowerReq));
17116 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
17117 vos_mem_set((void *)pMsg, sizeof(tSirSetTxPowerReq), 0);
17118 pMsg->messageType = eWNI_SME_SET_TX_POWER_REQ;
17119 pMsg->length = sizeof(tSirSetTxPowerReq);
17120 pMsg->mwPower = mW;
17121 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
17122 sizeof(tSirMacAddr));
17123 status = palSendMBMessage(pMac->hHdd, pMsg);
17124 if (!HAL_STATUS_SUCCESS(status))
schang86c22c42013-03-13 18:41:24 -070017125 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017126 smsLog(pMac, LOGE, FL(" csr set TX Power Post MSG Fail %d "), status);
17127 //pMsg is freed by palSendMBMessage
schang86c22c42013-03-13 18:41:24 -070017128 }
17129 return status;
17130}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017131
Sandeep Puligilla332ea912014-02-04 00:16:24 +053017132eHalStatus csrHT40StopOBSSScan(tpAniSirGlobal pMac, v_U8_t sessionId)
17133{
17134 tSirSmeHT40OBSSStopScanInd *pMsg = NULL;
17135 eHalStatus status = eHAL_STATUS_SUCCESS;
17136 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17137
17138 if (!pSession)
17139 {
17140 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17141 return eHAL_STATUS_FAILURE;
17142 }
17143 if(IS_HT40_OBSS_SCAN_FEATURE_ENABLE)
17144 {
17145 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSStopScanInd));
17146 vos_mem_zero((void *)pMsg, sizeof(tSirSmeHT40OBSSStopScanInd));
17147 pMsg->messageType = eWNI_SME_HT40_STOP_OBSS_SCAN_IND;
17148 pMsg->length = sizeof(tANI_U8);
17149 pMsg->seesionId = sessionId;
17150 status = palSendMBMessage(pMac->hHdd, pMsg);
17151 if (!HAL_STATUS_SUCCESS(status))
17152 {
17153 smsLog(pMac, LOGE, FL(" csr STOP OBSS SCAN Fail %d "), status);
17154 //pMsg is freed by palSendMBMessage
17155 }
17156 }
17157 else
17158 {
17159 smsLog(pMac, LOGE, FL(" OBSS STOP OBSS SCAN is not supported"));
17160 status = eHAL_STATUS_FAILURE;
17161 }
17162 return status;
17163}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017164/* Returns whether a session is in VOS_STA_MODE...or not */
17165tANI_BOOLEAN csrRoamIsStaMode(tpAniSirGlobal pMac, tANI_U32 sessionId)
17166{
17167 tCsrRoamSession *pSession = NULL;
17168 pSession = CSR_GET_SESSION ( pMac, sessionId );
17169 if(!pSession)
17170 {
17171 smsLog(pMac, LOGE, FL(" %s: session %d not found "), __func__, sessionId);
17172 return eANI_BOOLEAN_FALSE;
17173 }
17174 if ( !CSR_IS_SESSION_VALID ( pMac, sessionId ) )
17175 {
17176 smsLog(pMac, LOGE, FL(" %s: Inactive session"), __func__);
17177 return eANI_BOOLEAN_FALSE;
17178 }
17179 if ( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
17180 {
17181 return eANI_BOOLEAN_FALSE;
17182 }
17183 /* There is a possibility that the above check may fail,because
17184 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
17185 * when it is connected.So,we may sneak through the above check even
17186 * if we are not a STA mode INFRA station. So, if we sneak through
17187 * the above condition, we can use the following check if we are
17188 * really in STA Mode.*/
17189
17190 if ( NULL != pSession->pCurRoamProfile )
17191 {
17192 if ( pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE )
17193 {
17194 return eANI_BOOLEAN_TRUE;
17195 } else {
17196 smsLog(pMac, LOGE, FL(" %s: pCurRoamProfile is NULL\n"), __func__);
17197 return eANI_BOOLEAN_FALSE;
17198 }
17199 }
17200
17201 return eANI_BOOLEAN_FALSE;
17202}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017203
17204#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
17205eHalStatus csrHandoffRequest(tpAniSirGlobal pMac,
17206 tCsrHandoffRequest *pHandoffInfo)
17207{
17208 eHalStatus status = eHAL_STATUS_SUCCESS;
17209 vos_msg_t msg;
17210
17211 tAniHandoffReq *pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053017212 pMsg = vos_mem_malloc(sizeof(tAniHandoffReq));
17213 if ( NULL == pMsg )
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017214 {
17215 smsLog(pMac, LOGE, " csrHandoffRequest: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053017216 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017217 }
17218 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_HANDOFF_REQ);
17219 pMsg->msgLen = (tANI_U16)sizeof(tAniHandoffReq);
17220 pMsg->sessionId = pMac->roam.neighborRoamInfo.csrSessionId;
17221 pMsg->channel = pHandoffInfo->channel;
Kiet Lam64c1b492013-07-12 13:56:44 +053017222 vos_mem_copy(pMsg->bssid,
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017223 pHandoffInfo->bssid,
17224 6);
17225 msg.type = eWNI_SME_HANDOFF_REQ;
17226 msg.bodyptr = pMsg;
17227 msg.reserved = 0;
17228 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
17229 {
17230 smsLog(pMac, LOGE, " csrHandoffRequest failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053017231 vos_mem_free((void *)pMsg);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017232 status = eHAL_STATUS_FAILURE;
17233 }
17234 return status;
17235}
17236#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017237
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017238#if defined WLAN_FEATURE_RELIABLE_MCAST
17239eHalStatus csrEnableRMC(tpAniSirGlobal pMac, tANI_U32 sessionId)
17240{
17241 tSirSetRMCReq *pMsg = NULL;
17242 eHalStatus status = eHAL_STATUS_SUCCESS;
17243 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17244
17245 if (!pSession)
17246 {
17247 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17248 return eHAL_STATUS_FAILURE;
17249 }
17250
17251 pMsg = vos_mem_malloc(sizeof(tSirSetRMCReq));
17252 if (NULL != pMsg)
17253 {
17254 vos_mem_set((void *)pMsg, sizeof(tSirSetRMCReq), 0);
17255 pMsg->msgType = eWNI_SME_ENABLE_RMC_REQ;
17256 pMsg->msgLen = sizeof(tSirSetRMCReq);
17257 vos_mem_copy((v_U8_t *)pMsg->mcastTransmitter,
17258 &pSession->selfMacAddr, sizeof(tSirMacAddr));
17259
17260 status = palSendMBMessage(pMac->hHdd, pMsg);
17261 if (!HAL_STATUS_SUCCESS(status))
17262 {
17263 smsLog(pMac, LOGE, FL(" csr enable RMC Post MSG Fail %d "), status);
17264 //pMsg is freed by palSendMBMessage
17265 }
17266 }
17267 else
17268 {
17269 return eHAL_STATUS_FAILURE;
17270 }
17271 return status;
17272}
17273
17274eHalStatus csrDisableRMC(tpAniSirGlobal pMac, tANI_U32 sessionId)
17275{
17276 tSirSetRMCReq *pMsg = NULL;
17277 eHalStatus status = eHAL_STATUS_SUCCESS;
17278 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17279
17280 if (!pSession)
17281 {
17282 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17283 return eHAL_STATUS_FAILURE;
17284 }
17285
17286 pMsg = vos_mem_malloc(sizeof(tSirSetRMCReq));
17287 if (NULL != pMsg)
17288 {
17289 vos_mem_set((void *)pMsg, sizeof(tSirSetRMCReq), 0);
17290 pMsg->msgType = eWNI_SME_DISABLE_RMC_REQ;
17291 pMsg->msgLen = sizeof(tSirSetRMCReq);
17292 vos_mem_copy((v_U8_t *)pMsg->mcastTransmitter,
17293 &pSession->selfMacAddr, sizeof(tSirMacAddr));
17294
17295 status = palSendMBMessage(pMac->hHdd, pMsg);
17296 if (!HAL_STATUS_SUCCESS(status))
17297 {
17298 smsLog(pMac, LOGE, FL(" csr disable RMC Post MSG Fail %d "), status);
17299 //pMsg is freed by palSendMBMessage
17300 }
17301 }
17302 else
17303 {
17304 return eHAL_STATUS_FAILURE;
17305 }
17306 return status;
17307}
17308
17309#endif /* defined WLAN_FEATURE_RELIABLE_MCAST */
17310
17311
17312#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017313/* ---------------------------------------------------------------------------
17314 \fn csrSetCCKMIe
17315 \brief This function stores the CCKM IE passed by the supplicant in a place holder
17316 data structure and this IE will be packed inside reassociation request
17317 \param pMac - pMac global structure
17318 \param sessionId - Current session id
17319 \param pCckmIe - pointer to CCKM IE data
17320 \param ccKmIeLen - length of the CCKM IE
17321 \- return Success or failure
17322 -------------------------------------------------------------------------*/
17323VOS_STATUS csrSetCCKMIe(tpAniSirGlobal pMac, const tANI_U8 sessionId,
17324 const tANI_U8 *pCckmIe,
17325 const tANI_U8 ccKmIeLen)
17326{
17327 eHalStatus status = eHAL_STATUS_SUCCESS;
17328 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17329
17330 if (!pSession)
17331 {
17332 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17333 return eHAL_STATUS_FAILURE;
17334 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053017335 vos_mem_copy(pSession->suppCckmIeInfo.cckmIe, pCckmIe, ccKmIeLen);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017336 pSession->suppCckmIeInfo.cckmIeLen = ccKmIeLen;
17337 return status;
17338}
17339
17340/* ---------------------------------------------------------------------------
17341 \fn csrRoamReadTSF
17342 \brief This function reads the TSF; and also add the time elapsed since last beacon or
17343 probe response reception from the hand off AP to arrive at the latest TSF value.
17344 \param pMac - pMac global structure
17345 \param pTimestamp - output TSF timestamp
17346 \- return Success or failure
17347 -------------------------------------------------------------------------*/
17348VOS_STATUS csrRoamReadTSF(tpAniSirGlobal pMac, tANI_U8 *pTimestamp)
17349{
17350 eHalStatus status = eHAL_STATUS_SUCCESS;
17351 tCsrNeighborRoamBSSInfo handoffNode;
17352 tANI_U32 timer_diff = 0;
17353 tANI_U32 timeStamp[2];
17354 tpSirBssDescription pBssDescription = NULL;
17355
17356 csrNeighborRoamGetHandoffAPInfo(pMac, &handoffNode);
17357 pBssDescription = handoffNode.pBssDescription;
17358
17359 // Get the time diff in milli seconds
17360 timer_diff = vos_timer_get_system_time() - pBssDescription->scanSysTimeMsec;
17361 // Convert msec to micro sec timer
17362 timer_diff = (tANI_U32)(timer_diff * SYSTEM_TIME_MSEC_TO_USEC);
17363
17364 timeStamp[0] = pBssDescription->timeStamp[0];
17365 timeStamp[1] = pBssDescription->timeStamp[1];
17366
17367 UpdateCCKMTSF(&(timeStamp[0]), &(timeStamp[1]), &timer_diff);
17368
Kiet Lamf2f201e2013-11-16 21:24:16 +053017369 vos_mem_copy(pTimestamp, (void *) &timeStamp[0],
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017370 sizeof (tANI_U32) * 2);
17371 return status;
17372}
17373
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017374#endif /*FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017375