blob: 0d561984a5e84fcca130fd8c253ed036d6853f52 [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
c_hpothu059edb02014-03-12 21:44:28 +05301595 if (pParam->nInitialDwellTime)
1596 {
1597 pMac->roam.configParam.nInitialDwellTime =
1598 pParam->nInitialDwellTime;
1599 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001600 if (pParam->nActiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001601 {
1602 pMac->roam.configParam.nActiveMaxChnTime = pParam->nActiveMaxChnTime;
1603 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001604 if (pParam->nActiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001605 {
1606 pMac->roam.configParam.nActiveMinChnTime = pParam->nActiveMinChnTime;
1607 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001608 if (pParam->nPassiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001609 {
1610 pMac->roam.configParam.nPassiveMaxChnTime = pParam->nPassiveMaxChnTime;
1611 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001612 if (pParam->nPassiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001613 {
1614 pMac->roam.configParam.nPassiveMinChnTime = pParam->nPassiveMinChnTime;
1615 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001616 if (pParam->nActiveMaxChnTimeBtc)
1617 {
1618 pMac->roam.configParam.nActiveMaxChnTimeBtc = pParam->nActiveMaxChnTimeBtc;
1619 }
1620 if (pParam->nActiveMinChnTimeBtc)
1621 {
1622 pMac->roam.configParam.nActiveMinChnTimeBtc = pParam->nActiveMinChnTimeBtc;
1623 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001624#ifdef WLAN_AP_STA_CONCURRENCY
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001625 if (pParam->nActiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001626 {
1627 pMac->roam.configParam.nActiveMaxChnTimeConc = pParam->nActiveMaxChnTimeConc;
1628 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001629 if (pParam->nActiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001630 {
1631 pMac->roam.configParam.nActiveMinChnTimeConc = pParam->nActiveMinChnTimeConc;
1632 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001633 if (pParam->nPassiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001634 {
1635 pMac->roam.configParam.nPassiveMaxChnTimeConc = pParam->nPassiveMaxChnTimeConc;
1636 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001637 if (pParam->nPassiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001638 {
1639 pMac->roam.configParam.nPassiveMinChnTimeConc = pParam->nPassiveMinChnTimeConc;
1640 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001641 if (pParam->nRestTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001642 {
1643 pMac->roam.configParam.nRestTimeConc = pParam->nRestTimeConc;
1644 }
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001645 if (pParam->nNumStaChanCombinedConc)
Vinay Malekal05fdc812012-12-17 13:04:30 -08001646 {
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001647 pMac->roam.configParam.nNumStaChanCombinedConc = pParam->nNumStaChanCombinedConc;
1648 }
1649 if (pParam->nNumP2PChanCombinedConc)
1650 {
1651 pMac->roam.configParam.nNumP2PChanCombinedConc = pParam->nNumP2PChanCombinedConc;
Vinay Malekal05fdc812012-12-17 13:04:30 -08001652 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001653#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001654 //if upper layer wants to disable idle scan altogether set it to 0
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001655 if (pParam->impsSleepTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001656 {
1657 //Change the unit from second to microsecond
1658 tANI_U32 impsSleepTime = pParam->impsSleepTime * PAL_TIMER_TO_SEC_UNIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07001659 if(CSR_IDLE_SCAN_NO_PS_INTERVAL_MIN <= impsSleepTime)
1660 {
1661 pMac->roam.configParam.impsSleepTime = impsSleepTime;
1662 }
1663 else
1664 {
1665 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1666 }
1667 }
1668 else
1669 {
1670 pMac->roam.configParam.impsSleepTime = 0;
1671 }
1672 pMac->roam.configParam.eBand = pParam->eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001673 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(NULL, pMac->roam.configParam.phyMode,
1674 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07001675 //if HDD passed down non zero values for age params, then only update,
1676 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001677 if (pParam->nScanResultAgeCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07001678 {
1679 pMac->roam.configParam.agingCount = pParam->nScanResultAgeCount;
1680 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001681 if(pParam->scanAgeTimeNCNPS)
1682 {
1683 pMac->roam.configParam.scanAgeTimeNCNPS = pParam->scanAgeTimeNCNPS;
1684 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001685 if(pParam->scanAgeTimeNCPS)
1686 {
1687 pMac->roam.configParam.scanAgeTimeNCPS = pParam->scanAgeTimeNCPS;
1688 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001689 if(pParam->scanAgeTimeCNPS)
1690 {
1691 pMac->roam.configParam.scanAgeTimeCNPS = pParam->scanAgeTimeCNPS;
1692 }
1693 if(pParam->scanAgeTimeCPS)
1694 {
1695 pMac->roam.configParam.scanAgeTimeCPS = pParam->scanAgeTimeCPS;
1696 }
c_hpothu0d5a7352014-03-22 12:30:25 +05301697 if (pParam->initialScanSkipDFSCh)
1698 {
1699 pMac->roam.configParam.initialScanSkipDFSCh =
1700 pParam->initialScanSkipDFSCh;
1701 }
1702
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001703 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, pParam->bCatRssiOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07001704 pMac->roam.configParam.nRoamingTime = pParam->nRoamingTime;
1705 pMac->roam.configParam.fEnforce11dChannels = pParam->fEnforce11dChannels;
1706 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = pParam->fSupplicantCountryCodeHasPriority;
1707 pMac->roam.configParam.fEnforceCountryCodeMatch = pParam->fEnforceCountryCodeMatch;
1708 pMac->roam.configParam.fEnforceDefaultDomain = pParam->fEnforceDefaultDomain;
Jeff Johnson295189b2012-06-20 16:38:30 -07001709 pMac->roam.configParam.vccRssiThreshold = pParam->vccRssiThreshold;
1710 pMac->roam.configParam.vccUlMacLossThreshold = pParam->vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001711 pMac->roam.configParam.IsIdleScanEnabled = pParam->IsIdleScanEnabled;
1712 pMac->roam.configParam.statsReqPeriodicity = pParam->statsReqPeriodicity;
1713 pMac->roam.configParam.statsReqPeriodicityInPS = pParam->statsReqPeriodicityInPS;
1714 //Assign this before calling CsrInit11dInfo
1715 pMac->roam.configParam.nTxPowerCap = pParam->nTxPowerCap;
Jeff Johnson295189b2012-06-20 16:38:30 -07001716 if( csrIs11dSupported( pMac ) )
1717 {
1718 status = CsrInit11dInfo(pMac, &pParam->Csr11dinfo);
1719 }
1720 else
1721 {
1722 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
1723 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001724
1725 /* Initialize the power + channel information if 11h is enabled.
1726 If 11d is enabled this information has already been initialized */
1727 if( csrIs11hSupported( pMac ) && !csrIs11dSupported( pMac ) )
1728 {
1729 csrInitChannelPowerList(pMac, &pParam->Csr11dinfo);
1730 }
1731
1732
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05301733#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05301734 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
1735 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001736 smsLog( pMac, LOG1, "IsFTResourceReqSupp = %d", pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07001737#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001738#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001739 pMac->roam.configParam.isFastTransitionEnabled = pParam->isFastTransitionEnabled;
Jeff Johnson43971f52012-07-17 12:26:56 -07001740 pMac->roam.configParam.RoamRssiDiff = pParam->RoamRssiDiff;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001741 pMac->roam.configParam.nImmediateRoamRssiDiff = pParam->nImmediateRoamRssiDiff;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001742 smsLog( pMac, LOG1, "nImmediateRoamRssiDiff = %d",
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001743 pMac->roam.configParam.nImmediateRoamRssiDiff );
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08001744 pMac->roam.configParam.nRoamPrefer5GHz = pParam->nRoamPrefer5GHz;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07001745 pMac->roam.configParam.nRoamIntraBand = pParam->nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07001746 pMac->roam.configParam.isWESModeEnabled = pParam->isWESModeEnabled;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001747 pMac->roam.configParam.nProbes = pParam->nProbes;
1748 pMac->roam.configParam.nRoamScanHomeAwayTime = pParam->nRoamScanHomeAwayTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001749#endif
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001750#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1751 pMac->roam.configParam.isRoamOffloadScanEnabled = pParam->isRoamOffloadScanEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001752 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled = pParam->bFastRoamInConIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001753#endif
1754#ifdef FEATURE_WLAN_LFR
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001755 pMac->roam.configParam.isFastRoamIniFeatureEnabled = pParam->isFastRoamIniFeatureEnabled;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -08001756 pMac->roam.configParam.MAWCEnabled = pParam->MAWCEnabled;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001757#endif
1758
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001759#ifdef FEATURE_WLAN_ESE
1760 pMac->roam.configParam.isEseIniFeatureEnabled = pParam->isEseIniFeatureEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001761#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001762#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301763 vos_mem_copy(&pMac->roam.configParam.neighborRoamConfig,
1764 &pParam->neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001765 smsLog( pMac, LOG1, "nNeighborScanTimerPerioid = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod);
1766 smsLog( pMac, LOG1, "nNeighborReassocRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold);
1767 smsLog( pMac, LOG1, "nNeighborLookupRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold);
1768 smsLog( pMac, LOG1, "nNeighborScanMinChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime);
1769 smsLog( pMac, LOG1, "nNeighborScanMaxChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime);
1770 smsLog( pMac, LOG1, "nMaxNeighborRetries = %d", pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries);
1771 smsLog( pMac, LOG1, "nNeighborResultsRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod);
1772 smsLog( pMac, LOG1, "nEmptyScanRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07001773 {
1774 int i;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001775 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 -07001776 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1777 {
1778 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1779 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001780 }
1781#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001782 pMac->roam.configParam.addTSWhenACMIsOff = pParam->addTSWhenACMIsOff;
1783 pMac->scan.fValidateList = pParam->fValidateList;
1784 pMac->scan.fEnableBypass11d = pParam->fEnableBypass11d;
1785 pMac->scan.fEnableDFSChnlScan = pParam->fEnableDFSChnlScan;
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08001786 pMac->scan.scanResultCfgAgingTime = pParam->scanCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001787 pMac->roam.configParam.fScanTwice = pParam->fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001788 pMac->scan.fFirstScanOnly2GChnl = pParam->fFirstScanOnly2GChnl;
1789 /* This parameter is not available in cfg and not passed from upper layers. Instead it is initialized here
1790 * This paramtere is used in concurrency to determine if there are concurrent active sessions.
1791 * Is used as a temporary fix to disconnect all active sessions when BMPS enabled so the active session if Infra STA
1792 * will automatically connect back and resume BMPS since resume BMPS is not working when moving from concurrent to
1793 * single session
1794 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001795 //Remove this code once SLM_Sessionization is supported
1796 //BMPS_WORKAROUND_NOT_NEEDED
Mohit Khanna349bc392012-09-11 17:24:52 -07001797 pMac->roam.configParam.doBMPSWorkaround = 0;
1798
Jeff Johnsone7245742012-09-05 17:12:55 -07001799#ifdef WLAN_FEATURE_11AC
1800 pMac->roam.configParam.nVhtChannelWidth = pParam->nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001801 pMac->roam.configParam.txBFEnable= pParam->enableTxBF;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001802 pMac->roam.configParam.txBFCsnValue = pParam->txBFCsnValue;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07001803 pMac->roam.configParam.enableVhtFor24GHz = pParam->enableVhtFor24GHz;
Jeff Johnsone7245742012-09-05 17:12:55 -07001804#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08001805 pMac->roam.configParam.txLdpcEnable = pParam->enableTxLdpc;
krunal soni5afa96c2013-09-06 22:19:02 -07001806
1807 pMac->roam.configParam.isAmsduSupportInAMPDU = pParam->isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001808 pMac->roam.configParam.nSelect5GHzMargin = pParam->nSelect5GHzMargin;
krunal sonie9002db2013-11-25 14:24:17 -08001809 pMac->roam.configParam.isCoalesingInIBSSAllowed =
1810 pParam->isCoalesingInIBSSAllowed;
Sandeep Puligillac80f26e2014-03-11 18:36:10 +05301811 pMac->roam.configParam.allowDFSChannelRoam = pParam->allowDFSChannelRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -07001812 }
1813
1814 return status;
1815}
1816
Jeff Johnson295189b2012-06-20 16:38:30 -07001817eHalStatus csrGetConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1818{
1819 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07001820 if(pParam)
1821 {
1822 pParam->WMMSupportMode = pMac->roam.configParam.WMMSupportMode;
1823 pParam->Is11eSupportEnabled = pMac->roam.configParam.Is11eSupportEnabled;
1824 pParam->FragmentationThreshold = pMac->roam.configParam.FragmentationThreshold;
1825 pParam->Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabled;
1826 pParam->Is11dSupportEnabledOriginal = pMac->roam.configParam.Is11dSupportEnabledOriginal;
1827 pParam->Is11hSupportEnabled = pMac->roam.configParam.Is11hSupportEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07001828 pParam->channelBondingMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode24GHz);
1829 pParam->channelBondingMode5GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001830 pParam->RTSThreshold = pMac->roam.configParam.RTSThreshold;
1831 pParam->phyMode = pMac->roam.configParam.phyMode;
1832 pParam->shortSlotTime = pMac->roam.configParam.shortSlotTime;
1833 pParam->HeartbeatThresh24 = pMac->roam.configParam.HeartbeatThresh24;
1834 pParam->HeartbeatThresh50 = pMac->roam.configParam.HeartbeatThresh50;
1835 pParam->ProprietaryRatesEnabled = pMac->roam.configParam.ProprietaryRatesEnabled;
1836 pParam->TxRate = pMac->roam.configParam.TxRate;
1837 pParam->AdHocChannel24 = pMac->roam.configParam.AdHocChannel24;
1838 pParam->AdHocChannel5G = pMac->roam.configParam.AdHocChannel5G;
1839 pParam->bandCapability = pMac->roam.configParam.bandCapability;
1840 pParam->cbChoice = pMac->roam.configParam.cbChoice;
1841 pParam->bgScanInterval = pMac->roam.configParam.bgScanInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07001842 pParam->nActiveMaxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
1843 pParam->nActiveMinChnTime = pMac->roam.configParam.nActiveMinChnTime;
1844 pParam->nPassiveMaxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
1845 pParam->nPassiveMinChnTime = pMac->roam.configParam.nPassiveMinChnTime;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001846 pParam->nActiveMaxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
1847 pParam->nActiveMinChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
1848 pParam->disableAggWithBtc = pMac->roam.configParam.disableAggWithBtc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001849#ifdef WLAN_AP_STA_CONCURRENCY
1850 pParam->nActiveMaxChnTimeConc = pMac->roam.configParam.nActiveMaxChnTimeConc;
1851 pParam->nActiveMinChnTimeConc = pMac->roam.configParam.nActiveMinChnTimeConc;
1852 pParam->nPassiveMaxChnTimeConc = pMac->roam.configParam.nPassiveMaxChnTimeConc;
1853 pParam->nPassiveMinChnTimeConc = pMac->roam.configParam.nPassiveMinChnTimeConc;
1854 pParam->nRestTimeConc = pMac->roam.configParam.nRestTimeConc;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001855 pParam->nNumStaChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc;
1856 pParam->nNumP2PChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001857#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001858 //Change the unit from microsecond to second
1859 pParam->impsSleepTime = pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_SEC_UNIT;
1860 pParam->eBand = pMac->roam.configParam.eBand;
1861 pParam->nScanResultAgeCount = pMac->roam.configParam.agingCount;
1862 pParam->scanAgeTimeNCNPS = pMac->roam.configParam.scanAgeTimeNCNPS;
1863 pParam->scanAgeTimeNCPS = pMac->roam.configParam.scanAgeTimeNCPS;
1864 pParam->scanAgeTimeCNPS = pMac->roam.configParam.scanAgeTimeCNPS;
1865 pParam->scanAgeTimeCPS = pMac->roam.configParam.scanAgeTimeCPS;
1866 pParam->bCatRssiOffset = pMac->roam.configParam.bCatRssiOffset;
1867 pParam->nRoamingTime = pMac->roam.configParam.nRoamingTime;
1868 pParam->fEnforce11dChannels = pMac->roam.configParam.fEnforce11dChannels;
1869 pParam->fSupplicantCountryCodeHasPriority = pMac->roam.configParam.fSupplicantCountryCodeHasPriority;
1870 pParam->fEnforceCountryCodeMatch = pMac->roam.configParam.fEnforceCountryCodeMatch;
1871 pParam->fEnforceDefaultDomain = pMac->roam.configParam.fEnforceDefaultDomain;
1872 pParam->vccRssiThreshold = pMac->roam.configParam.vccRssiThreshold;
1873 pParam->vccUlMacLossThreshold = pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001874 pParam->IsIdleScanEnabled = pMac->roam.configParam.IsIdleScanEnabled;
1875 pParam->nTxPowerCap = pMac->roam.configParam.nTxPowerCap;
1876 pParam->statsReqPeriodicity = pMac->roam.configParam.statsReqPeriodicity;
1877 pParam->statsReqPeriodicityInPS = pMac->roam.configParam.statsReqPeriodicityInPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001878 pParam->addTSWhenACMIsOff = pMac->roam.configParam.addTSWhenACMIsOff;
1879 pParam->fValidateList = pMac->roam.configParam.fValidateList;
1880 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
1881 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
1882 pParam->fScanTwice = pMac->roam.configParam.fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001883 pParam->fFirstScanOnly2GChnl = pMac->scan.fFirstScanOnly2GChnl;
Madan Mohan Koyyalamudied419512012-11-29 15:53:46 -08001884 pParam->fEnableMCCMode = pMac->roam.configParam.fenableMCCMode;
Madan Mohan Koyyalamudi057bd802012-11-29 16:02:39 -08001885 pParam->fAllowMCCGODiffBI = pMac->roam.configParam.fAllowMCCGODiffBI;
Sunil Ravi39b2e532013-01-20 23:45:53 -08001886 pParam->scanCfgAgingTime = pMac->scan.scanResultCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001887
1888#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301889 vos_mem_copy(&pParam->neighborRoamConfig,
1890 &pMac->roam.configParam.neighborRoamConfig,
1891 sizeof(tCsrNeighborRoamConfigParams));
Jeff Johnson295189b2012-06-20 16:38:30 -07001892#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001893#ifdef WLAN_FEATURE_11AC
1894 pParam->nVhtChannelWidth = pMac->roam.configParam.nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001895 pParam->enableTxBF = pMac->roam.configParam.txBFEnable;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001896 pParam->txBFCsnValue = pMac->roam.configParam.txBFCsnValue;
Ravi Joshiacc81822013-10-10 15:30:41 -07001897 pParam->enableVhtFor24GHz = pMac->roam.configParam.enableVhtFor24GHz;
Jeff Johnsone7245742012-09-05 17:12:55 -07001898#endif
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001899#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05301900 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
1901 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001902#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001903#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001904 pParam->isFastTransitionEnabled = pMac->roam.configParam.isFastTransitionEnabled;
1905 pParam->RoamRssiDiff = pMac->roam.configParam.RoamRssiDiff;
1906 pParam->nImmediateRoamRssiDiff = pMac->roam.configParam.nImmediateRoamRssiDiff;
1907 pParam->nRoamPrefer5GHz = pMac->roam.configParam.nRoamPrefer5GHz;
1908 pParam->nRoamIntraBand = pMac->roam.configParam.nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07001909 pParam->isWESModeEnabled = pMac->roam.configParam.isWESModeEnabled;
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -07001910 pParam->nProbes = pMac->roam.configParam.nProbes;
1911 pParam->nRoamScanHomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001912#endif
1913#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1914 pParam->isRoamOffloadScanEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
1915 pParam->bFastRoamInConIniFeatureEnabled = pMac->roam.configParam.bFastRoamInConIniFeatureEnabled;
1916#endif
1917#ifdef FEATURE_WLAN_LFR
1918 pParam->isFastRoamIniFeatureEnabled = pMac->roam.configParam.isFastRoamIniFeatureEnabled;
1919#endif
1920
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001921#ifdef FEATURE_WLAN_ESE
1922 pParam->isEseIniFeatureEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001923#endif
1924#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301925 vos_mem_copy(&pParam->neighborRoamConfig,
1926 &pMac->roam.configParam.neighborRoamConfig,
1927 sizeof(tCsrNeighborRoamConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001928 {
1929 int i;
1930 smsLog( pMac, LOG1, FL("Num of Channels in CFG Channel List: %d"), pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
1931 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1932 {
1933 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1934 }
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001935 }
1936#endif
1937
Venkata Prathyusha Kuntupallif2695c12013-04-17 15:41:23 -07001938 pParam->enableTxLdpc = pMac->roam.configParam.txLdpcEnable;
krunal soni4f087d22013-07-29 16:32:26 -07001939
krunal soni5afa96c2013-09-06 22:19:02 -07001940 pParam->isAmsduSupportInAMPDU = pMac->roam.configParam.isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001941 pParam->nSelect5GHzMargin = pMac->roam.configParam.nSelect5GHzMargin;
krunal soni5afa96c2013-09-06 22:19:02 -07001942
krunal sonie9002db2013-11-25 14:24:17 -08001943 pParam->isCoalesingInIBSSAllowed =
1944 pMac->roam.configParam.isCoalesingInIBSSAllowed;
Sandeep Puligillac80f26e2014-03-11 18:36:10 +05301945 pParam->allowDFSChannelRoam =
1946 pMac->roam.configParam.allowDFSChannelRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -07001947 csrSetChannels(pMac, pParam);
1948
1949 status = eHAL_STATUS_SUCCESS;
1950 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001951 return (status);
1952}
1953
Jeff Johnson295189b2012-06-20 16:38:30 -07001954eHalStatus csrSetPhyMode(tHalHandle hHal, tANI_U32 phyMode, eCsrBand eBand, tANI_BOOLEAN *pfRestartNeeded)
1955{
1956 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
1957 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1958 tANI_BOOLEAN fRestartNeeded = eANI_BOOLEAN_FALSE;
1959 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001960 do
1961 {
1962 if(eCSR_BAND_24 == eBand)
1963 {
1964 if(CSR_IS_RADIO_A_ONLY(pMac)) break;
1965 if((eCSR_DOT11_MODE_11a & phyMode) || (eCSR_DOT11_MODE_11a_ONLY & phyMode)) break;
1966 }
1967 if(eCSR_BAND_5G == eBand)
1968 {
1969 if(CSR_IS_RADIO_BG_ONLY(pMac)) break;
1970 if((eCSR_DOT11_MODE_11b & phyMode) || (eCSR_DOT11_MODE_11b_ONLY & phyMode) ||
1971 (eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11g_ONLY & phyMode)
1972 )
1973 {
1974 break;
1975 }
1976 }
1977 if((0 == phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
1978 {
1979 newPhyMode = eCSR_DOT11_MODE_TAURUS;
1980 }
1981 else if(eCSR_DOT11_MODE_AUTO & phyMode)
1982 {
1983 newPhyMode = eCSR_DOT11_MODE_AUTO;
1984 }
1985 else
1986 {
1987 //Check for dual band and higher capability first
1988 if(eCSR_DOT11_MODE_11n_ONLY & phyMode)
1989 {
1990 if(eCSR_DOT11_MODE_11n_ONLY != phyMode) break;
1991 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
1992 }
1993 else if(eCSR_DOT11_MODE_11a_ONLY & phyMode)
1994 {
1995 if(eCSR_DOT11_MODE_11a_ONLY != phyMode) break;
1996 if(eCSR_BAND_24 == eBand) break;
1997 newPhyMode = eCSR_DOT11_MODE_11a_ONLY;
1998 eBand = eCSR_BAND_5G;
1999 }
2000 else if(eCSR_DOT11_MODE_11g_ONLY & phyMode)
2001 {
2002 if(eCSR_DOT11_MODE_11g_ONLY != phyMode) break;
2003 if(eCSR_BAND_5G == eBand) break;
2004 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
2005 eBand = eCSR_BAND_24;
2006 }
2007 else if(eCSR_DOT11_MODE_11b_ONLY & phyMode)
2008 {
2009 if(eCSR_DOT11_MODE_11b_ONLY != phyMode) break;
2010 if(eCSR_BAND_5G == eBand) break;
2011 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
2012 eBand = eCSR_BAND_24;
2013 }
2014 else if(eCSR_DOT11_MODE_11n & phyMode)
2015 {
2016 newPhyMode = eCSR_DOT11_MODE_11n;
2017 }
2018 else if(eCSR_DOT11_MODE_abg & phyMode)
2019 {
2020 newPhyMode = eCSR_DOT11_MODE_abg;
2021 }
2022 else if(eCSR_DOT11_MODE_11a & phyMode)
2023 {
2024 if((eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11b & phyMode))
2025 {
2026 if(eCSR_BAND_ALL == eBand)
2027 {
2028 newPhyMode = eCSR_DOT11_MODE_abg;
2029 }
2030 else
2031 {
2032 //bad setting
2033 break;
2034 }
2035 }
2036 else
2037 {
2038 newPhyMode = eCSR_DOT11_MODE_11a;
2039 eBand = eCSR_BAND_5G;
2040 }
2041 }
2042 else if(eCSR_DOT11_MODE_11g & phyMode)
2043 {
2044 newPhyMode = eCSR_DOT11_MODE_11g;
2045 eBand = eCSR_BAND_24;
2046 }
2047 else if(eCSR_DOT11_MODE_11b & phyMode)
2048 {
2049 newPhyMode = eCSR_DOT11_MODE_11b;
2050 eBand = eCSR_BAND_24;
2051 }
2052 else
2053 {
2054 //We will never be here
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002055 smsLog( pMac, LOGE, FL(" cannot recognize the phy mode 0x%08X"), phyMode );
Jeff Johnson295189b2012-06-20 16:38:30 -07002056 newPhyMode = eCSR_DOT11_MODE_AUTO;
2057 }
2058 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002059 //Done validating
2060 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002061 //Now we need to check whether a restart is needed.
2062 if(eBand != pMac->roam.configParam.eBand)
2063 {
2064 fRestartNeeded = eANI_BOOLEAN_TRUE;
2065 break;
2066 }
2067 if(newPhyMode != pMac->roam.configParam.phyMode)
2068 {
2069 fRestartNeeded = eANI_BOOLEAN_TRUE;
2070 break;
2071 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002072 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002073 if(HAL_STATUS_SUCCESS(status))
2074 {
2075 pMac->roam.configParam.eBand = eBand;
2076 pMac->roam.configParam.phyMode = newPhyMode;
2077 if(pfRestartNeeded)
2078 {
2079 *pfRestartNeeded = fRestartNeeded;
2080 }
2081 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002082 return (status);
2083}
2084
Jeff Johnson295189b2012-06-20 16:38:30 -07002085void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList )
2086{
2087 tANI_U8 Index;
2088 tANI_U8 cChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07002089 // for dual band NICs, don't need to trim the channel list....
2090 if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) )
2091 {
2092 // 2.4 GHz band operation requires the channel list to be trimmed to
2093 // the 2.4 GHz channels only...
2094 if ( CSR_IS_24_BAND_ONLY( pMac ) )
2095 {
2096 for( Index = 0, cChannels = 0; Index < pChannelList->numChannels;
2097 Index++ )
2098 {
2099 if ( CSR_IS_CHANNEL_24GHZ(pChannelList->channelList[ Index ]) )
2100 {
2101 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2102 cChannels++;
2103 }
2104 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002105 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2106 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2107 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2108 // only if we need to.
2109 //
2110 // The amount of memory to clear is the number of channesl that we trimmed
2111 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2112
2113 if ( pChannelList->numChannels > cChannels )
2114 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302115 vos_mem_set(&pChannelList->channelList[ cChannels ],
2116 sizeof( pChannelList->channelList[ 0 ] ) *
2117 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002118 }
2119
2120 pChannelList->numChannels = cChannels;
2121 }
2122 else if ( CSR_IS_5G_BAND_ONLY( pMac ) )
2123 {
2124 for ( Index = 0, cChannels = 0; Index < pChannelList->numChannels; Index++ )
2125 {
2126 if ( CSR_IS_CHANNEL_5GHZ(pChannelList->channelList[ Index ]) )
2127 {
2128 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2129 cChannels++;
2130 }
2131 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002132 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2133 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2134 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2135 // only if we need to.
2136 //
2137 // The amount of memory to clear is the number of channesl that we trimmed
2138 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2139 if ( pChannelList->numChannels > cChannels )
2140 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302141 vos_mem_set(&pChannelList->channelList[ cChannels ],
2142 sizeof( pChannelList->channelList[ 0 ] ) *
2143 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002144 }
2145
2146 pChannelList->numChannels = cChannels;
2147 }
2148 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002149}
Jeff Johnson295189b2012-06-20 16:38:30 -07002150#define INFRA_AP_DEFAULT_CHANNEL 6
2151eHalStatus csrIsValidChannel(tpAniSirGlobal pMac, tANI_U8 chnNum)
2152{
2153 tANI_U8 index= 0;
2154 eHalStatus status = eHAL_STATUS_FAILURE;
2155 for (index=0; index < pMac->scan.base20MHzChannels.numChannels ;index++)
2156 {
2157 if(pMac->scan.base20MHzChannels.channelList[ index ] == chnNum){
2158 status = eHAL_STATUS_SUCCESS;
2159 break;
2160 }
2161 }
2162 return status;
2163}
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002164
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002165
Jeff Johnson295189b2012-06-20 16:38:30 -07002166eHalStatus csrInitGetChannels(tpAniSirGlobal pMac)
2167{
2168 eHalStatus status = eHAL_STATUS_SUCCESS;
2169 tANI_U8 num20MHzChannelsFound = 0;
2170 VOS_STATUS vosStatus;
2171 tANI_U8 Index = 0;
2172 tANI_U8 num40MHzChannelsFound = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002173
Jeff Johnson295189b2012-06-20 16:38:30 -07002174
2175 //TODO: this interface changed to include the 40MHz channel list
2176 // this needs to be tied into the adapter structure somehow and referenced appropriately for CB operation
2177 // Read the scan channel list (including the power limit) from EEPROM
2178 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
2179 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
2180 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
2181 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002182 smsLog( pMac, LOGE, FL("failed to get channels "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002183 status = eHAL_STATUS_FAILURE;
2184 }
2185 else
2186 {
2187 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
2188 {
2189 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2190 }
2191 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
2192 // Move the channel list to the global data
2193 // structure -- this will be used as the scan list
2194 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
2195 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002196 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[ Index ].chanId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002197 }
2198 pMac->scan.base20MHzChannels.numChannels = num20MHzChannelsFound;
2199 if(num40MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN)
2200 {
2201 num40MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2202 }
2203 for ( Index = 0; Index < num40MHzChannelsFound; Index++)
2204 {
2205 pMac->scan.base40MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable40MHz[ Index ].chanId;
2206 }
2207 pMac->scan.base40MHzChannels.numChannels = num40MHzChannelsFound;
2208 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002209 return (status);
2210}
2211
Jeff Johnson295189b2012-06-20 16:38:30 -07002212eHalStatus csrInitChannelList( tHalHandle hHal )
2213{
2214 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2215 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002216 csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels);
2217 csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels);
Kiran4a17ebe2013-01-31 10:43:43 -08002218 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE);
2219 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002220 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002221 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnson295189b2012-06-20 16:38:30 -07002222
2223 return (status);
2224}
Jeff Johnson295189b2012-06-20 16:38:30 -07002225eHalStatus csrChangeConfigParams(tpAniSirGlobal pMac,
2226 tCsrUpdateConfigParam *pUpdateConfigParam)
2227{
2228 eHalStatus status = eHAL_STATUS_FAILURE;
2229 tCsr11dinfo *ps11dinfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002230 ps11dinfo = &pUpdateConfigParam->Csr11dinfo;
2231 status = CsrInit11dInfo(pMac, ps11dinfo);
2232 return status;
2233}
2234
Jeff Johnson295189b2012-06-20 16:38:30 -07002235static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2236{
2237 eHalStatus status = eHAL_STATUS_FAILURE;
2238 tANI_U8 index;
2239 tANI_U32 count=0;
2240 tSirMacChanInfo *pChanInfo;
2241 tSirMacChanInfo *pChanInfoStart;
2242 tANI_BOOLEAN applyConfig = TRUE;
2243
Mihir Shetebc866f62014-02-13 16:08:53 +05302244 pMac->scan.currentCountryRSSI = -128;
2245
Jeff Johnson295189b2012-06-20 16:38:30 -07002246 if(!ps11dinfo)
2247 {
2248 return (status);
2249 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002250 if ( ps11dinfo->Channels.numChannels && ( WNI_CFG_VALID_CHANNEL_LIST_LEN >= ps11dinfo->Channels.numChannels ) )
2251 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302252 pMac->scan.base20MHzChannels.numChannels = ps11dinfo->Channels.numChannels;
2253 vos_mem_copy(pMac->scan.base20MHzChannels.channelList,
2254 ps11dinfo->Channels.channelList,
2255 ps11dinfo->Channels.numChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07002256 }
2257 else
2258 {
2259 //No change
2260 return (eHAL_STATUS_SUCCESS);
2261 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002262 //legacy maintenance
Kiet Lam64c1b492013-07-12 13:56:44 +05302263
2264 vos_mem_copy(pMac->scan.countryCodeDefault, ps11dinfo->countryCode,
2265 WNI_CFG_COUNTRY_CODE_LEN);
2266
2267
Jeff Johnson295189b2012-06-20 16:38:30 -07002268 //Tush: at csropen get this initialized with default, during csr reset if this
2269 // already set with some value no need initilaize with default again
2270 if(0 == pMac->scan.countryCodeCurrent[0])
2271 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302272 vos_mem_copy(pMac->scan.countryCodeCurrent, ps11dinfo->countryCode,
2273 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002274 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002275 // need to add the max power channel list
Kiet Lam64c1b492013-07-12 13:56:44 +05302276 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2277 if (pChanInfo != NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002278 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302279 vos_mem_set(pChanInfo,
2280 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN ,
2281 0);
2282
Jeff Johnson295189b2012-06-20 16:38:30 -07002283 pChanInfoStart = pChanInfo;
Jeff Johnsone7245742012-09-05 17:12:55 -07002284 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2285 {
2286 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2287 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2288 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2289 pChanInfo++;
2290 count++;
2291 }
2292 if(count)
2293 {
2294 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2295 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302296 vos_mem_free(pChanInfoStart);
Jeff Johnsone7245742012-09-05 17:12:55 -07002297 }
2298 //Only apply them to CFG when not in STOP state. Otherwise they will be applied later
2299 if( HAL_STATUS_SUCCESS(status) )
2300 {
2301 for( index = 0; index < CSR_ROAM_SESSION_MAX; index++ )
2302 {
2303 if((CSR_IS_SESSION_VALID(pMac, index)) && CSR_IS_ROAM_STOP(pMac, index))
2304 {
2305 applyConfig = FALSE;
2306 }
2307 }
2308
2309 if(TRUE == applyConfig)
2310 {
2311 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002312 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnsone7245742012-09-05 17:12:55 -07002313 }
2314
2315 }
2316 return (status);
2317}
2318/* Initialize the Channel + Power List in the local cache and in the CFG */
2319eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2320{
2321 tANI_U8 index;
2322 tANI_U32 count=0;
2323 tSirMacChanInfo *pChanInfo;
2324 tSirMacChanInfo *pChanInfoStart;
2325
2326 if(!ps11dinfo || !pMac)
2327 {
2328 return eHAL_STATUS_FAILURE;
2329 }
2330
Kiet Lam64c1b492013-07-12 13:56:44 +05302331 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2332 if (pChanInfo != NULL)
Jeff Johnsone7245742012-09-05 17:12:55 -07002333 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302334 vos_mem_set(pChanInfo,
2335 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN,
2336 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07002337 pChanInfoStart = pChanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002338
2339 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2340 {
2341 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2342 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2343 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2344 pChanInfo++;
2345 count++;
2346 }
2347 if(count)
2348 {
2349 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2350 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302351 vos_mem_free(pChanInfoStart);
Jeff Johnson295189b2012-06-20 16:38:30 -07002352 }
2353
Jeff Johnsone7245742012-09-05 17:12:55 -07002354 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002355}
2356
2357//pCommand may be NULL
2358//Pass in sessionId in case pCommand is NULL. sessionId is not used in case pCommand is not NULL.
2359void csrRoamRemoveDuplicateCommand(tpAniSirGlobal pMac, tANI_U32 sessionId, tSmeCmd *pCommand, eCsrRoamReason eRoamReason)
2360{
2361 tListElem *pEntry, *pNextEntry;
2362 tSmeCmd *pDupCommand;
2363 tDblLinkList localList;
2364
2365 vos_mem_zero(&localList, sizeof(tDblLinkList));
2366 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
2367 {
2368 smsLog(pMac, LOGE, FL(" failed to open list"));
2369 return;
2370 }
2371 csrLLLock( &pMac->sme.smeCmdPendingList );
2372 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK );
2373 while( pEntry )
2374 {
2375 pNextEntry = csrLLNext( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
2376 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07002377 // Remove the previous command if..
2378 // - the new roam command is for the same RoamReason...
2379 // - the new roam command is a NewProfileList.
2380 // - the new roam command is a Forced Dissoc
2381 // - the new roam command is from an 802.11 OID (OID_SSID or OID_BSSID).
2382 if (
2383 (pCommand && ( pCommand->sessionId == pDupCommand->sessionId ) &&
2384 ((pCommand->command == pDupCommand->command) &&
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08002385 /* This peermac check is requried for Softap/GO scenarios
2386 * For STA scenario below OR check will suffice as pCommand will
2387 * always be NULL for STA scenarios
2388 */
2389 (vos_mem_compare(pDupCommand->u.roamCmd.peerMac, pCommand->u.roamCmd.peerMac, sizeof(v_MACADDR_t))) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002390 (pCommand->u.roamCmd.roamReason == pDupCommand->u.roamCmd.roamReason ||
2391 eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason ||
2392 eCsrHddIssued == pCommand->u.roamCmd.roamReason)))
2393 ||
2394 //below the pCommand is NULL
Jeff Johnson43971f52012-07-17 12:26:56 -07002395 ( (sessionId == pDupCommand->sessionId) &&
2396 (eSmeCommandRoam == pDupCommand->command) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002397 ((eCsrForcedDisassoc == eRoamReason) ||
2398 (eCsrHddIssued == eRoamReason))
2399 )
2400 )
2401 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002402 smsLog(pMac, LOGW, FL(" roamReason = %d"), pDupCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07002403 // Remove the 'stale' roam command from the pending list...
2404 if(csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK ))
2405 {
2406 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
2407 }
2408 }
2409 pEntry = pNextEntry;
2410 }
2411 csrLLUnlock( &pMac->sme.smeCmdPendingList );
2412
2413 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
2414 {
2415 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
2416 //Tell caller that the command is cancelled
2417 csrRoamCallCallback(pMac, pDupCommand->sessionId, NULL, pDupCommand->u.roamCmd.roamId,
2418 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
2419 csrReleaseCommandRoam(pMac, pDupCommand);
2420 }
2421 csrLLClose(&localList);
2422}
Jeff Johnson295189b2012-06-20 16:38:30 -07002423eHalStatus csrRoamCallCallback(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo,
2424 tANI_U32 roamId, eRoamCmdStatus u1, eCsrRoamResult u2)
2425{
2426 eHalStatus status = eHAL_STATUS_SUCCESS;
2427#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2428 WLAN_VOS_DIAG_EVENT_DEF(connectionStatus, vos_event_wlan_status_payload_type);
2429#endif
2430 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07002431 if( CSR_IS_SESSION_VALID( pMac, sessionId) )
2432 {
2433 pSession = CSR_GET_SESSION( pMac, sessionId );
2434 }
2435 else
2436 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002437 smsLog(pMac, LOGE, "Session ID:%d is not valid", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002438 VOS_ASSERT(0);
2439 return eHAL_STATUS_FAILURE;
2440 }
krunal soni587bf012014-02-04 12:35:11 -08002441
2442 if (eANI_BOOLEAN_FALSE == pSession->sessionActive)
2443 {
2444 smsLog(pMac, LOG1, "%s Session is not Active", __func__);
2445 return eHAL_STATUS_FAILURE;
2446 }
krunal soni7f7d2c92014-02-06 15:08:43 -08002447
krunal soni587bf012014-02-04 12:35:11 -08002448 smsLog(pMac, LOG4, "Recieved RoamCmdStatus %d with Roam Result %d", u1, u2);
2449
krunal soni7f7d2c92014-02-06 15:08:43 -08002450 if(eCSR_ROAM_ASSOCIATION_COMPLETION == u1 && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002451 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002452 smsLog(pMac, LOGW, " Assoc complete result = %d statusCode = %d reasonCode = %d", u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002453 }
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07002454 if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED) && (pSession->bRefAssocStartCnt)) {
2455 /*
2456 * Decrement bRefAssocStartCnt for FT reassoc failure.
2457 * Reason: For FT reassoc failures, we first call
2458 * csrRoamCallCallback before notifying a failed roam
2459 * completion through csrRoamComplete. The latter in
2460 * turn calls csrRoamProcessResults which tries to
2461 * once again call csrRoamCallCallback if bRefAssocStartCnt
2462 * is non-zero. Since this is redundant for FT reassoc
2463 * failure, decrement bRefAssocStartCnt.
2464 */
2465 pSession->bRefAssocStartCnt--;
2466 }
2467
Jeff Johnson295189b2012-06-20 16:38:30 -07002468 if(NULL != pSession->callback)
2469 {
2470 if( pRoamInfo )
2471 {
2472 pRoamInfo->sessionId = (tANI_U8)sessionId;
2473 }
2474
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302475 /* avoid holding the global lock when making the roaming callback, original change came
2476 from a raised CR (CR304874). Since this callback is in HDD a potential deadlock
2477 is possible on other OS ports where the callback may need to take locks to protect
2478 HDD state
Jeff Johnson295189b2012-06-20 16:38:30 -07002479 UPDATE : revert this change but keep the comments here. Need to revisit as there are callbacks
2480 that may actually depend on the lock being held */
2481 // TODO: revisit: sme_ReleaseGlobalLock( &pMac->sme );
2482 status = pSession->callback(pSession->pContext, pRoamInfo, roamId, u1, u2);
2483 // TODO: revisit: sme_AcquireGlobalLock( &pMac->sme );
2484 }
2485 //EVENT_WLAN_STATUS: eCSR_ROAM_ASSOCIATION_COMPLETION,
2486 // eCSR_ROAM_LOSTLINK, eCSR_ROAM_DISASSOCIATED,
2487#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiet Lam64c1b492013-07-12 13:56:44 +05302488 vos_mem_set(&connectionStatus,
2489 sizeof(vos_event_wlan_status_payload_type), 0);
2490
krunal soni7f7d2c92014-02-06 15:08:43 -08002491 if((eCSR_ROAM_ASSOCIATION_COMPLETION == u1) && (eCSR_ROAM_RESULT_ASSOCIATED == u2) && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002492 {
2493 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
2494 connectionStatus.bssType = pRoamInfo->u.pConnectedProfile->BSSType;
2495 if(NULL != pRoamInfo->pBssDesc)
2496 {
2497 connectionStatus.rssi = pRoamInfo->pBssDesc->rssi * (-1);
2498 connectionStatus.channel = pRoamInfo->pBssDesc->channelId;
2499 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002500 connectionStatus.qosCapability = pRoamInfo->u.pConnectedProfile->qosConnection;
2501 connectionStatus.authType = (v_U8_t)diagAuthTypeFromCSRType(pRoamInfo->u.pConnectedProfile->AuthType);
2502 connectionStatus.encryptionType = (v_U8_t)diagEncTypeFromCSRType(pRoamInfo->u.pConnectedProfile->EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05302503 vos_mem_copy(connectionStatus.ssid,
2504 pRoamInfo->u.pConnectedProfile->SSID.ssId, 6);
2505
Jeff Johnson295189b2012-06-20 16:38:30 -07002506 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
2507 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2508 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002509 if((eCSR_ROAM_MIC_ERROR_IND == u1) || (eCSR_ROAM_RESULT_MIC_FAILURE == u2))
2510 {
2511 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2512 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
2513 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2514 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002515 if(eCSR_ROAM_RESULT_FORCED == u2)
2516 {
2517 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2518 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
2519 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2520 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002521 if(eCSR_ROAM_RESULT_DISASSOC_IND == u2)
2522 {
2523 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2524 connectionStatus.reason = eCSR_REASON_DISASSOC;
2525 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2526 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002527 if(eCSR_ROAM_RESULT_DEAUTH_IND == u2)
2528 {
2529 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2530 connectionStatus.reason = eCSR_REASON_DEAUTH;
2531 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2532 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002533#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
2534
2535 return (status);
2536}
Jeff Johnson295189b2012-06-20 16:38:30 -07002537// Returns whether handoff is currently in progress or not
2538tANI_BOOLEAN csrRoamIsHandoffInProgress(tpAniSirGlobal pMac)
2539{
2540#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2541 return csrNeighborRoamIsHandoffInProgress(pMac);
2542#else
2543 return eANI_BOOLEAN_FALSE;
2544#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002545}
Jeff Johnson295189b2012-06-20 16:38:30 -07002546eHalStatus csrRoamIssueDisassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
2547 eCsrRoamSubState NewSubstate, tANI_BOOLEAN fMICFailure )
2548{
2549 eHalStatus status = eHAL_STATUS_SUCCESS;
2550 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2551 tANI_U16 reasonCode;
2552 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002553
2554 if(!pSession)
2555 {
2556 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2557 return eHAL_STATUS_FAILURE;
2558 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002559
2560 //Restore AC weight in case we change it
2561 if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
2562 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07002563 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 -07002564 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
2565 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
2566 }
2567
2568 if ( fMICFailure )
2569 {
2570 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
2571 }
2572 else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)
2573 {
2574 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002575 }
2576 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002577 {
2578 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
2579 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002580#ifdef WLAN_FEATURE_VOWIFI_11R
2581 if ( (csrRoamIsHandoffInProgress(pMac)) &&
2582 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF))
2583 {
2584 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05302585 vos_mem_copy(&bssId,
2586 pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid,
2587 sizeof(tSirMacAddr));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002588 }
2589 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002590#endif
2591 if(pSession->pConnectBssDesc)
2592 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302593 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002594 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002595
Jeff Johnson295189b2012-06-20 16:38:30 -07002596
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05302597 smsLog(pMac, LOG2, FL("CSR Attempting to Disassociate Bssid="MAC_ADDRESS_STR
2598 " subState = %s reason=%d"),
2599 MAC_ADDR_ARRAY(bssId), macTraceGetcsrRoamSubState(NewSubstate),
2600 reasonCode);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08002601
Jeff Johnson295189b2012-06-20 16:38:30 -07002602 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2603
2604 status = csrSendMBDisassocReqMsg( pMac, sessionId, bssId, reasonCode );
2605
2606 if(HAL_STATUS_SUCCESS(status))
2607 {
2608 csrRoamLinkDown(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002609#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2610 //no need to tell QoS that we are disassociating, it will be taken care off in assoc req for HO
2611 if(eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate)
2612 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002613 //notify QoS module that disassoc happening
Jeff Johnson295189b2012-06-20 16:38:30 -07002614 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
2615 }
2616#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002617 }
2618 else
2619 {
2620 smsLog(pMac, LOGW, FL("csrSendMBDisassocReqMsg failed with status %d"), status);
2621 }
2622
Jeff Johnson295189b2012-06-20 16:38:30 -07002623 return (status);
2624}
Jeff Johnson295189b2012-06-20 16:38:30 -07002625
Jeff Johnson295189b2012-06-20 16:38:30 -07002626/* ---------------------------------------------------------------------------
2627 \fn csrRoamIssueDisassociateStaCmd
2628 \brief csr function that HDD calls to disassociate a associated station
2629 \param sessionId - session Id for Soft AP
2630 \param pPeerMacAddr - MAC of associated station to delete
2631 \param reason - reason code, be one of the tSirMacReasonCodes
2632 \return eHalStatus
2633 ---------------------------------------------------------------------------*/
2634eHalStatus csrRoamIssueDisassociateStaCmd( tpAniSirGlobal pMac,
2635 tANI_U32 sessionId,
2636 tANI_U8 *pPeerMacAddr,
2637 tANI_U32 reason)
2638{
2639 eHalStatus status = eHAL_STATUS_SUCCESS;
2640 tSmeCmd *pCommand;
2641
2642 do
2643 {
2644 pCommand = csrGetCommandBuffer( pMac );
2645 if ( !pCommand )
2646 {
2647 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2648 status = eHAL_STATUS_RESOURCES;
2649 break;
2650 }
2651 pCommand->command = eSmeCommandRoam;
2652 pCommand->sessionId = (tANI_U8)sessionId;
2653 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
2654 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2655 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2656 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2657 if( !HAL_STATUS_SUCCESS( status ) )
2658 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002659 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002660 csrReleaseCommandRoam( pMac, pCommand );
2661 }
2662 }while(0);
2663
2664 return status;
2665}
2666
2667
Jeff Johnson295189b2012-06-20 16:38:30 -07002668/* ---------------------------------------------------------------------------
2669 \fn csrRoamIssueDeauthSta
2670 \brief csr function that HDD calls to delete a associated station
2671 \param sessionId - session Id for Soft AP
2672 \param pPeerMacAddr - MAC of associated station to delete
2673 \param reason - reason code, be one of the tSirMacReasonCodes
2674 \return eHalStatus
2675 ---------------------------------------------------------------------------*/
2676eHalStatus csrRoamIssueDeauthStaCmd( tpAniSirGlobal pMac,
2677 tANI_U32 sessionId,
2678 tANI_U8 *pPeerMacAddr,
2679 tANI_U32 reason)
2680{
2681 eHalStatus status = eHAL_STATUS_SUCCESS;
2682 tSmeCmd *pCommand;
2683
2684 do
2685 {
2686 pCommand = csrGetCommandBuffer( pMac );
2687 if ( !pCommand )
2688 {
2689 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2690 status = eHAL_STATUS_RESOURCES;
2691 break;
2692 }
2693 pCommand->command = eSmeCommandRoam;
2694 pCommand->sessionId = (tANI_U8)sessionId;
2695 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
2696 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2697 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2698 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2699 if( !HAL_STATUS_SUCCESS( status ) )
2700 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002701 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002702 csrReleaseCommandRoam( pMac, pCommand );
2703 }
2704 }while(0);
2705
2706 return status;
2707}
Jeff Johnson295189b2012-06-20 16:38:30 -07002708eHalStatus
2709csrRoamIssueTkipCounterMeasures( tpAniSirGlobal pMac, tANI_U32 sessionId,
2710 tANI_BOOLEAN bEnable )
2711{
2712 eHalStatus status = eHAL_STATUS_FAILURE;
2713 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2714 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002715 if (!pSession)
2716 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002717 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002718 return (status);
2719 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002720 if (pSession->pConnectBssDesc)
2721 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302722 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002723 }
2724 else
2725 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002726 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002727 return (status);
2728 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002729 smsLog( pMac, LOG2, "CSR issuing tkip counter measures for Bssid = "MAC_ADDRESS_STR", Enable = %d",
2730 MAC_ADDR_ARRAY(bssId), bEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002731 status = csrSendMBTkipCounterMeasuresReqMsg( pMac, sessionId, bEnable, bssId );
2732 return (status);
2733}
Jeff Johnson295189b2012-06-20 16:38:30 -07002734eHalStatus
2735csrRoamGetAssociatedStas( tpAniSirGlobal pMac, tANI_U32 sessionId,
2736 VOS_MODULE_ID modId, void *pUsrContext,
2737 void *pfnSapEventCallback, v_U8_t *pAssocStasBuf )
2738{
2739 eHalStatus status = eHAL_STATUS_SUCCESS;
2740 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2741 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002742 if (!pSession)
2743 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002744 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002745 return (status);
2746 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002747 if(pSession->pConnectBssDesc)
2748 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302749 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002750 }
2751 else
2752 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002753 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002754 return (status);
2755 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002756 smsLog( pMac, LOG2, "CSR getting associated stations for Bssid = "MAC_ADDRESS_STR,
2757 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002758 status = csrSendMBGetAssociatedStasReqMsg( pMac, sessionId, modId, bssId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
2759 return (status);
2760}
Jeff Johnson295189b2012-06-20 16:38:30 -07002761eHalStatus
2762csrRoamGetWpsSessionOverlap( tpAniSirGlobal pMac, tANI_U32 sessionId,
2763 void *pUsrContext, void *pfnSapEventCallback, v_MACADDR_t pRemoveMac )
2764{
2765 eHalStatus status = eHAL_STATUS_SUCCESS;
2766 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2767 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2768
2769 if (!pSession)
2770 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002771 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002772 return (status);
2773 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002774 if(pSession->pConnectBssDesc)
2775 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302776 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002777 }
2778 else
2779 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002780 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002781 return (status);
2782 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002783 smsLog( pMac, LOG2, "CSR getting WPS Session Overlap for Bssid = "MAC_ADDRESS_STR,
2784 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002785
2786 status = csrSendMBGetWPSPBCSessions( pMac, sessionId, bssId, pUsrContext, pfnSapEventCallback, pRemoveMac);
2787
2788 return (status);
2789}
Jeff Johnson295189b2012-06-20 16:38:30 -07002790eHalStatus csrRoamIssueDeauth( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
2791{
2792 eHalStatus status = eHAL_STATUS_SUCCESS;
2793 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2794 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002795
2796 if (!pSession)
2797 {
2798 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2799 return eHAL_STATUS_FAILURE;
2800 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002801
2802 if(pSession->pConnectBssDesc)
2803 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302804 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002805 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002806 smsLog( pMac, LOG2, "CSR Attempting to Deauth Bssid= "MAC_ADDRESS_STR,
2807 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002808 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2809
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05302810 status = csrSendMBDeauthReqMsg( pMac, sessionId, bssId, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002811 if(!HAL_STATUS_SUCCESS(status))
2812 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05302813 smsLog(pMac, LOGE, FL("csrSendMBDeauthReqMsg failed with status %d Session ID: %d"
2814 MAC_ADDRESS_STR ), status, sessionId, MAC_ADDR_ARRAY(bssId));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002815 }
2816
Jeff Johnson295189b2012-06-20 16:38:30 -07002817 return (status);
2818}
2819
Jeff Johnson295189b2012-06-20 16:38:30 -07002820eHalStatus csrRoamSaveConnectedBssDesc( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDesc )
2821{
2822 eHalStatus status = eHAL_STATUS_SUCCESS;
2823 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2824 tANI_U32 size;
Jeff Johnson32d95a32012-09-10 13:15:23 -07002825
2826 if(!pSession)
2827 {
2828 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2829 return eHAL_STATUS_FAILURE;
2830 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002831
2832 // If no BSS description was found in this connection (happens with start IBSS), then
2833 // nix the BSS description that we keep around for the connected BSS) and get out...
2834 if(NULL == pBssDesc)
2835 {
2836 csrFreeConnectBssDesc(pMac, sessionId);
2837 }
2838 else
2839 {
2840 size = pBssDesc->length + sizeof( pBssDesc->length );
2841 if(NULL != pSession->pConnectBssDesc)
2842 {
2843 if(((pSession->pConnectBssDesc->length) + sizeof(pSession->pConnectBssDesc->length)) < size)
2844 {
2845 //not enough room for the new BSS, pMac->roam.pConnectBssDesc is freed inside
2846 csrFreeConnectBssDesc(pMac, sessionId);
2847 }
2848 }
2849 if(NULL == pSession->pConnectBssDesc)
2850 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302851 pSession->pConnectBssDesc = vos_mem_malloc(size);
Jeff Johnson295189b2012-06-20 16:38:30 -07002852 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302853 if (NULL == pSession->pConnectBssDesc)
2854 status = eHAL_STATUS_FAILURE;
2855 else
2856 vos_mem_copy(pSession->pConnectBssDesc, pBssDesc, size);
2857 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002858 return (status);
2859}
2860
Jeff Johnson295189b2012-06-20 16:38:30 -07002861eHalStatus csrRoamPrepareBssConfig(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2862 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
2863 tDot11fBeaconIEs *pIes)
2864{
2865 eHalStatus status = eHAL_STATUS_SUCCESS;
2866 eCsrCfgDot11Mode cfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002867 VOS_ASSERT( pIes != NULL );
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +05302868 if (pIes == NULL)
2869 return eHAL_STATUS_FAILURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002870
Jeff Johnson295189b2012-06-20 16:38:30 -07002871 do
2872 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302873 vos_mem_copy(&pBssConfig->BssCap, &pBssDesc->capabilityInfo,
2874 sizeof(tSirMacCapabilityInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07002875 //get qos
2876 pBssConfig->qosType = csrGetQoSFromBssDesc(pMac, pBssDesc, pIes);
2877 //get SSID
2878 if(pIes->SSID.present)
2879 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302880 vos_mem_copy(&pBssConfig->SSID.ssId, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07002881 pBssConfig->SSID.length = pIes->SSID.num_ssid;
2882 }
2883 else
2884 pBssConfig->SSID.length = 0;
2885 if(csrIsNULLSSID(pBssConfig->SSID.ssId, pBssConfig->SSID.length))
2886 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002887 smsLog(pMac, LOGW, " BSS desc SSID is a wildcard");
Jeff Johnson295189b2012-06-20 16:38:30 -07002888 //Return failed if profile doesn't have an SSID either.
2889 if(pProfile->SSIDs.numOfSSIDs == 0)
2890 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002891 smsLog(pMac, LOGW, " Both BSS desc and profile doesn't have SSID");
Jeff Johnson295189b2012-06-20 16:38:30 -07002892 status = eHAL_STATUS_FAILURE;
2893 break;
2894 }
2895 }
2896 if(CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
2897 {
2898 pBssConfig->eBand = eCSR_BAND_5G;
2899 }
2900 else
2901 {
2902 pBssConfig->eBand = eCSR_BAND_24;
2903 }
2904 //phymode
2905 if(csrIsPhyModeMatch( pMac, pProfile->phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes ))
2906 {
2907 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
2908 }
2909 else
2910 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002911 smsLog(pMac, LOGW, " Can not find match phy mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07002912 //force it
2913 if(eCSR_BAND_24 == pBssConfig->eBand)
2914 {
2915 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2916 }
2917 else
2918 {
2919 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2920 }
2921 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002922 //Qos
2923 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
2924 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos))
2925 {
2926 //Joining BSS is not 11n capable and WMM is disabled on client.
2927 //Disable QoS and WMM
2928 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2929 }
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302930
2931 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
Pratik Bhalgat8d461642012-11-22 16:55:42 +05302932 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC)) &&
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302933 ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP) ||
2934 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF) ||
2935 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF) ))
2936 {
2937 //Joining BSS is 11n capable and WMM is disabled on AP.
2938 //Assume all HT AP's are QOS AP's and enable WMM
2939 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2940 }
2941
Jeff Johnson295189b2012-06-20 16:38:30 -07002942 //auth type
2943 switch( pProfile->negotiatedAuthType )
2944 {
2945 default:
2946 case eCSR_AUTH_TYPE_WPA:
2947 case eCSR_AUTH_TYPE_WPA_PSK:
2948 case eCSR_AUTH_TYPE_WPA_NONE:
2949 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2950 pBssConfig->authType = eSIR_OPEN_SYSTEM;
2951 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002952 case eCSR_AUTH_TYPE_SHARED_KEY:
2953 pBssConfig->authType = eSIR_SHARED_KEY;
2954 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002955 case eCSR_AUTH_TYPE_AUTOSWITCH:
2956 pBssConfig->authType = eSIR_AUTO_SWITCH;
2957 break;
2958 }
2959 //short slot time
2960 if( eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode )
2961 {
2962 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
2963 }
2964 else
2965 {
2966 pBssConfig->uShortSlotTime = 0;
2967 }
2968 if(pBssConfig->BssCap.ibss)
2969 {
2970 //We don't support 11h on IBSS
2971 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
2972 }
2973 else
2974 {
2975 pBssConfig->f11hSupport = pMac->roam.configParam.Is11hSupportEnabled;
2976 }
2977 //power constraint
2978 pBssConfig->uPowerLimit = csrGet11hPowerConstraint(pMac, &pIes->PowerConstraints);
2979 //heartbeat
2980 if ( CSR_IS_11A_BSS( pBssDesc ) )
2981 {
2982 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
2983 }
2984 else
2985 {
2986 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
2987 }
2988 //Join timeout
2989 // if we find a BeaconInterval in the BssDescription, then set the Join Timeout to
Jeff Johnsone7245742012-09-05 17:12:55 -07002990 // be 10 x the BeaconInterval.
Jeff Johnson295189b2012-06-20 16:38:30 -07002991 if ( pBssDesc->beaconInterval )
2992 {
2993 //Make sure it is bigger than the minimal
Jeff Johnsone7245742012-09-05 17:12:55 -07002994 pBssConfig->uJoinTimeOut = CSR_ROAM_MAX(10 * pBssDesc->beaconInterval, CSR_JOIN_FAILURE_TIMEOUT_MIN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002995 }
2996 else
2997 {
2998 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
2999 }
3000 //validate CB
3001 pBssConfig->cbMode = csrGetCBModeFromIes(pMac, pBssDesc->channelId, pIes);
Sandeep Puligilla60342762014-01-30 21:05:37 +05303002
Jeff Johnson295189b2012-06-20 16:38:30 -07003003 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003004 return (status);
3005}
3006
Jeff Johnson295189b2012-06-20 16:38:30 -07003007static eHalStatus csrRoamPrepareBssConfigFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
3008 tBssConfigParam *pBssConfig, tSirBssDescription *pBssDesc)
3009{
3010 eHalStatus status = eHAL_STATUS_SUCCESS;
3011 tANI_U8 operationChannel = 0;
3012 tANI_U8 qAPisEnabled = FALSE;
3013 //SSID
3014 pBssConfig->SSID.length = 0;
3015 if(pProfile->SSIDs.numOfSSIDs)
3016 {
3017 //only use the first one
Kiet Lam64c1b492013-07-12 13:56:44 +05303018 vos_mem_copy(&pBssConfig->SSID, &pProfile->SSIDs.SSIDList[0].SSID,
3019 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003020 }
3021 else
3022 {
3023 //SSID must present
3024 return eHAL_STATUS_FAILURE;
3025 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003026 //Settomg up the capabilities
3027 if( csrIsBssTypeIBSS(pProfile->BSSType) )
3028 {
3029 pBssConfig->BssCap.ibss = 1;
3030 }
3031 else
3032 {
3033 pBssConfig->BssCap.ess = 1;
3034 }
3035 if( eCSR_ENCRYPT_TYPE_NONE != pProfile->EncryptionType.encryptionType[0] )
3036 {
3037 pBssConfig->BssCap.privacy = 1;
3038 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003039 pBssConfig->eBand = pMac->roam.configParam.eBand;
3040 //phymode
3041 if(pProfile->ChannelInfo.ChannelList)
3042 {
3043 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3044 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003045 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, operationChannel,
3046 &pBssConfig->eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07003047 //QOS
3048 //Is this correct to always set to this //***
Jeff Johnson295189b2012-06-20 16:38:30 -07003049 if ( pBssConfig->BssCap.ess == 1 )
3050 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003051 /*For Softap case enable WMM*/
3052 if(CSR_IS_INFRA_AP(pProfile) && (eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode )){
3053 qAPisEnabled = TRUE;
3054 }
3055 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003056 if (csrRoamGetQosInfoFromBss(pMac, pBssDesc) == eHAL_STATUS_SUCCESS) {
3057 qAPisEnabled = TRUE;
3058 } else {
3059 qAPisEnabled = FALSE;
3060 }
3061 } else {
3062 qAPisEnabled = TRUE;
3063 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003064 if (( eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode && qAPisEnabled) ||
3065 (( eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode && qAPisEnabled) ||
3066 ( eCSR_CFG_DOT11_MODE_TAURUS == pBssConfig->uCfgDot11Mode ) ) //For 11n, need QoS
3067 )
3068 {
3069 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3070 } else {
3071 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3072 }
3073
3074 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08003075 switch( pProfile->AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07003076 {
3077 default:
3078 case eCSR_AUTH_TYPE_WPA:
3079 case eCSR_AUTH_TYPE_WPA_PSK:
3080 case eCSR_AUTH_TYPE_WPA_NONE:
3081 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3082 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3083 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003084 case eCSR_AUTH_TYPE_SHARED_KEY:
3085 pBssConfig->authType = eSIR_SHARED_KEY;
3086 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003087 case eCSR_AUTH_TYPE_AUTOSWITCH:
3088 pBssConfig->authType = eSIR_AUTO_SWITCH;
3089 break;
3090 }
3091 //short slot time
3092 if( WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode )
3093 {
3094 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3095 }
3096 else
3097 {
3098 pBssConfig->uShortSlotTime = 0;
3099 }
3100 //power constraint. We don't support 11h on IBSS
3101 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3102 pBssConfig->uPowerLimit = 0;
3103 //heartbeat
3104 if ( eCSR_BAND_5G == pBssConfig->eBand )
3105 {
3106 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3107 }
3108 else
3109 {
3110 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3111 }
3112 //Join timeout
3113 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07003114
Jeff Johnson295189b2012-06-20 16:38:30 -07003115 return (status);
3116}
Jeff Johnson295189b2012-06-20 16:38:30 -07003117static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc)
3118{
3119 eHalStatus status = eHAL_STATUS_FAILURE;
3120 tDot11fBeaconIEs *pIes = NULL;
3121
3122 do
3123 {
3124 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
3125 {
3126 //err msg
3127 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003128 "csrRoamGetQosInfoFromBss() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07003129 break;
3130 }
3131 //check if the AP is QAP & it supports APSD
3132 if( CSR_IS_QOS_BSS(pIes) )
3133 {
Kiet Lamb537cfb2013-11-07 12:56:49 +05303134 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07003135 }
3136 } while (0);
Kiet Lamb537cfb2013-11-07 12:56:49 +05303137
3138 if (NULL != pIes)
3139 {
3140 vos_mem_free(pIes);
3141 }
3142
Jeff Johnson295189b2012-06-20 16:38:30 -07003143 return status;
3144}
3145
Jeff Johnson295189b2012-06-20 16:38:30 -07003146void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
3147{
Jeff Johnson295189b2012-06-20 16:38:30 -07003148 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
3149 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
3150 // See !!Note: below in this function...
3151 tANI_U32 PrivacyEnabled = 0;
3152 tANI_U32 RsnEnabled = 0;
3153 tANI_U32 WepDefaultKeyId = 0;
3154 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
3155 tANI_U32 Key0Length = 0;
3156 tANI_U32 Key1Length = 0;
3157 tANI_U32 Key2Length = 0;
3158 tANI_U32 Key3Length = 0;
3159
3160 // Reserve for the biggest key
3161 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
3162 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
3163 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
3164 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
3165
3166 switch ( pProfile->negotiatedUCEncryptionType )
3167 {
3168 case eCSR_ENCRYPT_TYPE_NONE:
3169
3170 // for NO encryption, turn off Privacy and Rsn.
3171 PrivacyEnabled = 0;
3172 RsnEnabled = 0;
3173
3174 // WEP key length and Wep Default Key ID don't matter in this case....
3175
3176 // clear out the WEP keys that may be hanging around.
3177 Key0Length = 0;
3178 Key1Length = 0;
3179 Key2Length = 0;
3180 Key3Length = 0;
3181
3182 break;
3183
3184 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303185 case eCSR_ENCRYPT_TYPE_WEP40:
Jeff Johnson295189b2012-06-20 16:38:30 -07003186
3187 // Privacy is ON. NO RSN for Wep40 static key.
3188 PrivacyEnabled = 1;
3189 RsnEnabled = 0;
3190
3191 // Set the Wep default key ID.
3192 WepDefaultKeyId = pProfile->Keys.defaultIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07003193 // Wep key size if 5 bytes (40 bits).
3194 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
3195
3196 // set encryption keys in the CFG database or clear those that are not present in this profile.
3197 if ( pProfile->Keys.KeyLength[0] )
3198 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303199 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[0],
3200 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003201 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
3202 }
3203 else
3204 {
3205 Key0Length = 0;
3206 }
3207
3208 if ( pProfile->Keys.KeyLength[1] )
3209 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303210 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[1],
3211 WNI_CFG_WEP_KEY_LENGTH_5);
3212 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
Jeff Johnson295189b2012-06-20 16:38:30 -07003213 }
3214 else
3215 {
3216 Key1Length = 0;
3217 }
3218
3219 if ( pProfile->Keys.KeyLength[2] )
3220 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303221 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[2],
3222 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003223 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
3224 }
3225 else
3226 {
3227 Key2Length = 0;
3228 }
3229
3230 if ( pProfile->Keys.KeyLength[3] )
3231 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303232 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[3],
3233 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003234 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
3235 }
3236 else
3237 {
3238 Key3Length = 0;
3239 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003240 break;
3241
3242 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303243 case eCSR_ENCRYPT_TYPE_WEP104:
Jeff Johnson295189b2012-06-20 16:38:30 -07003244
3245 // Privacy is ON. NO RSN for Wep40 static key.
3246 PrivacyEnabled = 1;
3247 RsnEnabled = 0;
3248
3249 // Set the Wep default key ID.
3250 WepDefaultKeyId = pProfile->Keys.defaultIndex;
3251
3252 // Wep key size if 13 bytes (104 bits).
3253 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
3254
3255 // set encryption keys in the CFG database or clear those that are not present in this profile.
3256 if ( pProfile->Keys.KeyLength[0] )
3257 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303258 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[ 0 ],
3259 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003260 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
3261 }
3262 else
3263 {
3264 Key0Length = 0;
3265 }
3266
3267 if ( pProfile->Keys.KeyLength[1] )
3268 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303269 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[ 1 ],
3270 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003271 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
3272 }
3273 else
3274 {
3275 Key1Length = 0;
3276 }
3277
3278 if ( pProfile->Keys.KeyLength[2] )
3279 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303280 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[ 2 ],
3281 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003282 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
3283 }
3284 else
3285 {
3286 Key2Length = 0;
3287 }
3288
3289 if ( pProfile->Keys.KeyLength[3] )
3290 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303291 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[ 3 ],
3292 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003293 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
3294 }
3295 else
3296 {
3297 Key3Length = 0;
3298 }
3299
3300 break;
3301
Jeff Johnson295189b2012-06-20 16:38:30 -07003302 case eCSR_ENCRYPT_TYPE_TKIP:
3303 case eCSR_ENCRYPT_TYPE_AES:
3304#ifdef FEATURE_WLAN_WAPI
3305 case eCSR_ENCRYPT_TYPE_WPI:
3306#endif /* FEATURE_WLAN_WAPI */
3307 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
3308 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
3309 PrivacyEnabled = (0 != fPrivacy);
3310
3311 // turn on RSN enabled for WPA associations
3312 RsnEnabled = 1;
3313
3314 // WEP key length and Wep Default Key ID don't matter in this case....
3315
3316 // clear out the static WEP keys that may be hanging around.
3317 Key0Length = 0;
3318 Key1Length = 0;
3319 Key2Length = 0;
3320 Key3Length = 0;
3321
3322 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003323 default:
3324 PrivacyEnabled = 0;
3325 RsnEnabled = 0;
3326 break;
3327 }
3328
3329 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
3330 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
3331 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
3332 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
3333 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
3334 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
3335 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
3336 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
3337}
3338
Jeff Johnson295189b2012-06-20 16:38:30 -07003339static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
3340{
3341 tANI_U32 len = 0;
3342 if(pSSID->length <= WNI_CFG_SSID_LEN)
3343 {
3344 len = pSSID->length;
3345 }
3346 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
3347}
3348
Jeff Johnson295189b2012-06-20 16:38:30 -07003349eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
3350{
3351 eHalStatus status = eHAL_STATUS_SUCCESS;
3352 tANI_U32 QoSEnabled;
3353 tANI_U32 WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003354 // set the CFG enable/disable variables based on the qosType being configured...
3355 switch( qosType )
3356 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003357 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
3358 QoSEnabled = FALSE;
3359 WmeEnabled = TRUE;
3360 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003361 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
3362 QoSEnabled = FALSE;
3363 WmeEnabled = TRUE;
3364 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003365 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
3366 QoSEnabled = FALSE;
3367 WmeEnabled = TRUE;
3368 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003369 case eCSR_MEDIUM_ACCESS_11e_eDCF:
3370 QoSEnabled = TRUE;
3371 WmeEnabled = FALSE;
3372 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003373 case eCSR_MEDIUM_ACCESS_11e_HCF:
3374 QoSEnabled = TRUE;
3375 WmeEnabled = FALSE;
3376 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003377 default:
3378 case eCSR_MEDIUM_ACCESS_DCF:
3379 QoSEnabled = FALSE;
3380 WmeEnabled = FALSE;
3381 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003382 }
3383 //save the WMM setting for later use
3384 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
Sandeep Puligillaaea98a22013-12-04 13:36:32 +05303385 pMac->roam.roamSession[sessionId].fQOSConnection = (tANI_BOOLEAN)QoSEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003386 return (status);
3387}
Jeff Johnson295189b2012-06-20 16:38:30 -07003388static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
3389 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet)
3390{
3391 eHalStatus status = eHAL_STATUS_FAILURE;
3392 int i;
3393 eCsrCfgDot11Mode cfgDot11Mode;
3394 tANI_U8 *pDstRate;
Kiet Lam64c1b492013-07-12 13:56:44 +05303395 vos_mem_set(pOpRateSet, sizeof(tSirMacRateSet), 0);
3396 vos_mem_set(pExRateSet, sizeof(tSirMacRateSet), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003397 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003398
3399 if( NULL != pIes )
3400 {
3401 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003402 // Originally, we thought that for 11a networks, the 11a rates are always
3403 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3404 // appear in the Operational Rate set. Consequently, in either case, we
3405 // would blindly put the rates we support into our Operational Rate set
3406 // (including the basic rates, which we have already verified are
3407 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003408 // However, it turns out that this is not always the case. Some AP's
3409 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3410 // too. Now, we're a little more careful:
3411 pDstRate = pOpRateSet->rate;
3412 if(pIes->SuppRates.present)
3413 {
3414 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3415 {
3416 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
3417 {
3418 *pDstRate++ = pIes->SuppRates.rates[ i ];
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003419 pOpRateSet->numRates++;
Jeff Johnson295189b2012-06-20 16:38:30 -07003420 }
3421 }
3422 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003423 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3424 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3425 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3426 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3427 {
3428 // If there are Extended Rates in the beacon, we will reflect those
3429 // extended rates that we support in out Extended Operational Rate
3430 // set:
3431 pDstRate = pExRateSet->rate;
3432 if(pIes->ExtSuppRates.present)
3433 {
3434 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3435 {
3436 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) )
3437 {
3438 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3439 pExRateSet->numRates++;
3440 }
3441 }
3442 }
3443 }
3444 }//Parsing BSSDesc
3445 else
3446 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003447 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003448 }
3449 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
3450 return status;
3451}
3452
3453static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
3454 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3455{
3456 int i;
3457 tANI_U8 *pDstRate;
3458 eCsrCfgDot11Mode cfgDot11Mode;
3459 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3460 tANI_U32 OperationalRatesLength = 0;
3461 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3462 tANI_U32 ExtendedOperationalRatesLength = 0;
3463 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3464 tANI_U32 ProprietaryOperationalRatesLength = 0;
3465 tANI_U32 PropRatesEnable = 0;
3466 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
3467 tANI_U32 MCSRateLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003468 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003469 if( NULL != pIes )
3470 {
3471 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003472 // Originally, we thought that for 11a networks, the 11a rates are always
3473 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3474 // appear in the Operational Rate set. Consequently, in either case, we
3475 // would blindly put the rates we support into our Operational Rate set
3476 // (including the basic rates, which we have already verified are
3477 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003478 // However, it turns out that this is not always the case. Some AP's
3479 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3480 // too. Now, we're a little more careful:
3481 pDstRate = OperationalRates;
3482 if(pIes->SuppRates.present)
3483 {
3484 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3485 {
3486 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
3487 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
3488 {
3489 *pDstRate++ = pIes->SuppRates.rates[ i ];
3490 OperationalRatesLength++;
3491 }
3492 }
3493 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003494 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3495 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3496 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3497 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3498 {
3499 // If there are Extended Rates in the beacon, we will reflect those
3500 // extended rates that we support in out Extended Operational Rate
3501 // set:
3502 pDstRate = ExtendedOperationalRates;
3503 if(pIes->ExtSuppRates.present)
3504 {
3505 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3506 {
3507 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
3508 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
3509 {
3510 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3511 ExtendedOperationalRatesLength++;
3512 }
3513 }
3514 }
3515 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003516 // Enable proprietary MAC features if peer node is Airgo node and STA
3517 // user wants to use them
3518 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
3519 {
3520 PropRatesEnable = 1;
3521 }
3522 else
3523 {
3524 PropRatesEnable = 0;
3525 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003526 // For ANI network companions, we need to populate the proprietary rate
3527 // set with any proprietary rates we found in the beacon, only if user
3528 // allows them...
3529 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
3530 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
3531 {
3532 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
3533 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
3534 {
3535 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
3536 }
Kiet Lam64c1b492013-07-12 13:56:44 +05303537 vos_mem_copy(ProprietaryOperationalRates,
3538 pIes->Airgo.PropSuppRates.rates,
3539 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003540 }
3541 else {
3542 // No proprietary modes...
3543 ProprietaryOperationalRatesLength = 0;
3544 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003545 /* Get MCS Rate */
3546 pDstRate = MCSRateIdxSet;
3547 if ( pIes->HTCaps.present )
3548 {
3549 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
3550 {
3551 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
3552 {
3553 MCSRateLength++;
3554 *pDstRate++ = i;
3555 }
3556 }
3557 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003558 // Set the operational rate set CFG variables...
3559 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3560 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3561 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3562 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3563 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3564 ProprietaryOperationalRates,
3565 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3566 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
3567 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
3568 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
3569 }//Parsing BSSDesc
3570 else
3571 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003572 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003573 }
3574}
3575
Jeff Johnson295189b2012-06-20 16:38:30 -07003576static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
3577 tCsrRoamProfile *pProfile )
3578{
3579 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
3580 { 8,
3581 { SIR_MAC_RATE_6,
3582 SIR_MAC_RATE_9,
3583 SIR_MAC_RATE_12,
3584 SIR_MAC_RATE_18,
3585 SIR_MAC_RATE_24,
3586 SIR_MAC_RATE_36,
3587 SIR_MAC_RATE_48,
3588 SIR_MAC_RATE_54 } } };
Jeff Johnson295189b2012-06-20 16:38:30 -07003589 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
3590 { 4,
3591 { SIR_MAC_RATE_1,
3592 SIR_MAC_RATE_2,
3593 SIR_MAC_RATE_5_5,
3594 SIR_MAC_RATE_11 } } };
3595
3596
3597 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
3598 { SIR_MAC_RATE_72,
3599 SIR_MAC_RATE_96,
3600 SIR_MAC_RATE_108 } };
3601 eCsrCfgDot11Mode cfgDot11Mode;
3602 eCsrBand eBand;
3603 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3604 tANI_U32 OperationalRatesLength = 0;
3605 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3606 tANI_U32 ExtendedOperationalRatesLength = 0;
3607 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3608 tANI_U32 ProprietaryOperationalRatesLength = 0;
3609 tANI_U32 PropRatesEnable = 0;
3610 tANI_U8 operationChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003611 if(pProfile->ChannelInfo.ChannelList)
3612 {
3613 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3614 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003615 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -07003616 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
3617 // networks, the 11b rates appear in the Operational Rate set. In either case,
3618 // we can blindly put the rates we support into our Operational Rate set
3619 // (including the basic rates, which we have already verified are supported
3620 // earlier in the roaming decision).
3621 if ( eCSR_BAND_5G == eBand )
3622 {
3623 // 11a rates into the Operational Rate Set.
3624 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3625 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303626 vos_mem_copy(OperationalRates,
3627 DefaultSupportedRates11a.supportedRateSet.rate,
3628 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003629
3630 // Nothing in the Extended rate set.
3631 ExtendedOperationalRatesLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003632 // populate proprietary rates if user allows them
3633 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3634 {
3635 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3636 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303637 vos_mem_copy(ProprietaryOperationalRates,
3638 DefaultSupportedPropRates.propRate,
3639 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003640 }
3641 else
3642 {
3643 // No proprietary modes
3644 ProprietaryOperationalRatesLength = 0;
3645 }
3646 }
3647 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
3648 {
3649 // 11b rates into the Operational Rate Set.
3650 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3651 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303652 vos_mem_copy(OperationalRates,
3653 DefaultSupportedRates11b.supportedRateSet.rate,
3654 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003655 // Nothing in the Extended rate set.
3656 ExtendedOperationalRatesLength = 0;
3657 // No proprietary modes
3658 ProprietaryOperationalRatesLength = 0;
3659 }
3660 else
3661 {
3662 // 11G
3663
3664 // 11b rates into the Operational Rate Set.
3665 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3666 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303667 vos_mem_copy(OperationalRates,
3668 DefaultSupportedRates11b.supportedRateSet.rate,
3669 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003670
3671 // 11a rates go in the Extended rate set.
3672 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3673 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303674 vos_mem_copy(ExtendedOperationalRates,
3675 DefaultSupportedRates11a.supportedRateSet.rate,
3676 ExtendedOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003677
3678 // populate proprietary rates if user allows them
3679 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3680 {
3681 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3682 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303683 vos_mem_copy(ProprietaryOperationalRates,
3684 DefaultSupportedPropRates.propRate,
3685 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003686 }
3687 else
3688 {
3689 // No proprietary modes
3690 ProprietaryOperationalRatesLength = 0;
3691 }
3692 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003693 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
3694 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
3695 {
3696 PropRatesEnable = 1;
3697 }
3698 else
3699 {
3700 PropRatesEnable = 0;
3701 }
3702
3703 // Set the operational rate set CFG variables...
3704 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3705 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3706 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3707 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3708 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3709 ProprietaryOperationalRates,
3710 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3711 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003712}
Jeff Johnson295189b2012-06-20 16:38:30 -07003713void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
3714{
3715 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07003716
Jeff Johnson295189b2012-06-20 16:38:30 -07003717 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
3718 tANI_U32 sessionId;
3719 tSmeCmd *pCommand = NULL;
3720
3721 if(NULL == pEntry)
3722 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003723 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07003724 return;
3725 }
3726 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
3727 sessionId = pCommand->sessionId;
3728
3729 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
3730 {
3731 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
3732 }
3733}
3734
Jeff Johnson295189b2012-06-20 16:38:30 -07003735//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
3736tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
3737{
3738 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
3739 {
3740 return (WNI_CFG_PHY_MODE_11B);
3741 }
3742 else
3743 {
3744 if(eCSR_BAND_24 == band)
3745 return (WNI_CFG_PHY_MODE_11G);
3746 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003747 return (WNI_CFG_PHY_MODE_11A);
3748}
Jeff Johnson295189b2012-06-20 16:38:30 -07003749
Jeff Johnsone7245742012-09-05 17:12:55 -07003750
3751#ifdef WLAN_FEATURE_11AC
3752ePhyChanBondState csrGetHTCBStateFromVHTCBState(ePhyChanBondState aniCBMode)
3753{
3754 switch ( aniCBMode )
3755 {
3756 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
3757 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
3758 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
3759 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3760 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
3761 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
3762 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
3763 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3764 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003765 default :
Jeff Johnsone7245742012-09-05 17:12:55 -07003766 return PHY_SINGLE_CHANNEL_CENTERED;
3767 }
3768}
3769#endif
3770
Jeff Johnson295189b2012-06-20 16:38:30 -07003771//pIes may be NULL
3772eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3773 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303774 tDot11fBeaconIEs *pIes, tANI_BOOLEAN resetCountry)
Jeff Johnson295189b2012-06-20 16:38:30 -07003775{
3776 eHalStatus status = eHAL_STATUS_SUCCESS;
3777 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3778 tANI_U8 channel = 0;
3779 //Make sure we have the domain info for the BSS we try to connect to.
3780 //Do we need to worry about sequence for OSs that are not Windows??
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303781 if (pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -07003782 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303783 if (csrLearnCountryInformation(pMac, pBssDesc, pIes, eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07003784 {
3785 //Make sure the 11d info from this BSSDesc can be applied
3786 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303787 if (VOS_TRUE == resetCountry)
3788 {
3789 csrApplyCountryInformation(pMac, FALSE);
3790 }
3791 else
3792 {
3793 csrApplyCountryInformation(pMac, TRUE);
3794 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003795 }
Kiran4a17ebe2013-01-31 10:43:43 -08003796 if ((csrIs11dSupported (pMac)) && pIes)
3797 {
3798 if (!pIes->Country.present)
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003799 {
Kiran4a17ebe2013-01-31 10:43:43 -08003800 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE );
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003801 }
3802 else
3803 {
3804 //Let's also update the below to make sure we don't update CC while
3805 //connected to an AP which is advertising some CC
Kiet Lamf2f201e2013-11-16 21:24:16 +05303806 vos_mem_copy(pMac->scan.currentCountryBssid,
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003807 pBssDesc->bssId, sizeof(tSirMacAddr));
3808 }
Kiran4a17ebe2013-01-31 10:43:43 -08003809 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003810 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003811 //Qos
3812 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
3813 //SSID
3814 csrSetCfgSsid(pMac, &pBssConfig->SSID );
3815 //fragment threshold
3816 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3817 //RTS threshold
3818 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3819
3820 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003821 //Auth type
3822 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
3823 //encryption type
3824 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
3825 //short slot time
3826 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003827 //11d
3828 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
3829 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
3830 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003831 /*//11h
3832 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
3833 */
3834 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
3835 //CB
Jeff Johnsone7245742012-09-05 17:12:55 -07003836
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003837 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile) || CSR_IS_IBSS(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07003838 {
3839 channel = pProfile->operationChannel;
3840 }
3841 else
3842 {
3843 if(pBssDesc)
3844 {
3845 channel = pBssDesc->channelId;
3846 }
3847 }
3848 if(0 != channel)
3849 {
Sandeep Puligilla60342762014-01-30 21:05:37 +05303850 if(CSR_IS_CHANNEL_24GHZ(channel) &&
3851 !pMac->roam.configParam.channelBondingMode24GHz &&
3852 !WDA_getFwWlanFeatCaps(HT40_OBSS_SCAN))
3853 {//On 2.4 Ghz, CB will be disabled if it is not configured through .ini
Jeff Johnson295189b2012-06-20 16:38:30 -07003854 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Sandeep Puligilla60342762014-01-30 21:05:37 +05303855 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
3856 " cbMode disabled cfgCb = %d channelBondingMode24GHz %d",
3857 __func__, cfgCb, pMac->roam.configParam.channelBondingMode24GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07003858 }
3859 else
3860 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003861 cfgCb = pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003862 }
3863 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003864#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudia0d88932012-11-13 10:51:26 -08003865 // cbMode = 1 in cfg.ini is mapped to PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
3866 // in function csrConvertCBIniValueToPhyCBState()
3867 // So, max value for cbMode in 40MHz mode is 3 (MAC\src\include\sirParams.h)
3868 if(cfgCb > PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
Jeff Johnsone7245742012-09-05 17:12:55 -07003869 {
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003870 if(!WDA_getFwWlanFeatCaps(DOT11AC)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07003871 cfgCb = csrGetHTCBStateFromVHTCBState(cfgCb);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003872 }
Sandeep Puligilla60342762014-01-30 21:05:37 +05303873 else
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003874 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003875 ccmCfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, pMac->roam.configParam.nVhtChannelWidth, NULL, eANI_BOOLEAN_FALSE);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003876 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003877 }
3878 else
3879#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003880 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
3881 //Rate
3882 //Fixed Rate
3883 if(pBssDesc)
3884 {
3885 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
3886 }
3887 else
3888 {
3889 csrSetCfgRateSetFromProfile(pMac, pProfile);
3890 }
3891 //Make this the last CFG to set. The callback will trigger a join_req
3892 //Join time out
3893 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
3894
3895 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003896 return (status);
3897}
3898
Jeff Johnson295189b2012-06-20 16:38:30 -07003899eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3900 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3901{
3902 eHalStatus status;
3903 tBssConfigParam *pBssConfig;
3904 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003905
3906 if(!pSession)
3907 {
3908 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3909 return eHAL_STATUS_FAILURE;
3910 }
3911
Kiet Lam64c1b492013-07-12 13:56:44 +05303912 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
3913 if ( NULL == pBssConfig )
3914 status = eHAL_STATUS_FAILURE;
3915 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003916 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303917 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003918 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
3919 if(HAL_STATUS_SUCCESS(status))
3920 {
3921 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003922 /* This will allow to pass cbMode during join req */
3923 pSession->bssParams.cbMode= pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003924 //For IBSS, we need to prepare some more information
3925 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003926 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003927 )
3928 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003929 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07003930 }
3931 // If we are in an IBSS, then stop the IBSS...
3932 ////Not worry about WDS connection for now
3933 if ( csrIsConnStateIbss( pMac, sessionId ) )
3934 {
3935 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
3936 }
3937 else
3938 {
3939 // if we are in an Infrastructure association....
3940 if ( csrIsConnStateInfra( pMac, sessionId ) )
3941 {
3942 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
3943 // across SSIDs (roaming to a new SSID)... //
3944 //Not worry about WDS connection for now
3945 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303946 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003947 {
3948 // then we need to disassociate from the Infrastructure network...
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303949 status = csrRoamIssueDisassociate( pMac, sessionId,
3950 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07003951 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303952 else
3953 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003954 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
3955 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303956 if ( pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -07003957 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303958 // Set parameters for this Bss.
3959 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
3960 pBssDesc, pBssConfig,
3961 pIes, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003962 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303963 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003964 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303965 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003966 {
3967 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
3968 // Nothing to stop.
3969 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003970 || CSR_IS_INFRA_AP(pProfile)
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303971 )
3972 {
3973 tANI_BOOLEAN is11rRoamingFlag = eANI_BOOLEAN_FALSE;
3974 is11rRoamingFlag = csrRoamIs11rAssoc(pMac);
3975 // Set parameters for this Bss.
3976 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
3977 pBssDesc, pBssConfig,
3978 pIes, is11rRoamingFlag);
3979 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003980 }
3981 }
3982 }//Success getting BSS config info
Kiet Lam64c1b492013-07-12 13:56:44 +05303983 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -07003984 }//Allocate memory
Jeff Johnson295189b2012-06-20 16:38:30 -07003985 return (status);
3986}
3987
Jeff Johnson295189b2012-06-20 16:38:30 -07003988eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
3989 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
3990{
3991 eCsrJoinState eRoamState = eCsrContinueRoaming;
3992 eHalStatus status;
3993 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
3994 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
3995 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003996
3997 if(!pSession)
3998 {
3999 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4000 return (eCsrStopRoaming);
4001 }
4002
Jeff Johnson295189b2012-06-20 16:38:30 -07004003 if( CSR_IS_WDS_STA( pProfile ) )
4004 {
4005 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
4006 if( !HAL_STATUS_SUCCESS( status ) )
4007 {
4008 eRoamState = eCsrStopRoaming;
4009 }
4010 }
4011 else
4012 {
4013 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
4014 {
4015 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
4016 return (eCsrStopRoaming);
4017 }
4018 if ( csrIsInfraBssDesc( pBssDesc ) )
4019 {
4020 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
4021 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
4022 // have changed and handle the changes (without disturbing the current association).
4023
4024 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
4025 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
4026 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
4027 )
4028 {
4029 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
4030 // with Authenticating first. To force this, stop the current association (Disassociate) and
4031 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
4032 // a new Association.
4033 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4034 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07004035 smsLog(pMac, LOGW, FL(" detect same profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004036 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
4037 {
4038 eRoamState = eCsrReassocToSelfNoCapChange;
4039 }
4040 else
4041 {
4042 tBssConfigParam bssConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004043 //The key changes
Kiet Lam64c1b492013-07-12 13:56:44 +05304044 vos_mem_set(&bssConfig, sizeof(bssConfig), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004045 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
4046 if(HAL_STATUS_SUCCESS(status))
4047 {
4048 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07004049 pSession->bssParams.cbMode = bssConfig.cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004050 //Reapply the config including Keys so reassoc is happening.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304051 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4052 pBssDesc, &bssConfig,
4053 pIesLocal, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004054 if(!HAL_STATUS_SUCCESS(status))
4055 {
4056 eRoamState = eCsrStopRoaming;
4057 }
4058 }
4059 else
4060 {
4061 eRoamState = eCsrStopRoaming;
4062 }
4063 }//same profile
4064 }
4065 else
4066 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304067 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004068 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
4069 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05304070 smsLog(pMac, LOGE, FL(" fail to issue disassociate with Session ID %d"),
4071 sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004072 eRoamState = eCsrStopRoaming;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304073 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004074 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304075 }
4076 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004077 {
4078 // 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 +05304079 // we had a lot of join timeouts when testing at Samsung. removing this step helped associations
Jeff Johnson295189b2012-06-20 16:38:30 -07004080 // work much better.
4081 //
4082 //
4083 // stop the existing network before attempting to join the new network...
4084 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4085 {
4086 eRoamState = eCsrStopRoaming;
4087 }
4088 }
4089 }//Infra
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304090 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004091 {
4092 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4093 {
4094 eRoamState = eCsrStopRoaming;
4095 }
4096 }
4097 if( pIesLocal && !pScanResult->pvIes )
4098 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304099 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004100 }
4101 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004102 return( eRoamState );
4103}
4104
Jeff Johnson295189b2012-06-20 16:38:30 -07004105eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
4106 tSirBssDescription *pBssDesc, tANI_U32 roamId)
4107{
4108 eHalStatus status = eHAL_STATUS_SUCCESS;
4109 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05304110 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004111 roamInfo.pBssDesc = pBssDesc;
4112 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
4113 return (status);
4114}
Jeff Johnson295189b2012-06-20 16:38:30 -07004115//In case no matching BSS is found, use whatever default we can find
4116static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4117{
4118 //Need to get all negotiated types in place first
4119 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08004120 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07004121 {
4122 default:
4123 case eCSR_AUTH_TYPE_WPA:
4124 case eCSR_AUTH_TYPE_WPA_PSK:
4125 case eCSR_AUTH_TYPE_WPA_NONE:
4126 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4127 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4128 break;
4129
4130 case eCSR_AUTH_TYPE_SHARED_KEY:
4131 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
4132 break;
4133
4134 case eCSR_AUTH_TYPE_AUTOSWITCH:
4135 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
4136 break;
4137 }
4138 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4139 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4140 //In this case, the multicast encryption needs to follow the uncast ones.
4141 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4142 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4143}
4144
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004145
4146static void csrSetAbortRoamingCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4147{
4148 switch(pCommand->u.roamCmd.roamReason)
4149 {
4150 case eCsrLostLink1:
4151 pCommand->u.roamCmd.roamReason = eCsrLostLink1Abort;
4152 break;
4153 case eCsrLostLink2:
4154 pCommand->u.roamCmd.roamReason = eCsrLostLink2Abort;
4155 break;
4156 case eCsrLostLink3:
4157 pCommand->u.roamCmd.roamReason = eCsrLostLink3Abort;
4158 break;
4159 default:
4160 smsLog(pMac, LOGE, FL(" aborting roaming reason %d not recognized"),
4161 pCommand->u.roamCmd.roamReason);
4162 break;
4163 }
4164}
4165
Jeff Johnson295189b2012-06-20 16:38:30 -07004166static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
4167{
4168 eHalStatus status;
4169 tCsrScanResult *pScanResult = NULL;
4170 eCsrJoinState eRoamState = eCsrStopRoaming;
4171 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
4172 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
4173 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
4174#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4175 v_U8_t acm_mask = 0;
4176#endif
4177 tANI_U32 sessionId = pCommand->sessionId;
4178 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4179 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4180 tANI_U8 concurrentChannel = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004181
4182 if(!pSession)
4183 {
4184 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4185 return (eCsrStopRoaming);
4186 }
4187
Jeff Johnson295189b2012-06-20 16:38:30 -07004188 do
4189 {
4190 // Check for Cardbus eject condition, before trying to Roam to any BSS
4191 //***if( !balIsCardPresent(pAdapter) ) break;
4192
Kiet Lam64c1b492013-07-12 13:56:44 +05304193 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004194 memcpy (&roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004195 if(NULL != pBSSList)
4196 {
4197 // When handling AP's capability change, continue to associate to
4198 // same BSS and make sure pRoamBssEntry is not Null.
4199 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
4200 {
4201 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
4202 {
4203 //Try the first BSS
4204 pCommand->u.roamCmd.pLastRoamBss = NULL;
4205 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
4206 }
4207 else
4208 {
4209 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4210 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4211 {
4212 //Done with all the BSSs
4213 //In this case, will tell HDD the completion
4214 break;
4215 }
4216 else
4217 {
4218 //We need to indicate to HDD that we are done with this one.
Kiet Lam64c1b492013-07-12 13:56:44 +05304219 //vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004220 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
4221 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4222 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4223 pRoamInfo = &roamInfo;
4224 }
4225 }
4226 while(pCommand->u.roamCmd.pRoamBssEntry)
4227 {
4228 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Jeff Johnson295189b2012-06-20 16:38:30 -07004229 /*If concurrency enabled take the concurrent connected channel first. */
4230 /* Valid multichannel concurrent sessions exempted */
Jeff Johnsone7245742012-09-05 17:12:55 -07004231 if (vos_concurrent_sessions_running() &&
4232 !csrIsValidMcConcurrentSession(pMac, sessionId, &pScanResult->Result.BssDescriptor))
Jeff Johnson295189b2012-06-20 16:38:30 -07004233 {
4234 concurrentChannel =
4235 csrGetConcurrentOperationChannel(pMac);
4236 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004237 " csr Concurrent Channel = %d", __func__, concurrentChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07004238 if ((concurrentChannel) &&
4239 (concurrentChannel ==
4240 pScanResult->Result.BssDescriptor.channelId))
4241 {
4242 //make this 0 because we do not want the
4243 //below check to pass as we don't want to
4244 //connect on other channel
4245 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4246 FL("Concurrent channel match =%d"),
4247 concurrentChannel);
4248 concurrentChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004249 }
4250 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004251
4252 if (!concurrentChannel)
4253 {
4254
4255 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
4256 sessionId, &pScanResult->Result.BssDescriptor,
4257 pCommand->u.roamCmd.roamId)))
4258 {
4259 //Ok to roam this
4260 break;
4261 }
4262 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004263 else
4264 {
4265 eRoamState = eCsrStopRoamingDueToConcurrency;
4266 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004267 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4268 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4269 {
4270 //Done with all the BSSs
4271 fDone = eANI_BOOLEAN_TRUE;
4272 break;
4273 }
4274 }
4275 if(fDone)
4276 {
4277 break;
4278 }
4279 }
4280 }
4281 //We have something to roam, tell HDD when it is infra.
4282 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
4283 //For WDS, the indication is eCSR_ROAM_WDS_IND
4284 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4285 {
4286 if(pRoamInfo)
4287 {
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004288 if(pSession->bRefAssocStartCnt)
4289 {
4290 pSession->bRefAssocStartCnt--;
4291 //Complete the last association attemp because a new one is about to be tried
4292 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4293 eCSR_ROAM_ASSOCIATION_COMPLETION,
Jeff Johnson295189b2012-06-20 16:38:30 -07004294 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004295 }
4296 }
4297 /* If the roaming has stopped, not to continue the roaming command*/
4298 if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
4299 {
4300 //No need to complete roaming here as it already completes
4301 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed"),
4302 pCommand->u.roamCmd.roamReason);
4303 eRoamState = eCsrStopRoaming;
4304 csrSetAbortRoamingCommand(pMac, pCommand);
4305 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004306 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304307 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004308 if(pScanResult)
4309 {
4310 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07004311 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
4312 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004313 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004314 fDone = eANI_BOOLEAN_TRUE;
4315 eRoamState = eCsrStopRoaming;
4316 break;
4317 }
4318 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
4319 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
4320 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
4321 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
4322 CSR_IS_QOS_BSS(pIesLocal) &&
4323 CSR_IS_UAPSD_BSS(pIesLocal) )
4324 {
4325#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Jeff Johnson295189b2012-06-20 16:38:30 -07004326 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
4327 pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004328#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004329 }
4330 else
4331 {
4332 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4333 }
4334 if( pIesLocal && !pScanResult->Result.pvIes)
4335 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304336 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004337 }
4338 }
4339 else
4340 {
4341 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4342 }
4343 roamInfo.pProfile = pProfile;
4344 pSession->bRefAssocStartCnt++;
4345 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4346 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4347 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004348 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
4349 {
4350 // If this is a start IBSS profile, then we need to start the IBSS.
4351 if ( CSR_IS_START_IBSS(pProfile) )
4352 {
4353 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004354 // Attempt to start this IBSS...
4355 csrRoamAssignDefaultParam( pMac, pCommand );
4356 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
4357 if(HAL_STATUS_SUCCESS(status))
4358 {
4359 if ( fSameIbss )
4360 {
4361 eRoamState = eCsrStartIbssSameIbss;
4362 }
4363 else
4364 {
4365 eRoamState = eCsrContinueRoaming;
4366 }
4367 }
4368 else
4369 {
4370 //it somehow fail need to stop
4371 eRoamState = eCsrStopRoaming;
4372 }
4373 break;
4374 }
4375 else if ( (CSR_IS_WDS_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004376 || (CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004377 )
4378 {
4379 // Attempt to start this WDS...
4380 csrRoamAssignDefaultParam( pMac, pCommand );
4381 /* For AP WDS, we dont have any BSSDescription */
4382 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
4383 if(HAL_STATUS_SUCCESS(status))
4384 {
4385 eRoamState = eCsrContinueRoaming;
4386 }
4387 else
4388 {
4389 //it somehow fail need to stop
4390 eRoamState = eCsrStopRoaming;
4391 }
4392 }
4393 else
4394 {
4395 //Nothing we can do
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004396 smsLog(pMac, LOGW, FL("cannot continue without BSS list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004397 eRoamState = eCsrStopRoaming;
4398 break;
4399 }
4400 }
4401 else //We have BSS
4402 {
4403 //Need to assign these value because they are used in csrIsSameProfile
4404 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4405 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType = pScanResult->ucEncryptionType; //Negotiated while building scan result.
4406 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType = pScanResult->mcEncryptionType;
4407 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
4408 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
4409 {
4410 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4411 {
4412 eRoamState = eCsrStartIbssSameIbss;
4413 break;
4414 }
4415 }
4416 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
4417 {
4418 //trying to connect to the one already connected
4419 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
4420 eRoamState = eCsrReassocToSelfNoCapChange;
4421 break;
4422 }
4423 // Attempt to Join this Bss...
4424 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
4425 break;
4426 }
4427
4428 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004429 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
4430 {
4431 //Need to indicate association_completion if association_start has been done
4432 if(pSession->bRefAssocStartCnt > 0)
4433 {
4434 pSession->bRefAssocStartCnt--;
4435 //Complete the last association attemp because a new one is about to be tried
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004436 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07004437 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4438 eCSR_ROAM_ASSOCIATION_COMPLETION,
4439 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4440 }
4441 }
4442
4443 return( eRoamState );
4444}
4445
Jeff Johnson295189b2012-06-20 16:38:30 -07004446static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4447{
4448 eHalStatus status = eHAL_STATUS_SUCCESS;
4449 eCsrJoinState RoamState;
4450 tANI_U32 sessionId = pCommand->sessionId;
4451
Jeff Johnson295189b2012-06-20 16:38:30 -07004452 //***if( hddIsRadioStateOn( pAdapter ) )
4453 {
4454 // Attept to join a Bss...
4455 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07004456
Jeff Johnson295189b2012-06-20 16:38:30 -07004457 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07004458 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004459 {
4460 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004461 // and if connected in Infrastructure mode...
4462 if ( csrIsConnStateInfra(pMac, sessionId) )
4463 {
4464 //... then we need to issue a disassociation
4465 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
4466 if(!HAL_STATUS_SUCCESS(status))
4467 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004468 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004469 //roam command is completed by caller in the failed case
4470 fComplete = eANI_BOOLEAN_TRUE;
4471 }
4472 }
4473 else if( csrIsConnStateIbss(pMac, sessionId) )
4474 {
4475 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4476 if(!HAL_STATUS_SUCCESS(status))
4477 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004478 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004479 //roam command is completed by caller in the failed case
4480 fComplete = eANI_BOOLEAN_TRUE;
4481 }
4482 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004483 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
4484 {
4485 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4486 if(!HAL_STATUS_SUCCESS(status))
4487 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004488 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004489 //roam command is completed by caller in the failed case
4490 fComplete = eANI_BOOLEAN_TRUE;
4491 }
4492 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004493 else
4494 {
4495 fComplete = eANI_BOOLEAN_TRUE;
4496 }
4497 if(fComplete)
4498 {
4499 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07004500 if(eCsrStopRoamingDueToConcurrency == RoamState)
4501 {
4502 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
4503 }
4504 else
4505 {
4506 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
4507 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004508 }
4509 }
4510 else if ( eCsrReassocToSelfNoCapChange == RoamState )
4511 {
4512 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
4513 }
4514 else if ( eCsrStartIbssSameIbss == RoamState )
4515 {
4516 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
4517 }
4518 }//hddIsRadioStateOn
4519
4520 return status;
4521}
Jeff Johnson295189b2012-06-20 16:38:30 -07004522eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4523{
4524 tANI_U32 sessionId;
4525 tCsrRoamSession *pSession;
4526 tCsrScanResult *pScanResult = NULL;
4527 tSirBssDescription *pBssDesc = NULL;
4528 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004529 sessionId = pCommand->sessionId;
4530 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004531
4532 if(!pSession)
4533 {
4534 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4535 return eHAL_STATUS_FAILURE;
4536 }
4537
Jeff Johnson295189b2012-06-20 16:38:30 -07004538 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
4539 {
4540 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004541 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004542 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4543 return eHAL_STATUS_FAILURE;
4544 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004545 if (pCommand->u.roamCmd.pRoamBssEntry)
4546 {
4547 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4548 pBssDesc = &pScanResult->Result.BssDescriptor;
4549 }
4550 else
4551 {
4552 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004553 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004554 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4555 return eHAL_STATUS_FAILURE;
4556 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004557 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
4558 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
4559 return status;
4560}
4561
Jeff Johnson295189b2012-06-20 16:38:30 -07004562eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4563{
4564 eHalStatus status = eHAL_STATUS_SUCCESS;
4565 tCsrRoamInfo roamInfo;
4566 tANI_U32 sessionId = pCommand->sessionId;
4567 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004568
4569 if(!pSession)
4570 {
4571 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4572 return eHAL_STATUS_FAILURE;
4573 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004574
4575 switch ( pCommand->u.roamCmd.roamReason )
4576 {
4577 case eCsrForcedDisassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07004578 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004579 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004580 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004581 case eCsrSmeIssuedDisassocForHandoff:
4582 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
4583#if 0 // TODO : Confirm this change
4584 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
4585#else
4586 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4587#endif
4588
4589 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004590 case eCsrForcedDisassocMICFailure:
Jeff Johnson295189b2012-06-20 16:38:30 -07004591 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004592 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004593 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004594 case eCsrForcedDeauth:
Jeff Johnson295189b2012-06-20 16:38:30 -07004595 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004596 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004597 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004598 case eCsrHddIssuedReassocToSameAP:
4599 case eCsrSmeIssuedReassocToSameAP:
4600 {
4601 tDot11fBeaconIEs *pIes = NULL;
4602
Jeff Johnson295189b2012-06-20 16:38:30 -07004603 if( pSession->pConnectBssDesc )
4604 {
4605 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
4606 if(!HAL_STATUS_SUCCESS(status) )
4607 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004608 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004609 }
4610 else
4611 {
4612 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
4613 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
4614 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07004615 roamInfo.pBssDesc = pSession->pConnectBssDesc;
4616 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
4617 pSession->bRefAssocStartCnt++;
4618 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4619 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4620
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004621 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004622 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
4623 &pCommand->u.roamCmd.roamProfile );
4624 if(!HAL_STATUS_SUCCESS(status))
4625 {
4626 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08004627 csrReleaseCommandRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004628 }
4629
Kiet Lam64c1b492013-07-12 13:56:44 +05304630 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07004631 pIes = NULL;
4632 }
4633 }
4634 break;
4635 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004636 case eCsrCapsChange:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004637 smsLog(pMac, LOGE, FL("received eCsrCapsChange "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004638 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4639 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
4640 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004641 case eCsrSmeIssuedFTReassoc:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004642 smsLog(pMac, LOG1, FL("received FT Reassoc Req "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004643 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
4644 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07004645
Jeff Johnson295189b2012-06-20 16:38:30 -07004646 case eCsrStopBss:
4647 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4648 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4649 break;
4650
4651 case eCsrForcedDisassocSta:
4652 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4653 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
4654 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4655 pCommand->u.roamCmd.reason);
4656 break;
4657
4658 case eCsrForcedDeauthSta:
4659 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4660 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
4661 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4662 pCommand->u.roamCmd.reason);
4663 break;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004664
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004665 case eCsrPerformPreauth:
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08004666 smsLog(pMac, LOG1, FL("Attempting FT PreAuth Req"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004667 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
4668 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004669 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004670
4671 default:
4672 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4673
4674 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
4675 {
4676 //Remember the roaming profile
4677 csrFreeRoamProfile(pMac, sessionId);
Kiet Lam64c1b492013-07-12 13:56:44 +05304678 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
4679 if ( NULL != pSession->pCurRoamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004680 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304681 vos_mem_set(pSession->pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004682 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
4683 }
4684 }
4685
4686 //At this point, original uapsd_mask is saved in pCurRoamProfile
4687 //uapsd_mask in the pCommand may change from this point on.
4688
4689 // Attempt to roam with the new scan results (if we need to..)
4690 status = csrRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004691 if(!HAL_STATUS_SUCCESS(status))
4692 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004693 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X"), status);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004694 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004695 break;
4696 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004697 return (status);
4698}
4699
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004700void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4701{
4702 pCommand->u.roamCmd.pLastRoamBss = NULL;
4703 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4704 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05304705 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004706}
4707
Jeff Johnson295189b2012-06-20 16:38:30 -07004708void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4709{
4710 if(pCommand->u.roamCmd.fReleaseBssList)
4711 {
4712 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
4713 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
4714 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
4715 }
4716 if(pCommand->u.roamCmd.fReleaseProfile)
4717 {
4718 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
4719 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
4720 }
4721 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4722 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05304723 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004724}
4725
Jeff Johnson295189b2012-06-20 16:38:30 -07004726void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4727{
Kiet Lam64c1b492013-07-12 13:56:44 +05304728 vos_mem_set(&pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004729}
Jeff Johnson295189b2012-06-20 16:38:30 -07004730void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
4731{
4732 tListElem *pEntry;
4733 tSmeCmd *pCommand;
4734 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004735 smsLog( pMac, LOG2, "Roam Completion ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004736 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
4737 if ( pEntry )
4738 {
4739 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07004740 // If the head of the queue is Active and it is a ROAM command, remove
4741 // and put this on the Free queue.
4742 if ( eSmeCommandRoam == pCommand->command )
4743 {
4744 //we need to process the result first before removing it from active list because state changes
4745 //still happening insides roamQProcessRoamResults so no other roam command should be issued
4746 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
4747 if( fReleaseCommand )
4748 {
4749 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
4750 {
4751 csrReleaseCommandRoam( pMac, pCommand );
4752 }
4753 else
4754 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004755 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004756 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004757 }
4758 }
4759 else
4760 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004761 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004762 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004763 }
4764 }
4765 else
4766 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004767 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004768 }
4769 }
4770 else
4771 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004772 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004773 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004774 if( fReleaseCommand )
4775 {
4776 smeProcessPendingQueue( pMac );
4777 }
4778}
4779
Jeff Johnson295189b2012-06-20 16:38:30 -07004780void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4781{
4782 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004783 if(!pSession)
4784 {
4785 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4786 return;
4787 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304788 vos_mem_set(&(pSession->PmkidCandidateInfo[0]),
4789 sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004790 pSession->NumPmkidCandidate = 0;
4791}
Jeff Johnson295189b2012-06-20 16:38:30 -07004792#ifdef FEATURE_WLAN_WAPI
4793void csrResetBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4794{
4795 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004796 if(!pSession)
4797 {
4798 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4799 return;
4800 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304801 vos_mem_set(&(pSession->BkidCandidateInfo[0]),
4802 sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004803 pSession->NumBkidCandidate = 0;
4804}
4805#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004806extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
4807
Jeff Johnson295189b2012-06-20 16:38:30 -07004808static eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrAuthType authType,
4809 tSirBssDescription *pSirBssDesc,
4810 tDot11fBeaconIEs *pIes)
4811{
4812 eHalStatus status = eHAL_STATUS_SUCCESS;
4813 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4814 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004815
4816 if(!pSession)
4817 {
4818 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4819 return eHAL_STATUS_FAILURE;
4820 }
4821
Jeff Johnson295189b2012-06-20 16:38:30 -07004822 if((eCSR_AUTH_TYPE_WPA == authType) ||
4823 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
4824 (eCSR_AUTH_TYPE_RSN == authType) ||
4825 (eCSR_AUTH_TYPE_RSN_PSK == authType)
4826#if defined WLAN_FEATURE_VOWIFI_11R
4827 ||
4828 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4829 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
4830#endif /* FEATURE_WLAN_WAPI */
4831#ifdef FEATURE_WLAN_WAPI
4832 ||
4833 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4834 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
4835#endif /* FEATURE_WLAN_WAPI */
Chet Lanctot186b5732013-03-18 10:26:30 -07004836#ifdef WLAN_FEATURE_11W
4837 ||
4838 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType)
4839#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004840 )
4841 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004842 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4843 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004844 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004845 }
4846 if( pIesLocal )
4847 {
4848 tANI_U32 nIeLen;
4849 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07004850 if((eCSR_AUTH_TYPE_RSN == authType) ||
4851#if defined WLAN_FEATURE_VOWIFI_11R
4852 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4853 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
4854#endif /* WLAN_FEATURE_VOWIFI_11R */
Chet Lanctot186b5732013-03-18 10:26:30 -07004855#if defined WLAN_FEATURE_11W
4856 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
4857#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004858 (eCSR_AUTH_TYPE_RSN_PSK == authType))
4859 {
4860 if(pIesLocal->RSN.present)
4861 {
4862 //Calculate the actual length
4863 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
4864 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
4865 + 2 //akm_suite_count
4866 + pIesLocal->RSN.akm_suite_count * 4 //akm_suites
4867 + 2; //reserved
4868 if( pIesLocal->RSN.pmkid_count )
4869 {
4870 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
4871 }
4872 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304873 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
4874 if (NULL == pSession->pWpaRsnRspIE)
4875 status = eHAL_STATUS_FAILURE;
4876 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004877 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304878 vos_mem_set(pSession->pWpaRsnRspIE, nIeLen + 2, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004879 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
4880 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4881 //copy upto akm_suites
4882 pIeBuf = pSession->pWpaRsnRspIE + 2;
Kiet Lam64c1b492013-07-12 13:56:44 +05304883 vos_mem_copy(pIeBuf, &pIesLocal->RSN.version,
4884 sizeof(pIesLocal->RSN.version));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004885 pIeBuf += sizeof(pIesLocal->RSN.version);
Kiet Lam64c1b492013-07-12 13:56:44 +05304886 vos_mem_copy(pIeBuf, &pIesLocal->RSN.gp_cipher_suite,
4887 sizeof(pIesLocal->RSN.gp_cipher_suite));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004888 pIeBuf += sizeof(pIesLocal->RSN.gp_cipher_suite);
Kiet Lam64c1b492013-07-12 13:56:44 +05304889 vos_mem_copy(pIeBuf, &pIesLocal->RSN.pwise_cipher_suite_count,
4890 sizeof(pIesLocal->RSN.pwise_cipher_suite_count));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004891 pIeBuf += sizeof(pIesLocal->RSN.pwise_cipher_suite_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07004892 if( pIesLocal->RSN.pwise_cipher_suite_count )
4893 {
4894 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304895 vos_mem_copy(pIeBuf,
4896 pIesLocal->RSN.pwise_cipher_suites,
4897 pIesLocal->RSN.pwise_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004898 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
4899 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304900 vos_mem_copy(pIeBuf, &pIesLocal->RSN.akm_suite_count, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004901 pIeBuf += 2;
4902 if( pIesLocal->RSN.akm_suite_count )
4903 {
4904 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304905 vos_mem_copy(pIeBuf,
4906 pIesLocal->RSN.akm_suites,
4907 pIesLocal->RSN.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004908 pIeBuf += pIesLocal->RSN.akm_suite_count * 4;
4909 }
4910 //copy the rest
Kiet Lam64c1b492013-07-12 13:56:44 +05304911 vos_mem_copy(pIeBuf,
4912 pIesLocal->RSN.akm_suites + pIesLocal->RSN.akm_suite_count * 4,
4913 2 + pIesLocal->RSN.pmkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004914 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4915 }
4916 }
4917 }
4918 else if((eCSR_AUTH_TYPE_WPA == authType) ||
4919 (eCSR_AUTH_TYPE_WPA_PSK == authType))
4920 {
4921 if(pIesLocal->WPA.present)
4922 {
4923 //Calculate the actual length
4924 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
4925 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
4926 + 2 //auth_suite_count
4927 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
4928 // The WPA capabilities follows the Auth Suite (two octects)--
4929 // this field is optional, and we always "send" zero, so just
4930 // remove it. This is consistent with our assumptions in the
4931 // frames compiler; c.f. bug 15234:
4932 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304933
4934 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
4935 if ( NULL == pSession->pWpaRsnRspIE )
4936 status = eHAL_STATUS_FAILURE;
4937 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004938 {
4939 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
4940 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4941 pIeBuf = pSession->pWpaRsnRspIE + 2;
4942 //Copy WPA OUI
Kiet Lam64c1b492013-07-12 13:56:44 +05304943 vos_mem_copy(pIeBuf, &csrWpaOui[1], 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004944 pIeBuf += 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05304945 vos_mem_copy(pIeBuf, &pIesLocal->WPA.version,
4946 8 + pIesLocal->WPA.unicast_cipher_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004947 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05304948 vos_mem_copy(pIeBuf, &pIesLocal->WPA.auth_suite_count,
4949 2 + pIesLocal->WPA.auth_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004950 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
4951 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4952 }
4953 }
4954 }
4955#ifdef FEATURE_WLAN_WAPI
4956 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4957 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
4958 {
4959 if(pIesLocal->WAPI.present)
4960 {
4961 //Calculate the actual length
4962 nIeLen = 4 //version + akm_suite_count
4963 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
4964 + 2 //pwise_cipher_suite_count
4965 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
4966 + 6; //gp_cipher_suite + preauth + reserved
4967 if( pIesLocal->WAPI.bkid_count )
4968 {
4969 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
4970 }
4971
4972 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304973 pSession->pWapiRspIE = vos_mem_malloc(nIeLen + 2);
4974 if ( NULL == pSession->pWapiRspIE )
4975 status = eHAL_STATUS_FAILURE;
4976 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004977 {
4978 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
4979 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
4980 pIeBuf = pSession->pWapiRspIE + 2;
4981 //copy upto akm_suite_count
Kiet Lam64c1b492013-07-12 13:56:44 +05304982 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.version, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004983 pIeBuf += 4;
4984 if( pIesLocal->WAPI.akm_suite_count )
4985 {
4986 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304987 vos_mem_copy(pIeBuf, pIesLocal->WAPI.akm_suites,
4988 pIesLocal->WAPI.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004989 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05304990 }
4991 vos_mem_copy(pIeBuf,
4992 &pIesLocal->WAPI.unicast_cipher_suite_count,
4993 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004994 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004995 if( pIesLocal->WAPI.unicast_cipher_suite_count )
4996 {
4997 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304998 vos_mem_copy( pIeBuf,
4999 pIesLocal->WAPI.unicast_cipher_suites,
5000 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005001 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
5002 }
lukez3c809222013-05-03 10:23:02 -07005003 //gp_cipher_suite
Kiet Lam64c1b492013-07-12 13:56:44 +05305004 vos_mem_copy(pIeBuf,
5005 pIesLocal->WAPI.multicast_cipher_suite,
5006 4);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005007 pIeBuf += 4;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305008 //preauth + reserved
Kiet Lam64c1b492013-07-12 13:56:44 +05305009 vos_mem_copy(pIeBuf,
5010 pIesLocal->WAPI.multicast_cipher_suite + 4,
5011 2);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005012 pIeBuf += 2;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305013 //bkid_count
Kiet Lam64c1b492013-07-12 13:56:44 +05305014 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.bkid_count, 2);
5015
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005016 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005017 if( pIesLocal->WAPI.bkid_count )
5018 {
5019 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305020 vos_mem_copy(pIeBuf, pIesLocal->WAPI.bkid,
5021 pIesLocal->WAPI.bkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005022 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
5023 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305024 pSession->nWapiRspIeLength = nIeLen + 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005025 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005026 }
5027 }
5028#endif /* FEATURE_WLAN_WAPI */
5029 if( !pIes )
5030 {
5031 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05305032 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07005033 }
5034 }
5035 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005036 return (status);
5037}
5038
Jeff Johnson295189b2012-06-20 16:38:30 -07005039static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
5040{
5041 v_U8_t bACWeights[WLANTL_MAX_AC];
5042 v_U8_t paramBk, paramBe, paramVi, paramVo;
5043 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005044 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
5045 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
5046 //of the higher AC one, make the higher AC has the same weight as the lower AC.
5047 //This doesn't address the case where the lower AC needs a real higher weight
5048 if( pIEs->WMMParams.present )
5049 {
5050 //no change to the lowest ones
5051 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
5052 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
5053 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
5054 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
5055 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
5056 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
5057 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
5058 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
5059 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
5060 {
5061 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
5062 fWeightChange = VOS_TRUE;
5063 }
5064 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
5065 {
5066 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
5067 fWeightChange = VOS_TRUE;
5068 }
5069 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
5070 {
5071 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
5072 fWeightChange = VOS_TRUE;
5073 }
5074 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
5075 {
5076 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
5077 fWeightChange = VOS_TRUE;
5078 }
5079 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
5080 {
5081 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
5082 fWeightChange = VOS_TRUE;
5083 }
5084 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
5085 {
5086 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
5087 fWeightChange = VOS_TRUE;
5088 }
5089 if(fWeightChange)
5090 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005091 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)"), bACWeights[0], bACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07005092 bACWeights[2], bACWeights[3]);
5093 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
5094 }
5095 }
5096}
Jeff Johnson295189b2012-06-20 16:38:30 -07005097#ifdef WLAN_FEATURE_VOWIFI_11R
5098//Returns whether the current association is a 11r assoc or not
5099tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
5100{
5101#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5102 return csrNeighborRoamIs11rAssoc(pMac);
5103#else
5104 return eANI_BOOLEAN_FALSE;
5105#endif
5106}
5107#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005108#ifdef FEATURE_WLAN_ESE
5109//Returns whether the current association is a ESE assoc or not
5110tANI_BOOLEAN csrRoamIsESEAssoc(tpAniSirGlobal pMac)
Jeff Johnson295189b2012-06-20 16:38:30 -07005111{
5112#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005113 return csrNeighborRoamIsESEAssoc(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07005114#else
5115 return eANI_BOOLEAN_FALSE;
5116#endif
5117}
5118#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005119#ifdef FEATURE_WLAN_LFR
5120//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305121tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005122{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305123 tCsrRoamSession *pSession = NULL;
5124
5125 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
5126 {
5127 pSession = CSR_GET_SESSION( pMac, sessionId );
5128 if (NULL != pSession->pCurRoamProfile)
5129 {
5130 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
5131 {
5132 return eANI_BOOLEAN_FALSE;
5133 }
5134 }
5135 }
5136
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005137#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5138 if (eANI_BOOLEAN_TRUE == CSR_IS_FASTROAM_IN_CONCURRENCY_INI_FEATURE_ENABLED(pMac))
5139 {
5140 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled);
5141 }
5142 else
5143#endif
5144 {
5145 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07005146 (!csrIsConcurrentSessionRunning(pMac)));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005147 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005148}
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005149
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005150#ifdef FEATURE_WLAN_ESE
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005151/* ---------------------------------------------------------------------------
5152
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005153 \fn csrNeighborRoamIsESEAssoc
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005154
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005155 \brief This function returns whether the current association is a ESE assoc or not
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005156
5157 \param pMac - The handle returned by macOpen.
5158
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005159 \return eANI_BOOLEAN_TRUE if current assoc is ESE, eANI_BOOLEAN_FALSE otherwise
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005160
5161---------------------------------------------------------------------------*/
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005162tANI_BOOLEAN csrNeighborRoamIsESEAssoc(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005163{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005164 return pMac->roam.neighborRoamInfo.isESEAssoc;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005165}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005166#endif /* FEATURE_WLAN_ESE */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005167
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005168#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5169//Returns whether "FW based BG scan" is currently enabled...or not
5170tANI_BOOLEAN csrRoamIsRoamOffloadScanEnabled(tpAniSirGlobal pMac)
5171{
5172 return (pMac->roam.configParam.isRoamOffloadScanEnabled);
5173}
5174#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005175#endif
5176
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005177#if defined(FEATURE_WLAN_ESE)
5178tANI_BOOLEAN csrRoamIsEseIniFeatureEnabled(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005179{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005180 return pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005181}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005182#endif /*FEATURE_WLAN_ESE*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005183
Jeff Johnson295189b2012-06-20 16:38:30 -07005184//Return true means the command can be release, else not
5185static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
5186 eCsrRoamCompleteResult Result, void *Context )
5187{
5188 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
5189 tSirBssDescription *pSirBssDesc = NULL;
5190 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
5191 tCsrScanResult *pScanResult = NULL;
5192 tCsrRoamInfo roamInfo;
5193 sme_QosAssocInfo assocInfo;
5194 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
5195 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
5196 tDot11fBeaconIEs *pIes = NULL;
5197 tANI_U32 sessionId = pCommand->sessionId;
5198 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5199 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
5200 eRoamCmdStatus roamStatus;
5201 eCsrRoamResult roamResult;
5202 eHalStatus status;
5203 tANI_U32 key_timeout_interval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005204 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005205
Jeff Johnson32d95a32012-09-10 13:15:23 -07005206 if(!pSession)
5207 {
5208 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5209 return eANI_BOOLEAN_FALSE;
5210 }
5211
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005212 smsLog( pMac, LOG1, FL("Processing ROAM results..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07005213 switch( Result )
5214 {
5215 case eCsrJoinSuccess:
5216 // reset the IDLE timer
5217 // !!
5218 // !! fall through to the next CASE statement here is intentional !!
5219 // !!
5220 case eCsrReassocSuccess:
5221 if(eCsrReassocSuccess == Result)
5222 {
5223 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
5224 }
5225 else
5226 {
5227 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
5228 }
5229 // Success Join Response from LIM. Tell NDIS we are connected and save the
5230 // Connected state...
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005231 smsLog(pMac, LOGW, FL("receives association indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305232 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005233 //always free the memory here
5234 if(pSession->pWpaRsnRspIE)
5235 {
5236 pSession->nWpaRsnRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305237 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005238 pSession->pWpaRsnRspIE = NULL;
5239 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005240#ifdef FEATURE_WLAN_WAPI
5241 if(pSession->pWapiRspIE)
5242 {
5243 pSession->nWapiRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305244 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005245 pSession->pWapiRspIE = NULL;
5246 }
5247#endif /* FEATURE_WLAN_WAPI */
5248#ifdef FEATURE_WLAN_BTAMP_UT_RF
5249 //Reset counter so no join retry is needed.
5250 pSession->maxRetryCount = 0;
5251 csrRoamStopJoinRetryTimer(pMac, sessionId);
5252#endif
5253 /* This creates problem since we have not saved the connected profile.
5254 So moving this after saving the profile
5255 */
5256 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
Abhishek Singh36abbcb2014-03-20 13:04:09 +05305257
5258 /* Reset remainInPowerActiveTillDHCP as it might have been set
5259 * by last failed secured connection.
5260 * It should be set only for secured connection.
5261 */
5262 pMac->pmc.remainInPowerActiveTillDHCP = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005263 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
5264 {
5265 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
5266 }
5267 else
5268 {
5269 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
5270 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005271 //Use the last connected bssdesc for reassoc-ing to the same AP.
5272 //NOTE: What to do when reassoc to a different AP???
5273 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5274 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5275 {
5276 pSirBssDesc = pSession->pConnectBssDesc;
5277 if(pSirBssDesc)
5278 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305279 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5280 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005281 }
5282 }
5283 else
5284 {
5285
5286 if(pCommand->u.roamCmd.pRoamBssEntry)
5287 {
5288 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
5289 if(pScanResult != NULL)
5290 {
5291 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5292 //this can be NULL
5293 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
Kiet Lam64c1b492013-07-12 13:56:44 +05305294 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5295 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005296 }
5297 }
5298 }
5299 if( pSirBssDesc )
5300 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005301 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07005302 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5303 //Save WPA/RSN IE
5304 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005305#ifdef FEATURE_WLAN_ESE
5306 roamInfo.isESEAssoc = pSession->connectedProfile.isESEAssoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005307#endif
5308
5309 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
5310 // substate change.
5311 // Moving even save profile above so that below mentioned conditon is also met.
5312 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
5313 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005314 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
5315 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
5316 // will be dropped for the security context may not be set properly.
5317 //
5318 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
5319 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
5320 //
5321 // this reordering was done on titan_prod_usb branch and is being replicated here.
5322 //
5323
5324 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
5325 !pProfile->bWPSAssociation)
5326 {
5327 // Issue the set Context request to LIM to establish the Unicast STA context
5328 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
5329 pProfile->negotiatedUCEncryptionType,
5330 pSirBssDesc, &(pSirBssDesc->bssId),
5331 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
5332 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005333 smsLog( pMac, LOGE, FL(" Set context for unicast fail") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005334 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5335 }
5336 // Issue the set Context request to LIM to establish the Broadcast STA context
5337 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
5338 pSirBssDesc, &BroadcastMac,
5339 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5340 }
5341 else
5342 {
5343 //Need to wait for supplicant authtication
5344 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005345 //Set the subestate to WaitForKey in case authentiation is needed
5346 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
5347
Abhishek Singh36abbcb2014-03-20 13:04:09 +05305348 /* Set remainInPowerActiveTillDHCP to make sure we wait for
5349 * until keys are set before going into BMPS.
5350 */
5351 pMac->pmc.remainInPowerActiveTillDHCP = TRUE;
5352
Jeff Johnson295189b2012-06-20 16:38:30 -07005353 if(pProfile->bWPSAssociation)
5354 {
5355 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
5356 }
5357 else
5358 {
5359 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
5360 }
5361
5362 //Save sessionId in case of timeout
5363 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
5364 //This time should be long enough for the rest of the process plus setting key
5365 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
5366 {
5367 //Reset our state so nothting is blocked.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005368 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005369 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
5370 }
5371 }
5372
5373 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
5374 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005375 if(Context)
5376 {
5377 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
5378 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07005379 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5380 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
5381#ifdef WLAN_FEATURE_VOWIFI_11R
5382 len += pJoinRsp->parsedRicRspLen;
5383#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005384#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005385 len += pJoinRsp->tspecIeLen;
5386#endif
5387 if(len)
5388 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305389 pSession->connectedInfo.pbFrames = vos_mem_malloc(len);
5390 if ( pSession->connectedInfo.pbFrames != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07005391 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305392 vos_mem_copy(pSession->connectedInfo.pbFrames,
5393 pJoinRsp->frames, len);
5394 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5395 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5396 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
Jeff Johnson295189b2012-06-20 16:38:30 -07005397#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05305398 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005399#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005400#ifdef FEATURE_WLAN_ESE
Kiet Lam64c1b492013-07-12 13:56:44 +05305401 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005402#endif
Kiet Lam64c1b492013-07-12 13:56:44 +05305403 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5404 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5405 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
5406 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
Jeff Johnson295189b2012-06-20 16:38:30 -07005407 }
5408 }
5409 if(pCommand->u.roamCmd.fReassoc)
5410 {
5411 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5412 }
5413 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5414 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5415 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
5416 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
5417 }
5418 else
5419 {
5420 if(pCommand->u.roamCmd.fReassoc)
5421 {
5422 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5423 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5424 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5425 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5426 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5427 }
5428 }
5429#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5430 // Indicate SME-QOS with reassoc success event, only after
5431 // copying the frames
5432 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
5433#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005434 roamInfo.pBssDesc = pSirBssDesc;
5435 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5436 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5437#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5438 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
5439#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
5440 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005441 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
5442 //It may be better to let QoS do this????
5443 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
5444 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005445 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now",
Jeff Johnson295189b2012-06-20 16:38:30 -07005446 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
5447 pmcStartUapsd( pMac, NULL, NULL );
5448 }
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05305449 pSession->connectedProfile.dot11Mode = pSession->bssParams.uCfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005450 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5451 if( pSession->bRefAssocStartCnt > 0 )
5452 {
5453 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005454 //Remove this code once SLM_Sessionization is supported
5455 //BMPS_WORKAROUND_NOT_NEEDED
5456 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005457 {
5458 pMac->roam.configParam.doBMPSWorkaround = 1;
5459 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005460 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5461 }
5462
5463 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005464 // reset the PMKID candidate list
5465 csrResetPMKIDCandidateList( pMac, sessionId );
5466 //Update TL's AC weight base on the current EDCA parameters
5467 //These parameters may change in the course of the connection, that sictuation
5468 //is not taken care here. This change is mainly to address a WIFI WMM test where
5469 //BE has a equal or higher TX priority than VI.
5470 //We only do this for infra link
5471 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
5472 {
5473 csrCheckAndUpdateACWeight(pMac, pIes);
5474 }
5475#ifdef FEATURE_WLAN_WAPI
5476 // reset the BKID candidate list
5477 csrResetBKIDCandidateList( pMac, sessionId );
5478#endif /* FEATURE_WLAN_WAPI */
5479 }
5480 else
5481 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005482 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc");
Jeff Johnson295189b2012-06-20 16:38:30 -07005483 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005484 csrScanCancelIdleScan(pMac);
5485 //Not to signal link up because keys are yet to be set.
5486 //The linkup function will overwrite the sub-state that we need to keep at this point.
5487 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
5488 {
5489 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
5490 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005491 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
5492 //enough to let security and DHCP handshake succeed before entry into BMPS
5493 if (pmcShouldBmpsTimerRun(pMac))
5494 {
5495 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
5496 != eHAL_STATUS_SUCCESS)
5497 {
5498 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
5499 }
5500 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
5501 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005502 break;
5503
Jeff Johnson295189b2012-06-20 16:38:30 -07005504 case eCsrStartBssSuccess:
5505 // on the StartBss Response, LIM is returning the Bss Description that we
5506 // are beaconing. Add this Bss Description to our scan results and
5507 // chain the Profile to this Bss Description. On a Start BSS, there was no
5508 // detected Bss description (no partner) so we issued the Start Bss to
5509 // start the Ibss without any Bss description. Lim was kind enough to return
5510 // the Bss Description that we start beaconing for the newly started Ibss.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005511 smsLog(pMac, LOG2, FL("receives start BSS ok indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005512 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005513 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
Kiet Lam64c1b492013-07-12 13:56:44 +05305514 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005515 if( CSR_IS_IBSS( pProfile ) )
5516 {
5517 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
5518 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005519 else if (CSR_IS_INFRA_AP(pProfile))
5520 {
5521 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
5522 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005523 else
5524 {
5525 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
5526 }
5527 if( !CSR_IS_WDS_STA( pProfile ) )
5528 {
5529 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005530 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
Jeff Johnson295189b2012-06-20 16:38:30 -07005531 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
5532 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05305533 smsLog(pMac, LOGW, FL("cannot parse IBSS IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005534 roamInfo.pBssDesc = pSirBssDesc;
5535 //We need to associate_complete it first, becasue Associate_start already indicated.
5536 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5537 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
5538 break;
5539 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005540 if (!CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07005541 {
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07005542 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005543 }
5544 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
5545 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5546 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5547 if(pSirBssDesc)
5548 {
5549 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
Kiet Lam64c1b492013-07-12 13:56:44 +05305550 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5551 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005552 }
5553 //We are doen with the IEs so free it
Kiet Lam64c1b492013-07-12 13:56:44 +05305554 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005555#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5556 {
5557 vos_log_ibss_pkt_type *pIbssLog;
5558 tANI_U32 bi;
5559
5560 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5561 if(pIbssLog)
5562 {
5563 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5564 {
5565 //We start the IBSS (didn't find any matched IBSS out there)
5566 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
5567 }
5568 else
5569 {
5570 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
5571 }
5572 if(pSirBssDesc)
5573 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305574 vos_mem_copy(pIbssLog->bssid, pSirBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07005575 pIbssLog->operatingChannel = pSirBssDesc->channelId;
5576 }
5577 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
5578 {
5579 //***U8 is not enough for beacon interval
5580 pIbssLog->beaconInterval = (v_U8_t)bi;
5581 }
5582 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5583 }
5584 }
5585#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5586 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
5587 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07005588 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
5589 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005590 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
5591 csrRoamIssueSetContextReq( pMac, sessionId,
5592 pProfile->negotiatedMCEncryptionType,
5593 pSirBssDesc, &BroadcastMac,
5594 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5595 }
5596 }
5597 else
5598 {
5599 //Keep the state to eCSR_ROAMING_STATE_JOINING
5600 //Need to send join_req.
5601 if(pCommand->u.roamCmd.pRoamBssEntry)
5602 {
5603 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
5604 {
5605 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5606 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
5607 // Set the roaming substate to 'join attempt'...
5608 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08005609 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07005610 }
5611 }
5612 else
5613 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005614 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc" );
Jeff Johnson295189b2012-06-20 16:38:30 -07005615 VOS_ASSERT( 0 );
5616 }
5617 }
5618 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5619 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5620 //trigger the connection start indication in Vista
5621 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
5622 {
5623 roamStatus = eCSR_ROAM_IBSS_IND;
5624 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5625 if( CSR_IS_WDS( pProfile ) )
5626 {
5627 roamStatus = eCSR_ROAM_WDS_IND;
5628 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5629 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005630 if( CSR_IS_INFRA_AP( pProfile ) )
5631 {
5632 roamStatus = eCSR_ROAM_INFRA_IND;
5633 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
5634 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005635
5636 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5637 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5638 //trigger the connection start indication in Vista
Kiet Lam64c1b492013-07-12 13:56:44 +05305639 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005640 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5641 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
krunal soni3fc26642013-10-08 22:41:42 -07005642 //We start the IBSS (didn't find any matched IBSS out there)
5643 roamInfo.pBssDesc = pSirBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005644 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
Kiet Lam64c1b492013-07-12 13:56:44 +05305645 vos_mem_copy(roamInfo.bssid, pSirBssDesc->bssId,
5646 sizeof(tCsrBssid));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005647 //Remove this code once SLM_Sessionization is supported
5648 //BMPS_WORKAROUND_NOT_NEEDED
5649 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07005650 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005651 {
5652 pMac->roam.configParam.doBMPSWorkaround = 1;
5653 }
Mohit Khanna349bc392012-09-11 17:24:52 -07005654
Jeff Johnson295189b2012-06-20 16:38:30 -07005655 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5656 }
5657
5658 csrScanCancelIdleScan(pMac);
Ravi Joshi414b14c2013-10-04 16:33:26 -07005659
5660 if( CSR_IS_WDS_STA( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005661 {
5662 //need to send stop BSS because we fail to send join_req
5663 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
5664 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5665 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
5666 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005667 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005668 case eCsrStartBssFailure:
5669#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5670 {
5671 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07005672 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5673 if(pIbssLog)
5674 {
5675 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
5676 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5677 }
5678 }
5679#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07005680 roamStatus = eCSR_ROAM_IBSS_IND;
5681 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5682 if( CSR_IS_WDS( pProfile ) )
5683 {
5684 roamStatus = eCSR_ROAM_WDS_IND;
5685 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5686 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005687 if( CSR_IS_INFRA_AP( pProfile ) )
5688 {
5689 roamStatus = eCSR_ROAM_INFRA_IND;
5690 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
5691 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005692 if(Context)
5693 {
5694 pSirBssDesc = (tSirBssDescription *)Context;
5695 }
5696 else
5697 {
5698 pSirBssDesc = NULL;
5699 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305700 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005701 roamInfo.pBssDesc = pSirBssDesc;
5702 //We need to associate_complete it first, becasue Associate_start already indicated.
5703 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5704 csrSetDefaultDot11Mode( pMac );
5705 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005706 case eCsrSilentlyStopRoaming:
5707 // We are here because we try to start the same IBSS
5708 //No message to PE
5709 // return the roaming state to Joined.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005710 smsLog(pMac, LOGW, FL("receives silently roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005711 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
5712 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05305713 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005714 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5715 if( roamInfo.pBssDesc )
5716 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305717 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5718 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005719 }
5720 //Since there is no change in the current state, simply pass back no result otherwise
5721 //HDD may be mistakenly mark to disconnected state.
5722 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5723 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005724 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005725 case eCsrSilentlyStopRoamingSaveState:
5726 //We are here because we try to connect to the same AP
5727 //No message to PE
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005728 smsLog(pMac, LOGW, FL("receives silently stop roaming indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305729 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005730
5731 //to aviod resetting the substate to NONE
5732 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
5733 //No need to change substate to wai_for_key because there is no state change
5734 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5735 if( roamInfo.pBssDesc )
5736 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305737 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5738 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005739 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005740 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5741 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5742 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5743 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5744 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5745 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5746 roamInfo.staId = pSession->connectedInfo.staId;
5747 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005748 VOS_ASSERT( roamInfo.staId != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005749 pSession->bRefAssocStartCnt--;
5750 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5751 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5752 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
5753 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005754 case eCsrReassocFailure:
5755#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5756 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
5757#endif
5758 case eCsrJoinWdsFailure:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005759 smsLog(pMac, LOGW, FL("failed to join WDS"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005760 csrFreeConnectBssDesc(pMac, sessionId);
5761 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5762 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
Kiet Lam64c1b492013-07-12 13:56:44 +05305763 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005764 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5765 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5766 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5767 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5768 eCSR_ROAM_WDS_IND,
5769 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
5770 //Need to issue stop_bss
5771 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005772 case eCsrJoinFailure:
5773 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07005774 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07005775 default:
5776 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005777 smsLog(pMac, LOGW, FL("receives no association indication"));
5778 smsLog(pMac, LOG1, FL("Assoc ref count %d"),
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07005779 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07005780 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
5781 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
5782 {
5783 //do not free for the other profiles as we need to send down stop BSS later
5784 csrFreeConnectBssDesc(pMac, sessionId);
5785 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5786 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5787 csrSetDefaultDot11Mode( pMac );
5788 }
5789
5790 switch( pCommand->u.roamCmd.roamReason )
5791 {
5792 // If this transition is because of an 802.11 OID, then we transition
5793 // back to INIT state so we sit waiting for more OIDs to be issued and
5794 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07005795 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07005796 case eCsrSmeIssuedAssocToSimilarAP:
5797 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08005798 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07005799 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05305800 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005801 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5802 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5803 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Kiet Lam64c1b492013-07-12 13:56:44 +05305804 vos_mem_copy(&roamInfo.bssid,
5805 &pSession->joinFailStatusCode.bssId,
5806 sizeof(tCsrBssid));
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005807
Jeff Johnson295189b2012-06-20 16:38:30 -07005808 /* Defeaturize this later if needed */
5809#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5810 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
5811 if (csrRoamIsHandoffInProgress(pMac))
5812 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005813 /* Should indicate neighbor roam algorithm about the connect failure here */
5814 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
5815 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005816#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005817 if(pSession->bRefAssocStartCnt > 0)
5818 {
5819 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07005820 if(eCsrJoinFailureDueToConcurrency == Result)
5821 {
5822 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5823 eCSR_ROAM_ASSOCIATION_COMPLETION,
5824 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
5825 }
5826 else
5827 {
5828 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005829 eCSR_ROAM_ASSOCIATION_COMPLETION,
5830 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07005831 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005832 }
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005833 else
5834 {
5835 /* bRefAssocStartCnt is not incremented when
5836 * eRoamState == eCsrStopRoamingDueToConcurrency
5837 * in csrRoamJoinNextBss API. so handle this in
5838 * else case by sending assoc failure
5839 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005840 csrRoamCallCallback(pMac, sessionId, &roamInfo,
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005841 pCommand->u.scanCmd.roamId,
5842 eCSR_ROAM_ASSOCIATION_FAILURE,
5843 eCSR_ROAM_RESULT_FAILURE);
5844 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005845 smsLog(pMac, LOG1, FL(" roam(reason %d) failed"), pCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07005846#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Mukul Sharma5960ac82014-01-09 20:31:35 +05305847 sme_QosUpdateHandOff((tANI_U8)sessionId, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005848 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5849#endif
5850 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5851 csrScanStartIdleScan(pMac);
5852#ifdef FEATURE_WLAN_BTAMP_UT_RF
5853 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
5854 //BT activity and not able to recevie WLAN traffic. Retry the join
5855 if( CSR_IS_WDS_STA(pProfile) )
5856 {
5857 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
5858 }
5859#endif
5860 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005861 case eCsrHddIssuedReassocToSameAP:
5862 case eCsrSmeIssuedReassocToSameAP:
5863 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5864
5865 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5866#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5867 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5868#endif
5869 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5870 csrScanStartIdleScan(pMac);
5871 break;
5872 case eCsrForcedDisassoc:
5873 case eCsrForcedDeauth:
5874 case eCsrSmeIssuedIbssJoinFailure:
5875 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5876
5877 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
5878 {
5879 // Notify HDD that IBSS join failed
5880 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
5881 }
5882 else
5883 {
5884 csrRoamCallCallback(pMac, sessionId, NULL,
5885 pCommand->u.roamCmd.roamId,
5886 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5887 }
5888#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5889 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5890#endif
5891 csrRoamLinkDown(pMac, sessionId);
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08005892 /*
5893 *DelSta not done FW still in conneced state so dont
5894 *issue IMPS req
5895 */
5896 if (pMac->roam.deauthRspStatus == eSIR_SME_DEAUTH_STATUS)
5897 {
5898 smsLog(pMac, LOGW, FL("FW still in connected state "));
5899 break;
5900 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005901 csrScanStartIdleScan(pMac);
5902 break;
5903 case eCsrForcedIbssLeave:
5904 csrRoamCallCallback(pMac, sessionId, NULL,
5905 pCommand->u.roamCmd.roamId,
5906 eCSR_ROAM_IBSS_LEAVE,
5907 eCSR_ROAM_RESULT_IBSS_STOP);
5908 break;
5909 case eCsrForcedDisassocMICFailure:
5910 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5911
5912 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
5913#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5914 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
5915#endif
5916 csrScanStartIdleScan(pMac);
5917 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005918 case eCsrStopBss:
5919 csrRoamCallCallback(pMac, sessionId, NULL,
5920 pCommand->u.roamCmd.roamId,
5921 eCSR_ROAM_INFRA_IND,
5922 eCSR_ROAM_RESULT_INFRA_STOPPED);
5923 break;
5924 case eCsrForcedDisassocSta:
5925 case eCsrForcedDeauthSta:
5926 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
5927 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
5928 {
5929 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005930
5931 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
5932 {
5933 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05305934 vos_mem_copy(roamInfo.peerMac,
5935 pCommand->u.roamCmd.peerMac,
5936 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07005937 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
5938 roamInfo.statusCode = eSIR_SME_SUCCESS;
5939 status = csrRoamCallCallback(pMac, sessionId,
5940 &roamInfo, pCommand->u.roamCmd.roamId,
5941 eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
5942 }
5943 }
5944 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005945 case eCsrLostLink1:
5946 // if lost link roam1 failed, then issue lost link Scan2 ...
5947 csrScanRequestLostLink2(pMac, sessionId);
5948 break;
5949 case eCsrLostLink2:
5950 // if lost link roam2 failed, then issue lost link scan3 ...
5951 csrScanRequestLostLink3(pMac, sessionId);
5952 break;
5953 case eCsrLostLink3:
5954 default:
5955 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5956
5957 //We are done with one round of lostlink roaming here
5958 csrScanHandleFailedLostlink3(pMac, sessionId);
5959 break;
5960 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005961 break;
5962 }
5963 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005964 return ( fReleaseCommand );
5965}
5966
Jeff Johnson295189b2012-06-20 16:38:30 -07005967eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
5968{
5969 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005970 return (status);
5971}
5972
Jeff Johnson295189b2012-06-20 16:38:30 -07005973eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
5974{
5975 eHalStatus status = eHAL_STATUS_SUCCESS;
5976 tANI_U32 size = 0;
5977
5978 do
5979 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305980 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005981 if(pSrcProfile->BSSIDs.numOfBSSIDs)
5982 {
5983 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05305984 pDstProfile->BSSIDs.bssid = vos_mem_malloc(size);
5985 if ( NULL == pDstProfile->BSSIDs.bssid )
5986 status = eHAL_STATUS_FAILURE;
5987 else
5988 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005989 if(!HAL_STATUS_SUCCESS(status))
5990 {
5991 break;
5992 }
5993 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05305994 vos_mem_copy(pDstProfile->BSSIDs.bssid,
5995 pSrcProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07005996 }
5997 if(pSrcProfile->SSIDs.numOfSSIDs)
5998 {
5999 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306000 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(size);
6001 if ( NULL == pDstProfile->SSIDs.SSIDList )
6002 status = eHAL_STATUS_FAILURE;
6003 else
6004 status = eHAL_STATUS_SUCCESS;
6005 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006006 {
6007 break;
6008 }
6009 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306010 vos_mem_copy(pDstProfile->SSIDs.SSIDList,
6011 pSrcProfile->SSIDs.SSIDList, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07006012 }
6013 if(pSrcProfile->nWPAReqIELength)
6014 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306015 pDstProfile->pWPAReqIE = vos_mem_malloc(pSrcProfile->nWPAReqIELength);
6016 if ( NULL == pDstProfile->pWPAReqIE )
6017 status = eHAL_STATUS_FAILURE;
6018 else
6019 status = eHAL_STATUS_SUCCESS;
6020
6021 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006022 {
6023 break;
6024 }
6025 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306026 vos_mem_copy(pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE,
6027 pSrcProfile->nWPAReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006028 }
6029 if(pSrcProfile->nRSNReqIELength)
6030 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306031 pDstProfile->pRSNReqIE = vos_mem_malloc(pSrcProfile->nRSNReqIELength);
6032 if ( NULL == pDstProfile->pRSNReqIE )
6033 status = eHAL_STATUS_FAILURE;
6034 else
6035 status = eHAL_STATUS_SUCCESS;
6036
6037 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006038 {
6039 break;
6040 }
6041 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306042 vos_mem_copy(pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE,
6043 pSrcProfile->nRSNReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006044 }
6045#ifdef FEATURE_WLAN_WAPI
6046 if(pSrcProfile->nWAPIReqIELength)
6047 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306048 pDstProfile->pWAPIReqIE = vos_mem_malloc(pSrcProfile->nWAPIReqIELength);
6049 if ( NULL == pDstProfile->pWAPIReqIE )
6050 status = eHAL_STATUS_FAILURE;
6051 else
6052 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006053 if(!HAL_STATUS_SUCCESS(status))
6054 {
6055 break;
6056 }
6057 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306058 vos_mem_copy(pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE,
6059 pSrcProfile->nWAPIReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006060 }
6061#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07006062 if(pSrcProfile->nAddIEScanLength)
6063 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05306064 memset(pDstProfile->addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH);
6065 if ( SIR_MAC_MAX_IE_LENGTH >= pSrcProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -07006066 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05306067 vos_mem_copy(pDstProfile->addIEScan, pSrcProfile->addIEScan,
Kiet Lam64c1b492013-07-12 13:56:44 +05306068 pSrcProfile->nAddIEScanLength);
Agarwal Ashish4f616132013-12-30 23:32:50 +05306069 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
6070 }
6071 else
6072 {
6073 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
6074 FL(" AddIEScanLength is not valid %u"),
6075 pSrcProfile->nAddIEScanLength);
6076 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006077 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006078 if(pSrcProfile->nAddIEAssocLength)
6079 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306080 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6081 if ( NULL == pDstProfile->pAddIEAssoc )
6082 status = eHAL_STATUS_FAILURE;
6083 else
6084 status = eHAL_STATUS_SUCCESS;
6085
Jeff Johnson295189b2012-06-20 16:38:30 -07006086 if(!HAL_STATUS_SUCCESS(status))
6087 {
6088 break;
6089 }
6090 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306091 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6092 pSrcProfile->nAddIEAssocLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006093 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006094 if(pSrcProfile->ChannelInfo.ChannelList)
6095 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306096 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(
6097 pSrcProfile->ChannelInfo.numOfChannels);
6098 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6099 status = eHAL_STATUS_FAILURE;
6100 else
6101 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006102 if(!HAL_STATUS_SUCCESS(status))
6103 {
6104 break;
6105 }
6106 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
Kiet Lam64c1b492013-07-12 13:56:44 +05306107 vos_mem_copy(pDstProfile->ChannelInfo.ChannelList,
6108 pSrcProfile->ChannelInfo.ChannelList,
6109 pSrcProfile->ChannelInfo.numOfChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07006110 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006111 pDstProfile->AuthType = pSrcProfile->AuthType;
6112 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
6113 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
6114 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
6115 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
6116 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
Chet Lanctot186b5732013-03-18 10:26:30 -07006117#ifdef WLAN_FEATURE_11W
6118 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
6119 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
6120 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
6121#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006122 pDstProfile->BSSType = pSrcProfile->BSSType;
6123 pDstProfile->phyMode = pSrcProfile->phyMode;
6124 pDstProfile->csrPersona = pSrcProfile->csrPersona;
6125
6126#ifdef FEATURE_WLAN_WAPI
6127 if(csrIsProfileWapi(pSrcProfile))
6128 {
6129 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
6130 {
6131 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
6132 }
6133 }
6134#endif /* FEATURE_WLAN_WAPI */
6135 pDstProfile->CBMode = pSrcProfile->CBMode;
6136 /*Save the WPS info*/
6137 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006138 pDstProfile->bOSENAssociation = pSrcProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07006139 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006140 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07006141 pDstProfile->privacy = pSrcProfile->privacy;
6142 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
6143 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
6144 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
6145 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
6146 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
6147 pDstProfile->protEnabled = pSrcProfile->protEnabled;
6148 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
6149 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
6150 pDstProfile->wps_state = pSrcProfile->wps_state;
6151 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
Kiet Lam64c1b492013-07-12 13:56:44 +05306152 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6153 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006154#ifdef WLAN_FEATURE_VOWIFI_11R
6155 if (pSrcProfile->MDID.mdiePresent)
6156 {
6157 pDstProfile->MDID.mdiePresent = 1;
6158 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6159 }
6160#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006161 }while(0);
6162
6163 if(!HAL_STATUS_SUCCESS(status))
6164 {
6165 csrReleaseProfile(pMac, pDstProfile);
6166 pDstProfile = NULL;
6167 }
6168
6169 return (status);
6170}
Jeff Johnson295189b2012-06-20 16:38:30 -07006171eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
6172{
6173 eHalStatus status = eHAL_STATUS_SUCCESS;
6174 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
6175 do
6176 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306177 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006178 if(pSrcProfile->bssid)
6179 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306180 pDstProfile->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
6181 if ( NULL == pDstProfile->BSSIDs.bssid )
6182 status = eHAL_STATUS_FAILURE;
6183 else
6184 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006185 if(!HAL_STATUS_SUCCESS(status))
6186 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306187 smsLog( pMac, LOGE,
6188 FL("failed to allocate memory for BSSID"
6189 "%02x:%02x:%02x:%02x:%02x:%02x"),
6190 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6191 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006192 break;
6193 }
6194 pDstProfile->BSSIDs.numOfBSSIDs = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05306195 vos_mem_copy(pDstProfile->BSSIDs.bssid, pSrcProfile->bssid,
6196 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006197 }
6198 if(pSrcProfile->SSID.ssId)
6199 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306200 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
6201 if ( NULL == pDstProfile->SSIDs.SSIDList )
6202 status = eHAL_STATUS_FAILURE;
6203 else
6204 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006205 if(!HAL_STATUS_SUCCESS(status))
6206 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306207 smsLog( pMac, LOGE,
6208 FL("failed to allocate memory for SSIDList"
6209 "%02x:%02x:%02x:%02x:%02x:%02x"),
6210 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6211 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006212 break;
6213 }
6214 pDstProfile->SSIDs.numOfSSIDs = 1;
6215 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
6216 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
Kiet Lam64c1b492013-07-12 13:56:44 +05306217 vos_mem_copy(&pDstProfile->SSIDs.SSIDList[0].SSID,
6218 &pSrcProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006219 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006220 if(pSrcProfile->nAddIEAssocLength)
6221 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306222 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6223 if ( NULL == pDstProfile->pAddIEAssoc)
6224 status = eHAL_STATUS_FAILURE;
6225 else
6226 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006227 if(!HAL_STATUS_SUCCESS(status))
6228 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006229 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs ") );
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006230 break;
6231 }
6232 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306233 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6234 pSrcProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006235 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306236 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(1);
6237 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6238 status = eHAL_STATUS_FAILURE;
6239 else
6240 status = eHAL_STATUS_SUCCESS;
6241
Jeff Johnson295189b2012-06-20 16:38:30 -07006242 if(!HAL_STATUS_SUCCESS(status))
6243 {
6244 break;
6245 }
6246 pDstProfile->ChannelInfo.numOfChannels = 1;
6247 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006248 pDstProfile->AuthType.numEntries = 1;
6249 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
6250 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
6251 pDstProfile->EncryptionType.numEntries = 1;
6252 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
6253 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
6254 pDstProfile->mcEncryptionType.numEntries = 1;
6255 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
6256 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
6257 pDstProfile->BSSType = pSrcProfile->BSSType;
6258 pDstProfile->CBMode = pSrcProfile->CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +05306259 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6260 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006261#ifdef WLAN_FEATURE_VOWIFI_11R
6262 if (pSrcProfile->MDID.mdiePresent)
6263 {
6264 pDstProfile->MDID.mdiePresent = 1;
6265 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6266 }
6267#endif
6268
6269 }while(0);
6270
6271 if(!HAL_STATUS_SUCCESS(status))
6272 {
6273 csrReleaseProfile(pMac, pDstProfile);
6274 pDstProfile = NULL;
6275 }
6276
6277 return (status);
6278}
6279
Jeff Johnson295189b2012-06-20 16:38:30 -07006280eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6281 tScanResultHandle hBSSList,
6282 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
6283 tANI_BOOLEAN fClearScan)
6284{
6285 eHalStatus status = eHAL_STATUS_SUCCESS;
6286 tSmeCmd *pCommand;
6287
6288 pCommand = csrGetCommandBuffer(pMac);
6289 if(NULL == pCommand)
6290 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006291 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006292 status = eHAL_STATUS_RESOURCES;
6293 }
6294 else
6295 {
6296 if( fClearScan )
6297 {
6298 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306299 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006300 }
6301 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6302 if(NULL == pProfile)
6303 {
6304 //We can roam now
6305 //Since pProfile is NULL, we need to build our own profile, set everything to default
6306 //We can only support open and no encryption
6307 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
6308 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
6309 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
6310 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6311 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
6312 }
6313 else
6314 {
6315 //make a copy of the profile
6316 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6317 if(HAL_STATUS_SUCCESS(status))
6318 {
6319 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6320 }
6321 }
6322 pCommand->command = eSmeCommandRoam;
6323 pCommand->sessionId = (tANI_U8)sessionId;
6324 pCommand->u.roamCmd.hBSSList = hBSSList;
6325 pCommand->u.roamCmd.roamId = roamId;
6326 pCommand->u.roamCmd.roamReason = reason;
6327 //We need to free the BssList when the command is done
6328 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
6329 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006330 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6331 FL("CSR PERSONA=%d"),
6332 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07006333 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6334 if( !HAL_STATUS_SUCCESS( status ) )
6335 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006336 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006337 csrReleaseCommandRoam( pMac, pCommand );
6338 }
6339 }
6340
6341 return (status);
6342}
Jeff Johnson295189b2012-06-20 16:38:30 -07006343eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6344 tCsrRoamModifyProfileFields *pMmodProfileFields,
6345 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
6346{
6347 eHalStatus status = eHAL_STATUS_SUCCESS;
6348 tSmeCmd *pCommand;
6349
6350 pCommand = csrGetCommandBuffer(pMac);
6351 if(NULL == pCommand)
6352 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006353 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006354 status = eHAL_STATUS_RESOURCES;
6355 }
6356 else
6357 {
6358 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306359 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006360 if(pProfile)
6361 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006362 //This is likely trying to reassoc to different profile
6363 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6364 //make a copy of the profile
6365 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6366 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006367 }
6368 else
6369 {
6370 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
6371 //how to update WPA/WPA2 info in roamProfile??
6372 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006373 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006374 if(HAL_STATUS_SUCCESS(status))
6375 {
6376 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6377 }
6378 pCommand->command = eSmeCommandRoam;
6379 pCommand->sessionId = (tANI_U8)sessionId;
6380 pCommand->u.roamCmd.roamId = roamId;
6381 pCommand->u.roamCmd.roamReason = reason;
6382 //We need to free the BssList when the command is done
6383 //For reassoc there is no BSS list, so the boolean set to false
6384 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
6385 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
6386 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006387 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6388 if( !HAL_STATUS_SUCCESS( status ) )
6389 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006390 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006391 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6392 csrReleaseCommandRoam( pMac, pCommand );
6393 }
6394 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006395 return (status);
6396}
6397
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006398eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
6399 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306400// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006401{
6402 eHalStatus status = eHAL_STATUS_SUCCESS;
6403 tSmeCmd *pCommand;
6404
6405 pCommand = csrGetCommandBuffer(pMac);
6406 if(NULL == pCommand)
6407 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006408 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006409 status = eHAL_STATUS_RESOURCES;
6410 }
6411 else
6412 {
6413 if(pBssDescription)
6414 {
6415 //copy over the parameters we need later
6416 pCommand->command = eSmeCommandRoam;
6417 pCommand->sessionId = (tANI_U8)sessionId;
6418 pCommand->u.roamCmd.roamReason = reason;
6419 //this is the important parameter
6420 //in this case we are using this field for the "next" BSS
6421 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
6422 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
6423 if( !HAL_STATUS_SUCCESS( status ) )
6424 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006425 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d"), status );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006426 csrReleaseCommandPreauth( pMac, pCommand );
6427 }
6428 }
6429 else
6430 {
6431 //Return failure
6432 status = eHAL_STATUS_RESOURCES;
6433 }
6434 }
6435 return (status);
6436}
6437
6438eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
6439{
6440 tListElem *pEntry;
6441 tSmeCmd *pCommand;
6442 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6443 if ( pEntry )
6444 {
6445 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6446 if ( (eSmeCommandRoam == pCommand->command) &&
6447 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
6448 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006449 smsLog( pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006450 pCommand->command, pCommand->u.roamCmd.roamReason);
6451 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
6452 csrReleaseCommandPreauth( pMac, pCommand );
6453 }
6454 } else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006455 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d "),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006456 pCommand->command, pCommand->u.roamCmd.roamReason);
6457 }
6458 }
6459 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006460 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006461 }
6462 smeProcessPendingQueue( pMac );
6463 return eHAL_STATUS_SUCCESS;
6464}
6465
Jeff Johnson295189b2012-06-20 16:38:30 -07006466eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6467 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6468{
6469 eHalStatus status = eHAL_STATUS_FAILURE;
6470 tScanResultHandle hBSSList;
6471 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006472 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
6473 if(HAL_STATUS_SUCCESS(status))
6474 {
6475 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6476 if(pRoamId)
6477 {
6478 *pRoamId = roamId;
6479 }
6480 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6481 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6482 if(!HAL_STATUS_SUCCESS(status))
6483 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006484 smsLog(pMac, LOGE, FL("failed to start a join process"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006485 csrScanResultPurge(pMac, hBSSList);
6486 }
6487 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006488 return (status);
6489}
6490
Jeff Johnson295189b2012-06-20 16:38:30 -07006491eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6492 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6493{
6494 eHalStatus status = eHAL_STATUS_SUCCESS;
6495 tScanResultHandle hBSSList;
6496 tCsrScanResultFilter *pScanFilter;
6497 tANI_U32 roamId = 0;
6498 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
6499 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006500 if (NULL == pProfile)
6501 {
6502 smsLog(pMac, LOGP, FL("No profile specified"));
6503 return eHAL_STATUS_FAILURE;
6504 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006505 smsLog(pMac, LOG1, FL("called BSSType = %d authtype = %d encryType = %d"),
Jeff Johnson295189b2012-06-20 16:38:30 -07006506 pProfile->BSSType, pProfile->AuthType.authType[0], pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006507 if( CSR_IS_WDS( pProfile ) &&
6508 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
6509 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006510 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d"),
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006511 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006512 return status;
6513 }
6514 csrRoamCancelRoaming(pMac, sessionId);
6515 csrScanRemoveFreshScanCommand(pMac, sessionId);
6516 csrScanCancelIdleScan(pMac);
6517 //Only abort the scan if it is not used for other roam/connect purpose
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05306518 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Jeff Johnson295189b2012-06-20 16:38:30 -07006519 if (!vos_concurrent_sessions_running() && (VOS_STA_SAP_MODE == pProfile->csrPersona))//In case of AP mode we do not want idle mode scan
6520 {
6521 csrScanDisable(pMac);
6522 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006523 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6524 //Check whether ssid changes
6525 if(csrIsConnStateConnected(pMac, sessionId))
6526 {
6527 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6528 {
6529 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6530 }
6531 }
6532#ifdef FEATURE_WLAN_BTAMP_UT_RF
6533 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
6534#endif
6535 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
6536 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006537 smsLog(pMac, LOG1, FL("is called with BSSList"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006538 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
6539 if(pRoamId)
6540 {
6541 roamId = *pRoamId;
6542 }
6543 if(!HAL_STATUS_SUCCESS(status))
6544 {
6545 fCallCallback = eANI_BOOLEAN_TRUE;
6546 }
6547 }
6548 else
6549 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306550 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
6551 if ( NULL == pScanFilter )
6552 status = eHAL_STATUS_FAILURE;
6553 else
6554 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006555 if(HAL_STATUS_SUCCESS(status))
6556 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306557 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006558 //Try to connect to any BSS
6559 if(NULL == pProfile)
6560 {
6561 //No encryption
6562 pScanFilter->EncryptionType.numEntries = 1;
6563 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6564 }//we don't have a profile
6565 else
6566 {
6567 //Here is the profile we need to connect to
6568 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6569 }//We have a profile
6570 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6571 if(pRoamId)
6572 {
6573 *pRoamId = roamId;
6574 }
6575
6576 if(HAL_STATUS_SUCCESS(status))
6577 {
6578 /*Save the WPS info*/
6579 if(NULL != pProfile)
6580 {
6581 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006582 pScanFilter->bOSENAssociation = pProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07006583 }
6584 else
6585 {
6586 pScanFilter->bWPSAssociation = 0;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006587 pScanFilter->bOSENAssociation = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006588 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006589 do
6590 {
6591 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006592 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006593 )
6594 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006595 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07006596 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6597 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6598 if(!HAL_STATUS_SUCCESS(status))
6599 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006600 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006601 fCallCallback = eANI_BOOLEAN_TRUE;
6602 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006603 else
6604 {
6605 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
6606 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006607 break;
6608 }
6609 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006610 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006611 if(HAL_STATUS_SUCCESS(status))
6612 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006613 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6614 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6615 if(!HAL_STATUS_SUCCESS(status))
6616 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006617 smsLog(pMac, LOGE, FL(" CSR failed to issue connect command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006618 csrScanResultPurge(pMac, hBSSList);
6619 fCallCallback = eANI_BOOLEAN_TRUE;
6620 }
6621 }//Have scan result
6622 else if(NULL != pProfile)
6623 {
6624 //Check whether it is for start ibss
6625 if(CSR_IS_START_IBSS(pProfile))
6626 {
6627 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6628 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6629 if(!HAL_STATUS_SUCCESS(status))
6630 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006631 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006632 fCallCallback = eANI_BOOLEAN_TRUE;
6633 }
6634 }
6635 else
6636 {
6637 //scan for this SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006638 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006639 if(!HAL_STATUS_SUCCESS(status))
6640 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006641 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006642 fCallCallback = eANI_BOOLEAN_TRUE;
6643 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006644 else
6645 {
6646 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
6647 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006648 }
6649 }
6650 else
6651 {
6652 fCallCallback = eANI_BOOLEAN_TRUE;
6653 }
6654 } while (0);
6655 if(NULL != pProfile)
6656 {
6657 //we need to free memory for filter if profile exists
6658 csrFreeScanFilter(pMac, pScanFilter);
6659 }
6660 }//Got the scan filter from profile
6661
Kiet Lam64c1b492013-07-12 13:56:44 +05306662 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006663 }//allocated memory for pScanFilter
6664 }//No Bsslist coming in
6665 //tell the caller if we fail to trigger a join request
6666 if( fCallCallback )
6667 {
6668 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6669 }
6670
6671 return (status);
6672}
Jeff Johnson295189b2012-06-20 16:38:30 -07006673eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6674 tCsrRoamModifyProfileFields modProfileFields,
6675 tANI_U32 *pRoamId)
6676{
6677 eHalStatus status = eHAL_STATUS_SUCCESS;
6678 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
6679 tANI_U32 roamId = 0;
6680 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006681 if (NULL == pProfile)
6682 {
6683 smsLog(pMac, LOGP, FL("No profile specified"));
6684 return eHAL_STATUS_FAILURE;
6685 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006686 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 -07006687 csrRoamCancelRoaming(pMac, sessionId);
6688 csrScanRemoveFreshScanCommand(pMac, sessionId);
6689 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306690 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006691 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07006692 if(csrIsConnStateConnected(pMac, sessionId))
6693 {
6694 if(pProfile)
6695 {
6696 if(pProfile->SSIDs.numOfSSIDs &&
6697 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6698 {
6699 fCallCallback = eANI_BOOLEAN_FALSE;
6700 }
6701 else
6702 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006703 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006704 }
6705 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306706 else if (!vos_mem_compare(&modProfileFields,
6707 &pSession->connectedProfile.modifyProfileFields,
6708 sizeof(tCsrRoamModifyProfileFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -07006709 {
6710 fCallCallback = eANI_BOOLEAN_FALSE;
6711 }
6712 else
6713 {
6714 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006715 "in tCsrRoamModifyProfileFields got modified"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006716 }
6717 }
6718 else
6719 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006720 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006721 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006722 if(!fCallCallback)
6723 {
6724 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6725 if(pRoamId)
6726 {
6727 *pRoamId = roamId;
6728 }
6729
Jeff Johnson295189b2012-06-20 16:38:30 -07006730 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
6731 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006732 }
6733 else
6734 {
6735 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
6736 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6737 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006738 return status;
6739}
Jeff Johnson295189b2012-06-20 16:38:30 -07006740eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6741{
6742 eHalStatus status = eHAL_STATUS_FAILURE;
6743 tScanResultHandle hBSSList = NULL;
6744 tCsrScanResultFilter *pScanFilter = NULL;
6745 tANI_U32 roamId;
6746 tCsrRoamProfile *pProfile = NULL;
6747 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006748
6749 if(!pSession)
6750 {
6751 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6752 return eHAL_STATUS_FAILURE;
6753 }
6754
Jeff Johnson295189b2012-06-20 16:38:30 -07006755 do
6756 {
6757 if(pSession->pCurRoamProfile)
6758 {
6759 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306760 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006761 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
Kiet Lam64c1b492013-07-12 13:56:44 +05306762 pProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
6763 if ( NULL == pProfile )
6764 status = eHAL_STATUS_FAILURE;
6765 else
6766 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006767 if(!HAL_STATUS_SUCCESS(status))
6768 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05306769 vos_mem_set(pProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006770 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05306771 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006772 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05306773 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
6774 if ( NULL == pScanFilter )
6775 status = eHAL_STATUS_FAILURE;
6776 else
6777 status = eHAL_STATUS_SUCCESS;
6778
Jeff Johnson295189b2012-06-20 16:38:30 -07006779 if(!HAL_STATUS_SUCCESS(status))
6780 {
6781 break;
6782 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306783 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006784 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6785 if(!HAL_STATUS_SUCCESS(status))
6786 {
6787 break;
6788 }
6789 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6790 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
6791 if(HAL_STATUS_SUCCESS(status))
6792 {
6793 //we want to put the last connected BSS to the very beginning, if possible
6794 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
6795 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6796 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6797 if(!HAL_STATUS_SUCCESS(status))
6798 {
6799 csrScanResultPurge(pMac, hBSSList);
6800 break;
6801 }
6802 }
6803 else
6804 {
6805 //Do a scan on this profile
6806 //scan for this SSID only in case the AP suppresses SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006807 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006808 if(!HAL_STATUS_SUCCESS(status))
6809 {
6810 break;
6811 }
6812 }
6813 }//We have a profile
6814 else
6815 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006816 smsLog(pMac, LOGW, FL("cannot find a roaming profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006817 break;
6818 }
6819 }while(0);
6820 if(pScanFilter)
6821 {
6822 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05306823 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006824 }
6825 if(NULL != pProfile)
6826 {
6827 csrReleaseProfile(pMac, pProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05306828 vos_mem_free(pProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07006829 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006830 return (status);
6831}
Jeff Johnson295189b2012-06-20 16:38:30 -07006832eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
6833{
6834 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006835 if(csrIsConnStateConnected(pMac, sessionId))
6836 {
6837 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6838 if(HAL_STATUS_SUCCESS(status))
6839 {
6840 status = csrRoamJoinLastProfile(pMac, sessionId);
6841 }
6842 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006843 return (status);
6844}
6845
Jeff Johnson295189b2012-06-20 16:38:30 -07006846eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6847{
6848 eHalStatus status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006849 smsLog(pMac, LOGW, FL("is called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006850 csrRoamCancelRoaming(pMac, sessionId);
6851 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6852 if(csrIsConnStateDisconnected(pMac, sessionId))
6853 {
6854 status = csrRoamJoinLastProfile(pMac, sessionId);
6855 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006856 return (status);
6857}
6858
Jeff Johnson295189b2012-06-20 16:38:30 -07006859eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
6860{
6861 eHalStatus status = eHAL_STATUS_SUCCESS;
6862 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
6863 eCsrRoamSubState NewSubstate;
6864 tANI_U32 sessionId = pCommand->sessionId;
6865
6866 // change state to 'Roaming'...
6867 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
6868
6869 if ( csrIsConnStateIbss( pMac, sessionId ) )
6870 {
6871 // If we are in an IBSS, then stop the IBSS...
6872 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6873 fComplete = (!HAL_STATUS_SUCCESS(status));
6874 }
6875 else if ( csrIsConnStateInfra( pMac, sessionId ) )
6876 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006877 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 -07006878 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
6879 //Restore AC weight in case we change it
6880 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
6881 // in Infrasturcture, we need to disassociate from the Infrastructure network...
6882 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
6883 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
6884 {
6885 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
6886 }
Abhishek Singhcf4590b2014-04-16 18:58:08 +05306887 else
6888 {
6889 // If we are in neighbor preauth done state then on receiving
6890 // disassoc or deauth we dont roam instead we just disassoc
6891 // from current ap and then go to disconnected state
6892 // This happens for ESE and 11r FT connections ONLY.
6893#ifdef WLAN_FEATURE_VOWIFI_11R
6894 if (csrRoamIs11rAssoc(pMac) &&
6895 (csrNeighborRoamStatePreauthDone(pMac)))
6896 {
6897 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
6898 }
6899#endif
6900#ifdef FEATURE_WLAN_ESE
6901 if (csrRoamIsESEAssoc(pMac) &&
6902 (csrNeighborRoamStatePreauthDone(pMac)))
6903 {
6904 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
6905 }
6906#endif
6907#ifdef FEATURE_WLAN_LFR
6908 if (csrRoamIsFastRoamEnabled(pMac, sessionId) &&
6909 (csrNeighborRoamStatePreauthDone(pMac)))
6910 {
6911 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
6912 }
6913#endif
6914 }
6915
Jeff Johnson295189b2012-06-20 16:38:30 -07006916 if( fDisassoc )
6917 {
6918 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
6919 }
6920 else
6921 {
6922 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
6923 }
6924 fComplete = (!HAL_STATUS_SUCCESS(status));
6925 }
6926 else if ( csrIsConnStateWds( pMac, sessionId ) )
6927 {
6928 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
6929 {
6930 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6931 fComplete = (!HAL_STATUS_SUCCESS(status));
6932 }
6933 //This has to be WDS station
6934 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
6935 {
6936
6937 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
6938 if( fDisassoc )
6939 {
6940 status = csrRoamIssueDisassociate( pMac, sessionId,
6941 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
6942 fComplete = (!HAL_STATUS_SUCCESS(status));
6943 }
6944 }
6945 } else {
6946 // we got a dis-assoc request while not connected to any peer
6947 // just complete the command
6948 fComplete = eANI_BOOLEAN_TRUE;
6949 status = eHAL_STATUS_FAILURE;
6950 }
6951 if(fComplete)
6952 {
6953 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6954 }
6955
6956 if(HAL_STATUS_SUCCESS(status))
6957 {
6958 if ( csrIsConnStateInfra( pMac, sessionId ) )
6959 {
6960 //Set the state to disconnect here
6961 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
6962 }
6963 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006964 else
6965 {
6966 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
6967 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006968 return (status);
6969}
6970
Jeff Johnson295189b2012-06-20 16:38:30 -07006971/* This is been removed from latest code base */
6972/*
6973static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
6974{
6975 eHalStatus status;
6976 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07006977 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
6978 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006979 return ( status );
6980}
6981*/
6982
Jeff Johnson295189b2012-06-20 16:38:30 -07006983eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
6984{
6985 eHalStatus status = eHAL_STATUS_SUCCESS;
6986 tSmeCmd *pCommand;
6987 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006988 do
6989 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006990 smsLog( pMac, LOG1, FL(" reason = %d"), reason );
Jeff Johnson295189b2012-06-20 16:38:30 -07006991 pCommand = csrGetCommandBuffer( pMac );
6992 if ( !pCommand )
6993 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006994 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006995 status = eHAL_STATUS_RESOURCES;
6996 break;
6997 }
6998 //Change the substate in case it is wait-for-key
6999 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7000 {
7001 csrRoamStopWaitForKeyTimer( pMac );
7002 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7003 }
7004 pCommand->command = eSmeCommandRoam;
7005 pCommand->sessionId = (tANI_U8)sessionId;
7006 switch ( reason )
7007 {
7008 case eCSR_DISCONNECT_REASON_MIC_ERROR:
7009 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
7010 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007011 case eCSR_DISCONNECT_REASON_DEAUTH:
7012 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
7013 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007014 case eCSR_DISCONNECT_REASON_HANDOFF:
7015 fHighPriority = eANI_BOOLEAN_TRUE;
7016 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
7017 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007018 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
7019 case eCSR_DISCONNECT_REASON_DISASSOC:
7020 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
7021 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007022 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
7023 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
7024 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007025 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
7026 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
7027 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007028 default:
7029 break;
7030 }
7031 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7032 if( !HAL_STATUS_SUCCESS( status ) )
7033 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007034 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007035 csrReleaseCommandRoam( pMac, pCommand );
7036 }
7037 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07007038 return( status );
7039}
7040
Jeff Johnson295189b2012-06-20 16:38:30 -07007041eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
7042{
7043 eHalStatus status = eHAL_STATUS_SUCCESS;
7044 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007045 pCommand = csrGetCommandBuffer( pMac );
7046 if ( NULL != pCommand )
7047 {
7048 //Change the substate in case it is wait-for-key
7049 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
7050 {
7051 csrRoamStopWaitForKeyTimer( pMac );
7052 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7053 }
7054 pCommand->command = eSmeCommandRoam;
7055 pCommand->sessionId = (tANI_U8)sessionId;
7056 pCommand->u.roamCmd.roamReason = eCsrStopBss;
7057 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7058 if( !HAL_STATUS_SUCCESS( status ) )
7059 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007060 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007061 csrReleaseCommandRoam( pMac, pCommand );
7062 }
7063 }
7064 else
7065 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007066 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007067 status = eHAL_STATUS_RESOURCES;
7068 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007069 return ( status );
7070}
7071
Jeff Johnson295189b2012-06-20 16:38:30 -07007072eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7073{
7074 eHalStatus status = eHAL_STATUS_SUCCESS;
7075 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007076
7077 if(!pSession)
7078 {
7079 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7080 return eHAL_STATUS_FAILURE;
7081 }
7082
Jeff Johnson295189b2012-06-20 16:38:30 -07007083#ifdef FEATURE_WLAN_BTAMP_UT_RF
7084 //Stop te retry
7085 pSession->maxRetryCount = 0;
7086 csrRoamStopJoinRetryTimer(pMac, sessionId);
7087#endif
7088 //Not to call cancel roaming here
7089 //Only issue disconnect when necessary
7090 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
7091 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
7092 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
7093
7094 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007095 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007096 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
7097 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307098 else
7099 {
7100 smsLog( pMac, LOGE, FL("Roam command is not present"));
7101 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007102 return (status);
7103}
7104
Jeff Johnson295189b2012-06-20 16:38:30 -07007105eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7106{
7107 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007108
7109 if(!pSession)
7110 {
7111 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7112 return eHAL_STATUS_FAILURE;
7113 }
7114
Jeff Johnson295189b2012-06-20 16:38:30 -07007115 csrRoamCancelRoaming(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007116 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
7117
7118 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
7119}
7120
Jeff Johnson295189b2012-06-20 16:38:30 -07007121eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
7122 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
7123{
7124 eHalStatus status = eHAL_STATUS_SUCCESS;
7125 tDot11fBeaconIEs *pIesTemp = pIes;
7126 tANI_U8 index;
7127 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7128 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007129
7130 if(!pSession)
7131 {
7132 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7133 return eHAL_STATUS_FAILURE;
7134 }
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007135 if(pConnectProfile->pAddIEAssoc)
7136 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307137 vos_mem_free(pConnectProfile->pAddIEAssoc);
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007138 pConnectProfile->pAddIEAssoc = NULL;
7139 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307140 vos_mem_set(&pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007141 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
7142 pConnectProfile->AuthInfo = pProfile->AuthType;
7143 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
7144 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
7145 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
7146 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
7147 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
7148 pConnectProfile->BSSType = pProfile->BSSType;
7149 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
7150 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07007151 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
AnjaneeDevi Kapparapu4b043912014-02-18 13:22:35 +05307152 if (!pConnectProfile->beaconInterval)
7153 {
7154 smsLog(pMac, LOGW, FL("ERROR: Beacon interval is ZERO"));
7155 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307156 vos_mem_copy(&pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007157 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
7158 if(pProfile->nAddIEAssocLength)
7159 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307160 pConnectProfile->pAddIEAssoc = vos_mem_malloc(pProfile->nAddIEAssocLength);
7161 if ( NULL == pConnectProfile->pAddIEAssoc )
7162 status = eHAL_STATUS_FAILURE;
7163 else
7164 status = eHAL_STATUS_SUCCESS;
7165 if (!HAL_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007166 {
7167 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
7168 return eHAL_STATUS_FAILURE;
7169 }
7170 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05307171 vos_mem_copy(pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
7172 pProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007173 }
7174
Jeff Johnson295189b2012-06-20 16:38:30 -07007175 //Save bssid
7176 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
7177#ifdef WLAN_FEATURE_VOWIFI_11R
7178 if (pSirBssDesc->mdiePresent)
7179 {
7180 pConnectProfile->MDID.mdiePresent = 1;
7181 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
7182 }
7183#endif
Leela Venkata Kiran Kumar Reddy Chiralad48e3272013-04-12 14:21:07 -07007184 if( NULL == pIesTemp )
7185 {
7186 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
7187 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007188#ifdef FEATURE_WLAN_ESE
7189 if ((csrIsProfileESE(pProfile) ||
7190 ((pIesTemp->ESEVersion.present)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007191 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
7192 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
7193 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
7194 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -07007195#ifdef WLAN_FEATURE_11W
7196 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
7197#endif
Saurabh Gupta775073c2013-02-14 13:31:36 +05307198 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007199 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07007200 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007201 pConnectProfile->isESEAssoc = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007202 }
7203#endif
7204 //save ssid
Jeff Johnson295189b2012-06-20 16:38:30 -07007205 if(HAL_STATUS_SUCCESS(status))
7206 {
7207 if(pIesTemp->SSID.present)
7208 {
7209 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +05307210 vos_mem_copy(pConnectProfile->SSID.ssId, pIesTemp->SSID.ssid,
7211 pIesTemp->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07007212 }
7213
7214 //Save the bss desc
7215 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307216
7217 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07007218 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307219 //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 -07007220 pConnectProfile->qap = TRUE;
7221 }
7222 else
7223 {
7224 pConnectProfile->qap = FALSE;
7225 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007226 if ( NULL == pIes )
7227 {
7228 //Free memory if it allocated locally
Kiet Lam64c1b492013-07-12 13:56:44 +05307229 vos_mem_free(pIesTemp);
Jeff Johnson295189b2012-06-20 16:38:30 -07007230 }
7231 }
7232 //Save Qos connection
7233 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
7234
7235 if(!HAL_STATUS_SUCCESS(status))
7236 {
7237 csrFreeConnectBssDesc(pMac, sessionId);
7238 }
7239 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
7240 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307241 if ((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
7242 vos_mem_compare(pProfile->SSIDs.SSIDList[index].SSID.ssId,
7243 pConnectProfile->SSID.ssId,
7244 pConnectProfile->SSID.length))
Jeff Johnson295189b2012-06-20 16:38:30 -07007245 {
7246 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
7247 break;
7248 }
7249 pConnectProfile->handoffPermitted = FALSE;
7250 }
7251
7252 return (status);
7253}
7254
Jeff Johnson295189b2012-06-20 16:38:30 -07007255static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
7256{
7257 tListElem *pEntry = NULL;
7258 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007259 //The head of the active list is the request we sent
7260 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7261 if(pEntry)
7262 {
7263 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7264 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007265 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7266 {
7267 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
7268 {
7269#ifndef WLAN_MDM_CODE_REDUCTION_OPT
7270 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7271#endif
7272 }
7273 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
7274 }
7275 else
7276 {
7277 tANI_U32 roamId = 0;
7278 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007279 if(!pSession)
7280 {
7281 smsLog(pMac, LOGE, FL(" session %d not found "), pSmeJoinRsp->sessionId);
7282 return;
7283 }
7284
Jeff Johnson295189b2012-06-20 16:38:30 -07007285
7286 //The head of the active list is the request we sent
7287 //Try to get back the same profile and roam again
7288 if(pCommand)
7289 {
7290 roamId = pCommand->u.roamCmd.roamId;
7291 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007292 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
7293 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007294 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007295#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7296 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
7297 if (csrRoamIsHandoffInProgress(pMac))
7298 {
7299 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
7300 /* Should indicate neighbor roam algorithm about the connect failure here */
7301 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
7302 }
7303#endif
7304 if (pCommand)
7305 {
7306 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
7307 {
7308 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7309 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
7310 csrRoamReissueRoamCommand(pMac);
7311 }
7312 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
7313 {
7314 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7315 }
7316 else
7317 {
7318 csrRoam(pMac, pCommand);
7319 }
7320 }
7321 else
7322 {
7323 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7324 }
7325 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
7326}
7327
Jeff Johnson295189b2012-06-20 16:38:30 -07007328eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7329 tDot11fBeaconIEs *pIes,
7330 tCsrRoamProfile *pProfile, tANI_U32 roamId )
7331{
7332 eHalStatus status;
Arif Hussain24bafea2013-11-15 15:10:03 -08007333 smsLog( pMac, LOG1, "Attempting to Join Bssid= "MAC_ADDRESS_STR,
7334 MAC_ADDR_ARRAY(pSirBssDesc->bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07007335
7336 // Set the roaming substate to 'join attempt'...
7337 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007338 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007339 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007340 return (status);
7341}
7342
Jeff Johnson295189b2012-06-20 16:38:30 -07007343static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7344 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
7345{
7346 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007347 // Set the roaming substate to 'join attempt'...
7348 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
7349
Kaushik, Sushant8489f472014-01-27 11:41:22 +05307350 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7351 FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007352
7353 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007354 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07007355}
7356
Jeff Johnson295189b2012-06-20 16:38:30 -07007357void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
7358{
7359 tListElem *pEntry;
7360 tSmeCmd *pCommand;
7361 tCsrRoamInfo roamInfo;
7362 tANI_U32 sessionId;
7363 tCsrRoamSession *pSession;
7364
7365 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7366 if(pEntry)
7367 {
7368 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7369 if ( eSmeCommandRoam == pCommand->command )
7370 {
7371 sessionId = pCommand->sessionId;
7372 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007373
7374 if(!pSession)
7375 {
7376 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7377 return;
7378 }
Abhishek Singhaf15f152013-11-30 16:08:55 +05307379 /* While switching between two AP, csr will reissue roam command again
7380 to the nextbss if it was interrupted by the dissconnect req for the
7381 previous bss.During this csr is incrementing bRefAssocStartCnt twice.
7382 so reset the bRefAssocStartCnt.
7383 */
7384 if(pSession->bRefAssocStartCnt > 0)
7385 {
7386 pSession->bRefAssocStartCnt--;
7387 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007388 if( pCommand->u.roamCmd.fStopWds )
7389 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307390 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007391 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
7392 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
7393 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007394 if (CSR_IS_WDS(&pSession->connectedProfile)){
Jeff Johnson295189b2012-06-20 16:38:30 -07007395 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
7396 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7397 eCSR_ROAM_WDS_IND,
7398 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
Jeff Johnson295189b2012-06-20 16:38:30 -07007399 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
7400 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
7401 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7402 eCSR_ROAM_INFRA_IND,
7403 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
7404 }
7405
Jeff Johnson295189b2012-06-20 16:38:30 -07007406
Jeff Johnson295189b2012-06-20 16:38:30 -07007407 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
7408 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007409 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007410 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7411 }
7412 }
7413 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
7414 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007415 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007416 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7417 }
7418 }
7419 else
7420 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007421 smsLog(pMac, LOGW, " Command is not roaming after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007422 }
7423 }
7424 else
7425 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007426 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available");
Jeff Johnson295189b2012-06-20 16:38:30 -07007427 }
7428}
7429
Jeff Johnson295189b2012-06-20 16:38:30 -07007430tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
7431{
7432 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7433 tListElem *pEntry;
7434 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007435 //alwasy lock active list before locking pending list
7436 csrLLLock( &pMac->sme.smeCmdActiveList );
7437 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7438 if(pEntry)
7439 {
7440 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7441 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7442 {
7443 fRet = eANI_BOOLEAN_TRUE;
7444 }
7445 }
7446 if(eANI_BOOLEAN_FALSE == fRet)
7447 {
7448 csrLLLock(&pMac->sme.smeCmdPendingList);
7449 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
7450 while(pEntry)
7451 {
7452 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7453 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7454 {
7455 fRet = eANI_BOOLEAN_TRUE;
7456 break;
7457 }
7458 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7459 }
7460 csrLLUnlock(&pMac->sme.smeCmdPendingList);
7461 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307462 if (eANI_BOOLEAN_FALSE == fRet)
7463 {
7464 csrLLLock(&pMac->roam.roamCmdPendingList);
7465 pEntry = csrLLPeekHead(&pMac->roam.roamCmdPendingList, LL_ACCESS_NOLOCK);
7466 while (pEntry)
7467 {
7468 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7469 if (( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7470 {
7471 fRet = eANI_BOOLEAN_TRUE;
7472 break;
7473 }
7474 pEntry = csrLLNext(&pMac->roam.roamCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7475 }
7476 csrLLUnlock(&pMac->roam.roamCmdPendingList);
7477 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007478 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007479 return (fRet);
7480}
7481
Jeff Johnson295189b2012-06-20 16:38:30 -07007482tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
7483{
7484 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7485 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07007486 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
7487 {
7488 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
7489 {
7490 break;
7491 }
7492 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007493 return ( fRet );
7494}
7495
Jeff Johnson295189b2012-06-20 16:38:30 -07007496tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
7497{
7498 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007499 //alwasy lock active list before locking pending list
7500 csrLLLock( &pMac->sme.smeCmdActiveList );
7501 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7502 if(eANI_BOOLEAN_FALSE == fRet)
7503 {
7504 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
7505 }
7506 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007507 return (fRet);
7508}
7509
Jeff Johnson295189b2012-06-20 16:38:30 -07007510tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
7511{
7512 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7513 tListElem *pEntry;
7514 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007515 //alwasy lock active list before locking pending list
7516 csrLLLock( &pMac->sme.smeCmdActiveList );
7517 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7518 if( pEntry )
7519 {
7520 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
7521 if( ( eCsrRoamCommandScan == pCommand->command ) &&
7522 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
7523 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
7524 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
7525 {
7526 fRet = eANI_BOOLEAN_TRUE;
7527 }
7528 }
7529 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007530 return (fRet);
7531}
Jeff Johnson295189b2012-06-20 16:38:30 -07007532eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
7533{
7534 eHalStatus status = eHAL_STATUS_SUCCESS;
7535 tSmeCmd *pCommand = NULL;
7536 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
7537 tANI_BOOLEAN fRemoveCmd = FALSE;
7538 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07007539 // Delete the old assoc command. All is setup for reassoc to be serialized
7540 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7541 if ( pEntry )
7542 {
7543 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
7544 if ( !pCommand )
7545 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007546 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007547 return eHAL_STATUS_RESOURCES;
7548 }
7549 if ( eSmeCommandRoam == pCommand->command )
7550 {
7551 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
7552 {
7553 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7554 }
7555 else
7556 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007557 smsLog( pMac, LOGE, FL(" Unexpected active roam command present ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007558 }
7559 if (fRemoveCmd == FALSE)
7560 {
7561 // Implies we did not get the serialized assoc command we
7562 // were expecting
7563 pCommand = NULL;
7564 }
7565 }
7566 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007567 if(NULL == pCommand)
7568 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007569 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007570 return eHAL_STATUS_RESOURCES;
7571 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007572 do
7573 {
7574 //Change the substate in case it is wait-for-key
7575 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7576 {
7577 csrRoamStopWaitForKeyTimer( pMac );
7578 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
7579 }
7580 pCommand->command = eSmeCommandRoam;
7581 pCommand->sessionId = (tANI_U8)sessionId;
7582 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07007583 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7584 if( !HAL_STATUS_SUCCESS( status ) )
7585 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007586 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007587 csrReleaseCommandRoam( pMac, pCommand );
7588 }
7589 } while( 0 );
7590
Jeff Johnson295189b2012-06-20 16:38:30 -07007591 return( status );
7592}
7593static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
7594{
7595 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7596 tCsrScanResult *pScanResult = NULL;
7597 tSirBssDescription *pBssDesc = NULL;
7598 tSmeCmd *pCommand = NULL;
7599 tANI_U32 sessionId;
7600 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07007601 if(NULL == pEntry)
7602 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307603 smsLog(pMac, LOGE, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07007604 return;
7605 }
7606 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7607 sessionId = pCommand->sessionId;
7608 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007609
7610 if(!pSession)
7611 {
7612 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7613 return;
7614 }
7615
Jeff Johnson295189b2012-06-20 16:38:30 -07007616 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
7617 {
7618 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007619 smsLog(pMac, LOGW, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007620 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7621 }
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07007622 /* If the roaming has stopped, not to continue the roaming command*/
7623 else if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
7624 {
7625 //No need to complete roaming here as it already completes
7626 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed\n"),
7627 pCommand->u.roamCmd.roamReason);
7628 csrSetAbortRoamingCommand( pMac, pCommand );
7629 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7630 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007631 else
7632 {
7633 if ( CCM_IS_RESULT_SUCCESS(result) )
7634 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007635 smsLog(pMac, LOG2, "Cfg sequence complete");
Jeff Johnson295189b2012-06-20 16:38:30 -07007636 // Successfully set the configuration parameters for the new Bss. Attempt to
7637 // join the roaming Bss.
7638 if(pCommand->u.roamCmd.pRoamBssEntry)
7639 {
7640 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
7641 pBssDesc = &pScanResult->Result.BssDescriptor;
7642 }
7643 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
7644 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07007645 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07007646 )
7647 {
7648 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
7649 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
7650 pBssDesc, pCommand->u.roamCmd.roamId )))
7651 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307652 smsLog(pMac, LOGE, " CSR start BSS failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07007653 //We need to complete the command
7654 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7655 }
7656 }
7657 else
7658 {
7659 if (!pCommand->u.roamCmd.pRoamBssEntry)
7660 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307661 smsLog(pMac, LOGE, " pRoamBssEntry is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07007662 //We need to complete the command
7663 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
7664 return;
7665 }
7666 // If we are roaming TO an Infrastructure BSS...
7667 VOS_ASSERT(pScanResult != NULL);
7668 if ( csrIsInfraBssDesc( pBssDesc ) )
7669 {
7670 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07007671 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
7672 {
7673 // ..and currently in an Infrastructure connection....
7674 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
7675 {
7676 // ...and the SSIDs are equal, then we Reassoc.
7677 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
7678 pIesLocal ) )
7679 // ..and currently in an infrastructure connection
7680 {
7681 // then issue a Reassoc.
7682 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
7683 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
7684 &pCommand->u.roamCmd.roamProfile );
7685 }
7686 else
7687 {
7688
7689 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
7690 // previously associated AP.
7691 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7692 pIesLocal,
7693 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
7694 {
7695 //try something else
7696 csrRoam( pMac, pCommand );
7697 }
7698 }
7699 }
7700 else
7701 {
7702 eHalStatus status = eHAL_STATUS_SUCCESS;
7703
7704 /* We need to come with other way to figure out that this is because of HO in BMP
7705 The below API will be only available for Android as it uses a different HO algorithm */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007706 /* Reassoc request will be used only for ESE and 11r handoff whereas other legacy roaming should
Jeff Johnson295189b2012-06-20 16:38:30 -07007707 * use join request */
7708#ifdef WLAN_FEATURE_VOWIFI_11R
7709 if (csrRoamIsHandoffInProgress(pMac) &&
7710 csrRoamIs11rAssoc(pMac))
7711 {
7712 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
7713 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
7714 }
7715 else
7716#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007717#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07007718 if (csrRoamIsHandoffInProgress(pMac) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007719 csrRoamIsESEAssoc(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07007720 {
7721 // Now serialize the reassoc command.
7722 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7723 }
7724 else
7725#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007726#ifdef FEATURE_WLAN_LFR
7727 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05307728 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007729 {
7730 // Now serialize the reassoc command.
7731 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7732 }
7733 else
7734#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007735 // else we are not connected and attempting to Join. Issue the
7736 // Join request.
7737 {
7738 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7739 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
7740 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
7741 }
7742 if(!HAL_STATUS_SUCCESS(status))
7743 {
7744 //try something else
7745 csrRoam( pMac, pCommand );
7746 }
7747 }
7748 if( !pScanResult->Result.pvIes )
7749 {
7750 //Locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05307751 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07007752 }
7753 }
7754 }//if ( csrIsInfraBssDesc( pBssDesc ) )
7755 else
7756 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007757 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007758 }
7759 }//else
7760 }//if ( WNI_CFG_SUCCESS == result )
7761 else
7762 {
7763 // In the event the configuration failed, for infra let the roam processor
7764 //attempt to join something else...
7765 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
7766 {
7767 csrRoam(pMac, pCommand);
7768 }
7769 else
7770 {
7771 //We need to complete the command
7772 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
7773 {
7774 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7775 }
7776 else
7777 {
7778 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7779 }
7780 }
7781 }
7782 }//we have active entry
7783}
7784
Jeff Johnson295189b2012-06-20 16:38:30 -07007785static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
7786{
7787 //No one is sending eWNI_SME_AUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007788 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007789 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
7790 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007791 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007792 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
7793 // join the new one...
7794 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07007795 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
7796 }
7797 else {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007798 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08X [%d]", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007799 /***profHandleLostLinkAfterReset(pAdapter);
7800 // In the event the authenticate fails, let the roam processor attempt to join something else...
7801 roamRoam( pAdapter );***/
7802 }
7803}
7804
Jeff Johnson295189b2012-06-20 16:38:30 -07007805static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
7806{
7807 eCsrRoamCompleteResult result;
7808 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
7809 tCsrRoamInfo roamInfo;
7810 tANI_U32 roamId = 0;
7811
7812 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7813 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007814 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007815 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07007816 /* Defeaturize this part later if needed */
7817#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
7818 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
7819 * we need the response contents while processing the result in csrRoamProcessResults() */
7820 if (csrRoamIsHandoffInProgress(pMac))
7821 {
7822 /* Need to dig more on indicating events to SME QoS module */
7823 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7824 csrRoamComplete( pMac, result, pSmeJoinRsp);
7825 }
7826 else
7827#endif
7828 {
7829 csrRoamComplete( pMac, result, NULL );
7830 }
7831 }
7832 /* Should we handle this similar to handling the join failure? Is it ok
7833 * to call csrRoamComplete() with state as CsrJoinFailure */
7834 else
7835 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007836 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007837 result = eCsrReassocFailure;
7838#ifdef WLAN_FEATURE_VOWIFI_11R
7839 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
7840 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode))
7841 {
7842 // Inform HDD to turn off FT flag in HDD
7843 if (pNeighborRoamInfo)
7844 {
7845 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7846 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
7847 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07007848 /*
7849 * Since the above callback sends a disconnect
7850 * to HDD, we should clean-up our state
7851 * machine as well to be in sync with the upper
7852 * layers. There is no need to send a disassoc
7853 * since: 1) we will never reassoc to the current
7854 * AP in LFR, and 2) there is no need to issue a
7855 * disassoc to the AP with which we were trying
7856 * to reassoc.
7857 */
7858 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7859 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07007860 }
7861 }
7862#endif
7863 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
7864 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
7865 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
7866 //The disassoc rsp message will remove the command from active list
7867 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
7868 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
7869 {
7870 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7871 }
7872 }
7873}
7874
Jeff Johnson295189b2012-06-20 16:38:30 -07007875static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
7876{
Jeff Johnson295189b2012-06-20 16:38:30 -07007877#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7878 {
7879 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07007880 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
7881 if(pIbssLog)
7882 {
7883 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
7884 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
7885 {
7886 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
7887 }
7888 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
7889 }
7890 }
7891#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07007892 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7893 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
7894 {
7895 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7896 }
7897 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
7898 {
7899 csrRoamReissueRoamCommand(pMac);
7900 }
7901}
7902
Jeff Johnson295189b2012-06-20 16:38:30 -07007903void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
7904{
7905 tSirResultCodes statusCode;
7906#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7907 tScanResultHandle hBSSList;
7908 tANI_BOOLEAN fCallCallback, fRemoveCmd;
7909 eHalStatus status;
7910 tCsrRoamInfo roamInfo;
7911 tCsrScanResultFilter *pScanFilter = NULL;
7912 tANI_U32 roamId = 0;
7913 tCsrRoamProfile *pCurRoamProfile = NULL;
7914 tListElem *pEntry = NULL;
7915 tSmeCmd *pCommand = NULL;
7916#endif
7917 tANI_U32 sessionId;
7918 tCsrRoamSession *pSession;
Jeff Johnsone7245742012-09-05 17:12:55 -07007919
Jeff Johnson295189b2012-06-20 16:38:30 -07007920 tSirSmeDisassocRsp SmeDisassocRsp;
7921
7922 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
7923 sessionId = SmeDisassocRsp.sessionId;
7924 statusCode = SmeDisassocRsp.statusCode;
7925
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007926 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007927
7928 if ( csrIsConnStateInfra( pMac, sessionId ) )
7929 {
7930 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7931 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007932 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007933
7934 if(!pSession)
7935 {
7936 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7937 return;
7938 }
7939
Jeff Johnson295189b2012-06-20 16:38:30 -07007940 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
7941 {
7942 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7943 }
7944 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
7945 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
7946 {
7947 if ( eSIR_SME_SUCCESS == statusCode )
7948 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007949 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007950 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
7951 }
7952 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7953 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007954 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
7955 {
Kaushik, Sushant8489f472014-01-27 11:41:22 +05307956 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH,
7957 "CSR SmeDisassocReq due to HO on session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007958#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007959 /*
7960 * First ensure if the roam profile is in the scan cache.
7961 * If not, post a reassoc failure and disconnect.
7962 */
Kiet Lam64c1b492013-07-12 13:56:44 +05307963 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
7964 if ( NULL == pScanFilter )
7965 status = eHAL_STATUS_FAILURE;
7966 else
7967 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007968 if(HAL_STATUS_SUCCESS(status))
7969 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307970 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007971 status = csrRoamPrepareFilterFromProfile(pMac,
7972 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
7973 if(!HAL_STATUS_SUCCESS(status))
7974 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007975 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007976 __func__, status);
7977 goto POST_ROAM_FAILURE;
7978 }
7979 else
7980 {
7981 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
7982 if (!HAL_STATUS_SUCCESS(status))
7983 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007984 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007985 __func__, status);
7986 goto POST_ROAM_FAILURE;
7987 }
7988 }
7989 }
7990 else
7991 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007992 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007993 __func__, status);
7994 goto POST_ROAM_FAILURE;
7995 }
7996
7997 /*
7998 * After ensuring that the roam profile is in the scan result list,
7999 * dequeue the command from the active list.
8000 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008001 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
8002 if ( pEntry )
8003 {
8004 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008005 /* If the head of the queue is Active and it is a ROAM command, remove
8006 * and put this on the Free queue.
8007 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008008 if ( eSmeCommandRoam == pCommand->command )
8009 {
Jeff Johnsone7245742012-09-05 17:12:55 -07008010
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008011 /*
8012 * we need to process the result first before removing it from active list
8013 * because state changes still happening insides roamQProcessRoamResults so
8014 * no other roam command should be issued.
8015 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008016 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
8017 if(pCommand->u.roamCmd.fReleaseProfile)
8018 {
8019 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
8020 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
8021 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008022 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07008023 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07008024 else
8025 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008026 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008027 __func__, pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07008028 }
8029 }
8030 else
8031 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008032 smsLog( pMac, LOGE, "%s: roam command not active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008033 }
8034 }
8035 else
8036 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008037 smsLog( pMac, LOGE, "%s: NO commands are active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008038 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008039
8040 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07008041 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
8042
Kiet Lam64c1b492013-07-12 13:56:44 +05308043 vos_mem_copy(roamInfo.bssid,
8044 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
8045 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008046
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008047 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
8048 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008049
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008050 /* Copy the connected profile to apply the same for this connection as well */
Kiet Lam64c1b492013-07-12 13:56:44 +05308051 pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
8052 if ( pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07008053 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308054 vos_mem_set(pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008055 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
8056 //make sure to put it at the head of the cmd queue
8057 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
8058 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
8059 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
8060
Jeff Johnson295189b2012-06-20 16:38:30 -07008061 if(!HAL_STATUS_SUCCESS(status))
8062 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008063 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008064 __func__, status);
8065 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008066 }
8067
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008068 /* Notify sub-modules like QoS etc. that handoff happening */
8069 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08008070 csrReleaseProfile(pMac, pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05308071 vos_mem_free(pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07008072 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308073 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008074 return;
8075 }
8076
8077POST_ROAM_FAILURE:
8078 if (pScanFilter)
8079 {
8080 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308081 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008082 }
8083 if (pCurRoamProfile)
Kiet Lam64c1b492013-07-12 13:56:44 +05308084 vos_mem_free(pCurRoamProfile);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008085
8086 /* Inform the upper layers that the reassoc failed */
8087 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
8088 csrRoamCallCallback(pMac, sessionId,
8089 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
8090
8091 /*
8092 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
8093 * Upon success, we would re-enter this routine after receiving the disassoc
8094 * response and will fall into the reassoc fail sub-state. And, eventually
8095 * call csrRoamComplete which would remove the roam command from SME active
8096 * queue.
8097 */
8098 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
8099 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
8100 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008101 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008102 __func__, status);
8103 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07008104 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008105#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008106
Jeff Johnson295189b2012-06-20 16:38:30 -07008107 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
8108 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
8109 {
8110 // Disassoc due to Reassoc failure falls into this codepath....
8111 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8112 }
8113 else
8114 {
8115 if ( eSIR_SME_SUCCESS == statusCode )
8116 {
8117 // Successfully disassociated from the 'old' Bss...
8118 //
8119 // We get Disassociate response in three conditions.
8120 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
8121 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
8122 // Infrastructure network.
8123 // - Third is where we are doing an Infra to Infra roam between networks with different
8124 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
8125
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008126 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008127 }
8128 else
8129 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008130 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008131 }
8132 //We are not done yet. Get the data and continue roaming
8133 csrRoamReissueRoamCommand(pMac);
8134 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008135}
8136
Jeff Johnson295189b2012-06-20 16:38:30 -07008137static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
8138{
8139 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008140 //No one is sending eWNI_SME_DEAUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008141 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008142 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08008143 pMac->roam.deauthRspStatus = statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008144 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
8145 {
8146 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8147 }
8148 else
8149 {
8150 if ( eSIR_SME_SUCCESS == statusCode )
8151 {
8152 // Successfully deauth from the 'old' Bss...
8153 //
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008154 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008155 }
8156 else
8157 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008158 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008159 }
8160 //We are not done yet. Get the data and continue roaming
8161 csrRoamReissueRoamCommand(pMac);
8162 }
8163}
8164
Jeff Johnson295189b2012-06-20 16:38:30 -07008165static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
8166{
8167 eCsrRoamCompleteResult result;
8168
8169 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
8170 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008171 smsLog( pMac, LOGW, "SmeStartBssReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008172 result = eCsrStartBssSuccess;
8173 }
8174 else
8175 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008176 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08X", pSmeStartBssRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008177 //Let csrRoamComplete decide what to do
8178 result = eCsrStartBssFailure;
8179 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008180 csrRoamComplete( pMac, result, pSmeStartBssRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -07008181}
8182
Jeff Johnson295189b2012-06-20 16:38:30 -07008183/*
8184 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
8185 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
8186 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
8187 For the messages where sender allocates memory for specific structures, then it can be
8188 cast accordingly.
8189*/
8190void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8191{
8192 tSirSmeRsp *pSmeRsp;
8193 tSmeIbssPeerInd *pIbssPeerInd;
8194 tCsrRoamInfo roamInfo;
8195 // TODO Session Id need to be acquired in this function
8196 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008197 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308198 smsLog(pMac, LOG2, FL("Message %d[0x%04X] received in substate %s"),
8199 pSmeRsp->messageType, pSmeRsp->messageType,
8200 macTraceGetcsrRoamSubState(
8201 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008202 pSmeRsp->messageType = (pSmeRsp->messageType);
8203 pSmeRsp->length = (pSmeRsp->length);
8204 pSmeRsp->statusCode = (pSmeRsp->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008205 switch (pSmeRsp->messageType)
8206 {
8207
8208 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
8209 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
8210 {
8211 //We sent a JOIN_REQ
8212 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
8213 }
8214 break;
8215
8216 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
8217 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
8218 {
8219 //We sent a AUTH_REQ
8220 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
8221 }
8222 break;
8223
8224 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
8225 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
8226 {
8227 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
8228 }
8229 break;
8230
8231 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
8232 {
8233 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
8234 }
8235 break;
8236
8237 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
8238 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
8239 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
8240 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
8241 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
8242 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
8243//HO
8244 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
8245 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308246 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %s"),
8247 macTraceGetcsrRoamSubState(
8248 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008249 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
8250 }
8251 break;
8252
8253 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
8254 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
8255 {
8256 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
8257 }
8258 break;
8259
8260 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
8261 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
8262 {
8263 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
8264 }
8265 break;
8266
8267 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
8268 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
8269 {
8270 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
8271 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008272 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008273 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
8274 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
8275 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008276 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state");
Kiet Lam64c1b492013-07-12 13:56:44 +05308277 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
8278 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008279 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
8280 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05308281 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
8282 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008283 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
8284 eCSR_ROAM_CONNECT_STATUS_UPDATE,
8285 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
8286 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008287 default:
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308288 smsLog(pMac, LOG1,
8289 FL("Unexpected message type = %d[0x%X] received in substate %s"),
8290 pSmeRsp->messageType, pSmeRsp->messageType,
8291 macTraceGetcsrRoamSubState(
8292 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008293
8294 //If we are connected, check the link status change
8295 if(!csrIsConnStateDisconnected(pMac, sessionId))
8296 {
8297 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
8298 }
8299 break;
8300 }
8301}
8302
Jeff Johnson295189b2012-06-20 16:38:30 -07008303void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8304{
8305 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07008306 switch (pSirMsg->messageType)
8307 {
8308 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008309 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008310 csrRoamStatsRspProcessor( pMac, pSirMsg );
8311 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008312 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
8313 {
8314 tCsrRoamSession *pSession;
8315 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
8316 tCsrRoamInfo roamInfo;
8317 tCsrRoamInfo *pRoamInfo = NULL;
8318 tANI_U32 sessionId;
8319 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008320 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer "));
Kiet Lam64c1b492013-07-12 13:56:44 +05308321 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008322 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07008323 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
8324 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
8325 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008326
8327 if(!pSession)
8328 {
8329 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8330 return;
8331 }
8332
Jeff Johnson295189b2012-06-20 16:38:30 -07008333 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
8334 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07008335 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
8336 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
8337 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07008338 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
8339 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05308340 vos_mem_copy(pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr,
8341 sizeof(tSirMacAddr));
8342 vos_mem_copy(&pRoamInfo->bssid, pUpperLayerAssocCnf->bssId,
8343 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008344 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07008345 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
8346 {
8347 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
8348 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
8349 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
8350 }
8351 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8352 {
8353 vos_sleep( 100 );
8354 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
8355 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
8356 }
8357
Jeff Johnson295189b2012-06-20 16:38:30 -07008358 }
8359 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008360 default:
8361 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
8362 break;
8363 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008364}
8365
Jeff Johnson295189b2012-06-20 16:38:30 -07008366eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
8367 tSirBssDescription *pBssDescription,
8368 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
8369 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
8370 tANI_U8 keyId, tANI_U16 keyLength,
8371 tANI_U8 *pKey, tANI_U8 paeRole )
8372{
8373 eHalStatus status = eHAL_STATUS_SUCCESS;
8374 tAniEdType edType;
8375
8376 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
8377 {
8378 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
8379 }
8380
8381 edType = csrTranslateEncryptTypeToEdType( EncryptType );
8382
8383 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
8384 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
8385 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
8386 addKey )
8387 {
8388 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07008389 setKey.encType = EncryptType;
8390 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308391 vos_mem_copy(&setKey.peerMac, bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008392 setKey.paeRole = paeRole; //0 for supplicant
8393 setKey.keyId = keyId; // Kye index
8394 setKey.keyLength = keyLength;
8395 if( keyLength )
8396 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308397 vos_mem_copy(setKey.Key, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008398 }
8399 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
8400 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008401 return (status);
8402}
8403
Jeff Johnson295189b2012-06-20 16:38:30 -07008404static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8405 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8406{
8407 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8408 tSmeCmd *pCommand = NULL;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008409#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008410 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008411#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07008412
8413 do
8414 {
8415 pCommand = csrGetCommandBuffer(pMac);
8416 if(NULL == pCommand)
8417 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008418 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008419 status = eHAL_STATUS_RESOURCES;
8420 break;
8421 }
8422 pCommand->command = eSmeCommandSetKey;
8423 pCommand->sessionId = (tANI_U8)sessionId;
8424 // validate the key length, Adjust if too long...
8425 // for static WEP the keys are not set thru' SetContextReq
8426 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
8427 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
8428 {
8429 //KeyLength maybe 0 for static WEP
8430 if( pSetKey->keyLength )
8431 {
8432 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
8433 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008434 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008435 break;
8436 }
8437
8438 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308439 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8440 CSR_WEP40_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008441 }
8442 }
8443 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
8444 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
8445 {
8446 //KeyLength maybe 0 for static WEP
8447 if( pSetKey->keyLength )
8448 {
8449 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
8450 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008451 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008452 break;
8453 }
8454
8455 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308456 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8457 CSR_WEP104_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008458 }
8459 }
8460 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
8461 {
8462 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
8463 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008464 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008465 break;
8466 }
8467 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308468 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8469 CSR_TKIP_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008470 }
8471 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
8472 {
8473 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
8474 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008475 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008476 break;
8477 }
8478 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308479 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8480 CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008481 }
8482#ifdef FEATURE_WLAN_WAPI
8483 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
8484 {
8485 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
8486 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008487 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008488 break;
8489 }
8490 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308491 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8492 CSR_WAPI_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008493 }
8494#endif /* FEATURE_WLAN_WAPI */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008495#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008496 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8497 {
8498 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
8499 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008500 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008501 break;
8502 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008503 vos_mem_copy(pSession->eseCckmInfo.krk, pSetKey->Key,
Kiet Lam64c1b492013-07-12 13:56:44 +05308504 CSR_KRK_KEY_LEN);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008505 pSession->eseCckmInfo.reassoc_req_num=1;
8506 pSession->eseCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008507 status = eHAL_STATUS_SUCCESS;
8508 break;
8509 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008510#endif /* FEATURE_WLAN_ESE */
Jeff Johnsone7245742012-09-05 17:12:55 -07008511
Jeff Johnson295189b2012-06-20 16:38:30 -07008512#ifdef WLAN_FEATURE_11W
8513 //Check for 11w BIP
Chet Lanctot186b5732013-03-18 10:26:30 -07008514 else if (eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008515 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008516 if (pSetKey->keyLength < CSR_AES_KEY_LEN)
Jeff Johnson295189b2012-06-20 16:38:30 -07008517 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008518 smsLog(pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008519 break;
8520 }
8521 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308522 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008523 }
8524#endif
8525 status = eHAL_STATUS_SUCCESS;
8526 pCommand->u.setKeyCmd.roamId = roamId;
8527 pCommand->u.setKeyCmd.encType = pSetKey->encType;
8528 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308529 vos_mem_copy(&pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac,
8530 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008531 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
8532 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
Kiet Lam64c1b492013-07-12 13:56:44 +05308533 vos_mem_copy(pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008534 //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
8535
8536 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
8537 if( !HAL_STATUS_SUCCESS( status ) )
8538 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008539 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008540 }
8541 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008542 // Free the command if there has been a failure, or it is a
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008543 // "local" operation like the set ESE CCKM KRK key.
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008544 if ( ( NULL != pCommand ) &&
8545 ( (!HAL_STATUS_SUCCESS( status ) )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008546#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008547 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008548#endif /* FEATURE_WLAN_ESE */
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008549 ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008550 {
8551 csrReleaseCommandSetKey( pMac, pCommand );
8552 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008553 return( status );
8554}
8555
Jeff Johnson295189b2012-06-20 16:38:30 -07008556eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8557 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
8558{
8559 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8560 tSmeCmd *pCommand = NULL;
8561 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008562 do
8563 {
8564 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8565 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008566 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008567 status = eHAL_STATUS_CSR_WRONG_STATE;
8568 break;
8569 }
8570 pCommand = csrGetCommandBuffer(pMac);
8571 if(NULL == pCommand)
8572 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008573 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008574 status = eHAL_STATUS_RESOURCES;
8575 break;
8576 }
8577 pCommand->command = eSmeCommandRemoveKey;
8578 pCommand->sessionId = (tANI_U8)sessionId;
8579 pCommand->u.removeKeyCmd.roamId = roamId;
8580 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
Kiet Lam64c1b492013-07-12 13:56:44 +05308581 vos_mem_copy(&pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac,
8582 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008583 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
8584 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8585 {
8586 //in this case, put it to the end of the Q incase there is a set key pending.
8587 fImediate = eANI_BOOLEAN_FALSE;
8588 }
Arif Hussain24bafea2013-11-15 15:10:03 -08008589 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac="MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07008590 pRemoveKey->encType, pRemoveKey->keyId,
Arif Hussain24bafea2013-11-15 15:10:03 -08008591 MAC_ADDR_ARRAY(pCommand->u.removeKeyCmd.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07008592 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
8593 if( !HAL_STATUS_SUCCESS( status ) )
8594 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008595 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008596 break;
8597 }
8598 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008599 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
8600 {
8601 csrReleaseCommandRemoveKey( pMac, pCommand );
8602 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008603 return (status );
8604}
8605
Jeff Johnson295189b2012-06-20 16:38:30 -07008606eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8607{
8608 eHalStatus status;
8609 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
8610 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
8611 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
8612 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008613#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8614 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8615 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
lukez3c809222013-05-03 10:23:02 -07008616 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008617 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308618 vos_mem_set(&setKeyEvent,
8619 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008620 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8621 {
8622 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_REQ;
8623 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8624 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8625 }
8626 else
8627 {
8628 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_REQ;
8629 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8630 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8631 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308632 vos_mem_copy(setKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
lukez3c809222013-05-03 10:23:02 -07008633 if(CSR_IS_ENC_TYPE_STATIC(pCommand->u.setKeyCmd.encType))
Jeff Johnson295189b2012-06-20 16:38:30 -07008634 {
8635 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008636 //It has to be static WEP here
8637 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
8638 {
8639 setKeyEvent.keyId = (v_U8_t)defKeyId;
8640 }
8641 }
8642 else
8643 {
8644 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
8645 }
8646 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8647 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8648 }
8649#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008650 if( csrIsSetKeyAllowed(pMac, sessionId) )
8651 {
8652 status = csrSendMBSetContextReqMsg( pMac, sessionId,
8653 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
8654 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
8655 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
8656 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
8657 pCommand->u.setKeyCmd.keyRsc);
8658 }
8659 else
8660 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008661 smsLog( pMac, LOGW, FL(" cannot process not connected") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008662 //Set this status so the error handling take care of the case.
8663 status = eHAL_STATUS_CSR_WRONG_STATE;
8664 }
8665 if( !HAL_STATUS_SUCCESS(status) )
8666 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008667 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008668 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008669#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
lukez3c809222013-05-03 10:23:02 -07008670 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008671 {
8672 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8673 {
8674 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
8675 }
8676 else
8677 {
8678 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
8679 }
8680 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
8681 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8682 }
8683#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008684 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008685 return ( status );
8686}
8687
Jeff Johnson295189b2012-06-20 16:38:30 -07008688eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8689{
8690 eHalStatus status;
8691 tpSirSmeRemoveKeyReq pMsg = NULL;
8692 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
8693 tANI_U8 *p;
8694 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008695#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8696 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8697 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +05308698 vos_mem_set(&removeKeyEvent,
8699 sizeof(vos_event_wlan_security_payload_type),0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008700 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
8701 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8702 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05308703 vos_mem_copy(removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07008704 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
8705 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8706 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8707#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008708 if( csrIsSetKeyAllowed(pMac, sessionId) )
8709 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308710 pMsg = vos_mem_malloc(wMsgLen);
8711 if ( NULL == pMsg )
8712 status = eHAL_STATUS_FAILURE;
8713 else
8714 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008715 }
8716 else
8717 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008718 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008719 //Set the error status so error handling kicks in below
8720 status = eHAL_STATUS_CSR_WRONG_STATE;
8721 }
8722 if( HAL_STATUS_SUCCESS( status ) )
8723 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308724 vos_mem_set(pMsg, wMsgLen ,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008725 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
8726 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008727 pMsg->sessionId = (tANI_U8)sessionId;
8728 pMsg->transactionId = 0;
8729 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
8730 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
8731 // bssId - copy from session Info
Kiet Lam64c1b492013-07-12 13:56:44 +05308732 vos_mem_copy(p,
8733 &pMac->roam.roamSession[sessionId].connectedProfile.bssid,
8734 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008735 p += sizeof(tSirMacAddr);
8736 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +05308737 vos_mem_copy(p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008738 p += sizeof(tSirMacAddr);
8739 // edType
8740 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
8741 p++;
8742 // weptype
8743 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
8744 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
8745 {
8746 *p = (tANI_U8)eSIR_WEP_STATIC;
8747 }
8748 else
8749 {
8750 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
8751 }
8752 p++;
8753 //keyid
8754 *p = pCommand->u.removeKeyCmd.keyId;
8755 p++;
8756 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008757 status = palSendMBMessage(pMac->hHdd, pMsg);
8758 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008759 if( !HAL_STATUS_SUCCESS( status ) )
8760 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008761 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008762#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8763 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07008764 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008765 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8766#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008767 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
8768 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008769 return ( status );
8770}
8771
Jeff Johnson295189b2012-06-20 16:38:30 -07008772eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8773{
8774 eHalStatus status;
8775
8776 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8777 {
8778 status = eHAL_STATUS_CSR_WRONG_STATE;
8779 }
8780 else
8781 {
8782 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
8783 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008784 return ( status );
8785}
8786
Jeff Johnson295189b2012-06-20 16:38:30 -07008787/*
8788 Prepare a filter base on a profile for parsing the scan results.
8789 Upon successful return, caller MUST call csrFreeScanFilter on
8790 pScanFilter when it is done with the filter.
8791*/
8792eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
8793 tCsrScanResultFilter *pScanFilter)
8794{
8795 eHalStatus status = eHAL_STATUS_SUCCESS;
8796 tANI_U32 size = 0;
8797 tANI_U8 index = 0;
8798
8799 do
8800 {
8801 if(pProfile->BSSIDs.numOfBSSIDs)
8802 {
8803 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308804 pScanFilter->BSSIDs.bssid = vos_mem_malloc(size);
8805 if ( NULL == pScanFilter->BSSIDs.bssid )
8806 status = eHAL_STATUS_FAILURE;
8807 else
8808 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008809 if(!HAL_STATUS_SUCCESS(status))
8810 {
8811 break;
8812 }
8813 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308814 vos_mem_copy(pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07008815 }
8816 if(pProfile->SSIDs.numOfSSIDs)
8817 {
8818 if( !CSR_IS_WDS_STA( pProfile ) )
8819 {
8820 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
8821 }
8822 else
8823 {
8824 //For WDS station
8825 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
8826 pScanFilter->SSIDs.numOfSSIDs = 1;
8827 }
8828 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308829 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(size);
8830 if ( NULL == pScanFilter->SSIDs.SSIDList )
8831 status = eHAL_STATUS_FAILURE;
8832 else
8833 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008834 if(!HAL_STATUS_SUCCESS(status))
8835 {
8836 break;
8837 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308838 vos_mem_copy(pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList,
8839 size);
Jeff Johnson295189b2012-06-20 16:38:30 -07008840 }
8841 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
8842 {
8843 pScanFilter->ChannelInfo.numOfChannels = 0;
8844 pScanFilter->ChannelInfo.ChannelList = NULL;
8845 }
8846 else if(pProfile->ChannelInfo.numOfChannels)
8847 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308848 pScanFilter->ChannelInfo.ChannelList = vos_mem_malloc(
8849 sizeof(*pScanFilter->ChannelInfo.ChannelList) *
8850 pProfile->ChannelInfo.numOfChannels);
8851 if ( NULL == pScanFilter->ChannelInfo.ChannelList )
8852 status = eHAL_STATUS_FAILURE;
8853 else
8854 status = eHAL_STATUS_SUCCESS;
8855
Jeff Johnson295189b2012-06-20 16:38:30 -07008856 pScanFilter->ChannelInfo.numOfChannels = 0;
8857 if(HAL_STATUS_SUCCESS(status))
8858 {
8859 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
8860 {
8861 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
8862 {
8863 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
8864 = pProfile->ChannelInfo.ChannelList[index];
8865 pScanFilter->ChannelInfo.numOfChannels++;
8866 }
8867 else
8868 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008869 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid"), pProfile->ChannelInfo.ChannelList[index]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008870 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008871 }
8872 }
8873 else
8874 {
8875 break;
8876 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008877 }
8878 else
8879 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05308880 smsLog(pMac, LOGE, FL("Channel list empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008881 status = eHAL_STATUS_FAILURE;
8882 break;
8883 }
8884 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
8885 pScanFilter->authType = pProfile->AuthType;
8886 pScanFilter->EncryptionType = pProfile->EncryptionType;
8887 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
8888 pScanFilter->BSSType = pProfile->BSSType;
8889 pScanFilter->phyMode = pProfile->phyMode;
8890#ifdef FEATURE_WLAN_WAPI
8891 //check if user asked for WAPI with 11n or auto mode, in that case modify
8892 //the phymode to 11g
8893 if(csrIsProfileWapi(pProfile))
8894 {
8895 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
8896 {
8897 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
8898 }
8899 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
8900 {
8901 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
8902 }
8903 if(!pScanFilter->phyMode)
8904 {
8905 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
8906 }
8907 }
8908#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07008909 /*Save the WPS info*/
8910 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07008911 if( pProfile->countryCode[0] )
8912 {
8913 //This causes the matching function to use countryCode as one of the criteria.
Kiet Lam64c1b492013-07-12 13:56:44 +05308914 vos_mem_copy(pScanFilter->countryCode, pProfile->countryCode,
8915 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008916 }
8917#ifdef WLAN_FEATURE_VOWIFI_11R
8918 if (pProfile->MDID.mdiePresent)
8919 {
8920 pScanFilter->MDID.mdiePresent = 1;
8921 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
8922 }
8923#endif
8924
8925 }while(0);
8926
8927 if(!HAL_STATUS_SUCCESS(status))
8928 {
8929 csrFreeScanFilter(pMac, pScanFilter);
8930 }
8931
8932 return(status);
8933}
8934
Jeff Johnson295189b2012-06-20 16:38:30 -07008935tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
8936 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
8937{
8938 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
8939 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008940 do
8941 {
8942 // Validate the type is ok...
8943 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
8944 pCommand = csrGetCommandBuffer( pMac );
8945 if ( !pCommand )
8946 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008947 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008948 break;
8949 }
8950 //Change the substate in case it is waiting for key
8951 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8952 {
8953 csrRoamStopWaitForKeyTimer( pMac );
8954 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
8955 }
8956 pCommand->command = eSmeCommandWmStatusChange;
8957 pCommand->sessionId = (tANI_U8)sessionId;
8958 pCommand->u.wmStatusChangeCmd.Type = Type;
8959 if ( eCsrDisassociated == Type )
8960 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308961 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg,
8962 pSmeRsp,
8963 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07008964 }
8965 else
8966 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308967 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg,
8968 pSmeRsp,
8969 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07008970 }
8971 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
8972 {
8973 fCommandQueued = eANI_BOOLEAN_TRUE;
8974 }
8975 else
8976 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008977 smsLog( pMac, LOGE, FL(" fail to send message ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008978 csrReleaseCommandWmStatusChange( pMac, pCommand );
8979 }
8980
Jeff Johnson295189b2012-06-20 16:38:30 -07008981 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
8982 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07008983 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07008984 return( fCommandQueued );
8985}
8986
Jeff Johnson295189b2012-06-20 16:38:30 -07008987static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
8988{
8989 v_S7_t rssi = 0;
8990 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
8991 if(pGetRssiReq)
8992 {
8993 if(NULL != pGetRssiReq->pVosContext)
8994 {
8995 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
8996 }
8997 else
8998 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008999 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009000 return;
9001 }
9002
9003 if(NULL != pGetRssiReq->rssiCallback)
9004 {
9005 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
9006 }
9007 else
9008 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009009 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009010 return;
9011 }
9012 }
9013 else
9014 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009015 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009016 }
9017 return;
9018}
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309019
9020static void csrUpdateSnr(tpAniSirGlobal pMac, void* pMsg)
9021{
9022 tANI_S8 snr = 0;
9023 tAniGetSnrReq *pGetSnrReq = (tAniGetSnrReq*)pMsg;
9024
9025 if (pGetSnrReq)
9026 {
9027 if (VOS_STATUS_SUCCESS !=
9028 WDA_GetSnr(pGetSnrReq->staId, &snr))
9029 {
9030 smsLog(pMac, LOGE, FL("Error in WLANTL_GetSnr"));
9031 return;
9032 }
9033
9034 if (pGetSnrReq->snrCallback)
9035 {
9036 ((tCsrSnrCallback)(pGetSnrReq->snrCallback))(snr, pGetSnrReq->staId,
9037 pGetSnrReq->pDevContext);
9038 }
9039 else
9040 {
9041 smsLog(pMac, LOGE, FL("pGetSnrReq->snrCallback is NULL"));
9042 return;
9043 }
9044 }
9045 else
9046 {
9047 smsLog(pMac, LOGE, FL("pGetSnrReq is NULL"));
9048 }
9049 return;
9050}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009051#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009052void csrRoamRssiRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9053{
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009054 tAniGetRoamRssiRsp* pRoamRssiRsp = (tAniGetRoamRssiRsp*)pMsg;
9055
Jeff Johnson36d483b2013-04-08 11:08:53 -07009056 if (NULL != pRoamRssiRsp)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009057 {
Jeff Johnson36d483b2013-04-08 11:08:53 -07009058 /* Get roam Rssi request is backed up and passed back to the response,
9059 Extract the request message to fetch callback */
9060 tpAniGetRssiReq reqBkp = (tAniGetRssiReq*)pRoamRssiRsp->rssiReq;
9061 v_S7_t rssi = pRoamRssiRsp->rssi;
9062
9063 if ((NULL != reqBkp) && (NULL != reqBkp->rssiCallback))
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009064 {
9065 ((tCsrRssiCallback)(reqBkp->rssiCallback))(rssi, pRoamRssiRsp->staId, reqBkp->pDevContext);
9066 reqBkp->rssiCallback = NULL;
9067 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009068 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009069 }
9070 else
9071 {
9072 smsLog( pMac, LOGE, FL("reqBkp->rssiCallback is NULL"));
9073 if (NULL != reqBkp)
9074 {
9075 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009076 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009077 }
9078 }
9079 }
9080 else
9081 {
9082 smsLog( pMac, LOGE, FL("pRoamRssiRsp is NULL"));
9083 }
9084 return;
9085}
9086#endif
9087
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009088
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009089#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009090void csrTsmStatsRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9091{
9092 tAniGetTsmStatsRsp* pTsmStatsRsp = (tAniGetTsmStatsRsp*)pMsg;
9093
9094 if (NULL != pTsmStatsRsp)
9095 {
9096 /* Get roam Rssi request is backed up and passed back to the response,
9097 Extract the request message to fetch callback */
9098 tpAniGetTsmStatsReq reqBkp = (tAniGetTsmStatsReq*)pTsmStatsRsp->tsmStatsReq;
9099
9100 if (NULL != reqBkp)
9101 {
9102 if (NULL != reqBkp->tsmStatsCallback)
9103 {
9104 ((tCsrTsmStatsCallback)(reqBkp->tsmStatsCallback))(pTsmStatsRsp->tsmMetrics,
9105 pTsmStatsRsp->staId, reqBkp->pDevContext);
9106 reqBkp->tsmStatsCallback = NULL;
9107 }
9108 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009109 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009110 }
9111 else
9112 {
9113 smsLog( pMac, LOGE, FL("reqBkp is NULL"));
9114 if (NULL != reqBkp)
9115 {
9116 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009117 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009118 }
9119 }
9120 }
9121 else
9122 {
9123 smsLog( pMac, LOGE, FL("pTsmStatsRsp is NULL"));
9124 }
9125 return;
9126}
9127
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009128void csrSendEseAdjacentApRepInd(tpAniSirGlobal pMac, tCsrRoamSession *pSession)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009129{
9130 tANI_U32 roamTS2 = 0;
9131 tCsrRoamInfo roamInfo;
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009132 tpPESession pSessionEntry = NULL;
9133 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009134
9135 if (NULL == pSession)
9136 {
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009137 smsLog(pMac, LOGE, FL("pSession is NULL"));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009138 return;
9139 }
9140
9141 roamTS2 = vos_timer_get_system_time();
9142 roamInfo.tsmRoamDelay = roamTS2 - pSession->roamTS1;
Arif Hussaina7c8e412013-11-20 11:06:42 -08009143 smsLog(pMac, LOG1, "Bssid("MAC_ADDRESS_STR") Roaming Delay(%u ms)",
9144 MAC_ADDR_ARRAY(pSession->connectedProfile.bssid),
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009145 roamInfo.tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009146
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009147 pSessionEntry = peFindSessionByBssid(pMac, pSession->connectedProfile.bssid, &sessionId);
9148 if (NULL == pSessionEntry)
9149 {
9150 smsLog(pMac, LOGE, FL("session %d not found"), sessionId);
9151 return;
9152 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009153 pSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly = roamInfo.tsmRoamDelay;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009154 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009155 0, eCSR_ROAM_ESE_ADJ_AP_REPORT_IND, 0);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009156}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009157#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009158
Jeff Johnsone7245742012-09-05 17:12:55 -07009159static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
9160{
9161 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
9162 if(pTlRssiInd)
9163 {
9164 if(NULL != pTlRssiInd->tlCallback)
9165 {
9166 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -08009167 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07009168 }
9169 else
9170 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009171 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009172 }
9173 }
9174 else
9175 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009176 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009177 }
9178 return;
9179}
Jeff Johnson295189b2012-06-20 16:38:30 -07009180
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309181eHalStatus csrSendResetApCapsChanged(tpAniSirGlobal pMac, tSirMacAddr *bssId)
9182{
9183 tpSirResetAPCapsChange pMsg;
9184 tANI_U16 len;
9185 eHalStatus status = eHAL_STATUS_SUCCESS;
9186
9187 /* Create the message and send to lim */
9188 len = sizeof(tSirResetAPCapsChange);
Kiet Lam64c1b492013-07-12 13:56:44 +05309189 pMsg = vos_mem_malloc(len);
9190 if ( NULL == pMsg )
9191 status = eHAL_STATUS_FAILURE;
9192 else
9193 status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309194 if (HAL_STATUS_SUCCESS(status))
9195 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309196 vos_mem_set(pMsg, sizeof(tSirResetAPCapsChange), 0);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309197 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
9198 pMsg->length = len;
Kiet Lam64c1b492013-07-12 13:56:44 +05309199 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08009200 smsLog( pMac, LOG1, FL("CSR reset caps change for Bssid= "MAC_ADDRESS_STR),
9201 MAC_ADDR_ARRAY(pMsg->bssId));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309202 status = palSendMBMessage(pMac->hHdd, pMsg);
9203 }
9204 else
9205 {
9206 smsLog( pMac, LOGE, FL("Memory allocation failed\n"));
9207 }
9208 return status;
9209}
9210
Jeff Johnson295189b2012-06-20 16:38:30 -07009211void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
9212{
9213 tSirSmeAssocInd *pAssocInd;
9214 tSirSmeDisassocInd *pDisassocInd;
9215 tSirSmeDeauthInd *pDeauthInd;
9216 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
9217 tSirSmeNewBssInfo *pNewBss;
9218 tSmeIbssPeerInd *pIbssPeerInd;
9219 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
9220 tSirSmeApNewCaps *pApNewCaps;
9221 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
9222 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
9223 tCsrRoamInfo *pRoamInfo = NULL;
9224 tCsrRoamInfo roamInfo;
9225 eHalStatus status;
9226 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
9227 tCsrRoamSession *pSession = NULL;
9228 tpSirSmeSwitchChannelInd pSwitchChnInd;
9229 tSmeMaxAssocInd *pSmeMaxAssocInd;
Kiet Lam64c1b492013-07-12 13:56:44 +05309230 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
krunal soni587bf012014-02-04 12:35:11 -08009231
9232
9233 if (NULL == pSirMsg)
9234 { smsLog(pMac, LOGE, FL("pSirMsg is NULL"));
9235 return;
9236 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009237 switch( pSirMsg->messageType )
9238 {
9239 case eWNI_SME_ASSOC_IND:
9240 {
9241 tCsrRoamSession *pSession;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009242 smsLog( pMac, LOG1, FL("ASSOCIATION Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009243 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
9244 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
9245 if( HAL_STATUS_SUCCESS( status ) )
9246 {
9247 pSession = CSR_GET_SESSION(pMac, sessionId);
9248
Jeff Johnson32d95a32012-09-10 13:15:23 -07009249 if(!pSession)
9250 {
9251 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9252 return;
9253 }
9254
Jeff Johnson295189b2012-06-20 16:38:30 -07009255 pRoamInfo = &roamInfo;
9256
9257 // Required for indicating the frames to upper layer
9258 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
9259 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
9260
9261 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
9262 pRoamInfo->beaconLength = pAssocInd->beaconLength;
9263 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
9264 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9265
9266 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
9267 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
9268 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
9269
9270 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
9271 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05309272 vos_mem_copy(pRoamInfo->peerMac, pAssocInd->peerMacAddr,
9273 sizeof(tSirMacAddr));
9274 vos_mem_copy(&pRoamInfo->bssid, pAssocInd->bssId,
9275 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009276 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
9277 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07009278 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -07009279 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
9280 {
9281 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
9282 {
9283 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
9284 pSession->pConnectBssDesc,
9285 &(pRoamInfo->peerMac),
9286 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9287 pRoamInfo->fAuthRequired = FALSE;
9288 }
9289 else
9290 {
9291 pRoamInfo->fAuthRequired = TRUE;
9292 }
9293 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
9294 if (!HAL_STATUS_SUCCESS(status))
9295 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
9296 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009297 /* Send Association completion message to PE */
9298 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
9299
9300 /* send a message to CSR itself just to avoid the EAPOL frames going
9301 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -07009302 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
9303 {
9304 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9305 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009306 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
9307 {
9308 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
9309 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
9310 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9311 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009312 }
9313 }
9314 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009315 case eWNI_SME_DISASSOC_IND:
Jeff Johnson295189b2012-06-20 16:38:30 -07009316 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309317 // Check if AP dis-associated us because of MIC failure. If so,
9318 // then we need to take action immediately and not wait till the
9319 // the WmStatusChange requests is pushed and processed
9320 tSmeCmd *pCommand;
9321
9322 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
9323 status = csrRoamGetSessionIdFromBSSID( pMac,
9324 (tCsrBssid *)pDisassocInd->bssId, &sessionId );
9325 if( HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009326 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309327 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC"
9328 " for session %d "), sessionId);
9329 smsLog( pMac, LOGE, FL("DISASSOCIATION from peer ="
9330 MAC_ADDRESS_STR " "
9331 " reason = %d status = %d "),
9332 MAC_ADDR_ARRAY(pDisassocInd->peerMacAddr),
9333 pDisassocInd->reasonCode,
9334 pDisassocInd->statusCode);
9335 // If we are in neighbor preauth done state then on receiving
9336 // disassoc or deauth we dont roam instead we just disassoc
9337 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009338 // This happens for ESE and 11r FT connections ONLY.
Agarwal Ashish4f616132013-12-30 23:32:50 +05309339#ifdef WLAN_FEATURE_VOWIFI_11R
9340 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9341 {
9342 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9343 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009344#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009345#ifdef FEATURE_WLAN_ESE
9346 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Agarwal Ashish4f616132013-12-30 23:32:50 +05309347 {
9348 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9349 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009350#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009351#ifdef FEATURE_WLAN_LFR
Agarwal Ashish4f616132013-12-30 23:32:50 +05309352 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
9353 {
9354 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9355 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009356#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +05309357 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009358
Agarwal Ashish4f616132013-12-30 23:32:50 +05309359 if (!pSession)
9360 {
9361 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9362 return;
9363 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07009364
Agarwal Ashish4f616132013-12-30 23:32:50 +05309365 if ( csrIsConnStateInfra( pMac, sessionId ) )
9366 {
9367 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9368 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009369#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Agarwal Ashish4f616132013-12-30 23:32:50 +05309370 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009371#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +05309372 csrRoamLinkDown(pMac, sessionId);
9373 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
9374 if (CSR_IS_INFRA_AP(&pSession->connectedProfile))
9375 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309376 pRoamInfo = &roamInfo;
9377 pRoamInfo->statusCode = pDisassocInd->statusCode;
9378 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9379 pRoamInfo->staId = (tANI_U8)pDisassocInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009380
Agarwal Ashish4f616132013-12-30 23:32:50 +05309381 vos_mem_copy(pRoamInfo->peerMac, pDisassocInd->peerMacAddr,
9382 sizeof(tSirMacAddr));
9383 vos_mem_copy(&pRoamInfo->bssid, pDisassocInd->bssId,
9384 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009385
Agarwal Ashish4f616132013-12-30 23:32:50 +05309386 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9387 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DISASSOC_IND);
Jeff Johnson295189b2012-06-20 16:38:30 -07009388
Agarwal Ashish4f616132013-12-30 23:32:50 +05309389 /*
9390 * STA/P2P client got disassociated so remove any pending deauth
9391 * commands in sme pending list
9392 */
Kaushik, Sushant488df382014-03-05 11:43:47 +05309393 pCommand = csrGetCommandBuffer(pMac);
9394 if (NULL == pCommand)
9395 {
9396 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
9397 status = eHAL_STATUS_RESOURCES;
9398 return;
9399 }
Agarwal Ashish4f616132013-12-30 23:32:50 +05309400 pCommand->command = eSmeCommandRoam;
9401 pCommand->sessionId = (tANI_U8)sessionId;
9402 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
9403 vos_mem_copy(pCommand->u.roamCmd.peerMac,
9404 pDisassocInd->peerMacAddr,
9405 sizeof(tSirMacAddr));
9406 csrRoamRemoveDuplicateCommand(pMac, sessionId, pCommand, eCsrForcedDeauthSta);
9407 csrReleaseCommand( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07009408
Agarwal Ashish4f616132013-12-30 23:32:50 +05309409 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009410 }
Agarwal Ashish4f616132013-12-30 23:32:50 +05309411 else
9412 {
9413 smsLog(pMac, LOGE, FL(" Session Id not found for BSSID " MAC_ADDRESS_STR),
9414 MAC_ADDR_ARRAY(pDisassocInd->bssId));
9415 }
Kiet Lam82004c62013-11-11 13:24:28 +05309416 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009417 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009418 case eWNI_SME_DEAUTH_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009419 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009420 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
9421 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
9422 if( HAL_STATUS_SUCCESS( status ) )
9423 {
9424 // If we are in neighbor preauth done state then on receiving
9425 // disassoc or deauth we dont roam instead we just disassoc
9426 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009427 // This happens for ESE and 11r FT connections ONLY.
Jeff Johnson295189b2012-06-20 16:38:30 -07009428#ifdef WLAN_FEATURE_VOWIFI_11R
9429 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9430 {
9431 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9432 }
9433#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009434#ifdef FEATURE_WLAN_ESE
9435 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson295189b2012-06-20 16:38:30 -07009436 {
9437 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9438 }
9439#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009440#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05309441 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009442 {
9443 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9444 }
9445#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009446 pSession = CSR_GET_SESSION( pMac, sessionId );
9447
Jeff Johnson32d95a32012-09-10 13:15:23 -07009448 if(!pSession)
9449 {
9450 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9451 return;
9452 }
9453
Jeff Johnson295189b2012-06-20 16:38:30 -07009454 if ( csrIsConnStateInfra( pMac, sessionId ) )
9455 {
9456 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9457 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009458#ifndef WLAN_MDM_CODE_REDUCTION_OPT
9459 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
9460#endif
9461 csrRoamLinkDown(pMac, sessionId);
9462 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07009463 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
9464 {
9465
9466 pRoamInfo = &roamInfo;
9467
9468 pRoamInfo->statusCode = pDeauthInd->statusCode;
9469 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9470
9471 pRoamInfo->staId = (tANI_U8)pDeauthInd->staId;
9472
Kiet Lam64c1b492013-07-12 13:56:44 +05309473 vos_mem_copy(pRoamInfo->peerMac, pDeauthInd->peerMacAddr,
9474 sizeof(tSirMacAddr));
9475 vos_mem_copy(&pRoamInfo->bssid, pDeauthInd->bssId,
9476 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009477
9478 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DEAUTH_IND);
9479 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009480 }
9481 break;
9482
9483 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 -08009484 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009485 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
9486 //Update with the new channel id.
9487 //The channel id is hidden in the statusCode.
9488 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
9489 if( HAL_STATUS_SUCCESS( status ) )
9490 {
9491 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009492 if(!pSession)
9493 {
9494 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9495 return;
9496 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009497 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
9498 if(pSession->pConnectBssDesc)
9499 {
9500 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
9501 }
9502 }
9503 break;
9504
9505 case eWNI_SME_DEAUTH_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009506 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009507 {
9508 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
9509 sessionId = pDeauthRsp->sessionId;
9510 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9511 {
9512 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009513 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9514 {
9515 pRoamInfo = &roamInfo;
9516 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309517 vos_mem_copy(pRoamInfo->peerMac, pDeauthRsp->peerMacAddr,
9518 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009519 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9520 pRoamInfo->statusCode = pDeauthRsp->statusCode;
9521 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9522 }
9523 }
9524 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009525 break;
9526
9527 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009528 /* session id is invalid here so cant use it to access the array curSubstate as index */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009529 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -07009530 {
9531 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
9532 sessionId = pDisassocRsp->sessionId;
9533 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9534 {
9535 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009536 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9537 {
9538 pRoamInfo = &roamInfo;
9539 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309540 vos_mem_copy(pRoamInfo->peerMac, pDisassocRsp->peerMacAddr,
9541 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009542 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9543 pRoamInfo->statusCode = pDisassocRsp->statusCode;
9544 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9545 }
9546 }
9547 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009548 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009549 case eWNI_SME_MIC_FAILURE_IND:
9550 {
9551 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
9552 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
9553 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Leo Chang9b01ad92013-09-12 17:26:56 -07009554
9555 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
9556 if( HAL_STATUS_SUCCESS( status ) )
9557 {
Kiet Lamf2f201e2013-11-16 21:24:16 +05309558 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Leo Chang9b01ad92013-09-12 17:26:56 -07009559 roamInfo.u.pMICFailureInfo = &pMicInd->info;
9560 pRoamInfo = &roamInfo;
9561 if(pMicInd->info.multicast)
9562 {
9563 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
9564 }
9565 else
9566 {
9567 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
9568 }
9569 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
9570 }
9571
Jeff Johnson295189b2012-06-20 16:38:30 -07009572#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9573 {
lukez3c809222013-05-03 10:23:02 -07009574 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07009575 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009576 if(!pSession)
9577 {
9578 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9579 return;
9580 }
lukez3c809222013-05-03 10:23:02 -07009581
Kiet Lam64c1b492013-07-12 13:56:44 +05309582 vos_mem_set(&secEvent, sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009583 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
9584 secEvent.encryptionModeMulticast =
9585 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9586 secEvent.encryptionModeUnicast =
9587 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9588 secEvent.authMode =
9589 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309590 vos_mem_copy(secEvent.bssid,
9591 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009592 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
9593 }
9594#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009595 }
9596 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009597 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
9598 {
9599 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
9600 tCsrRoamInfo roamInfo;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009601 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009602
9603 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
9604 if( HAL_STATUS_SUCCESS( status ) )
9605 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309606 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009607 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
9608 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
9609 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
9610 }
9611 }
9612 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009613
Jeff Johnson295189b2012-06-20 16:38:30 -07009614 case eWNI_SME_WM_STATUS_CHANGE_NTF:
9615 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
9616 switch( pStatusChangeMsg->statusChangeCode )
9617 {
9618 case eSIR_SME_IBSS_ACTIVE:
9619 sessionId = csrFindIbssSession( pMac );
9620 if( CSR_SESSION_ID_INVALID != sessionId )
9621 {
9622 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009623 if(!pSession)
9624 {
9625 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9626 return;
9627 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009628 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
9629 if(pSession->pConnectBssDesc)
9630 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309631 vos_mem_copy(&roamInfo.bssid,
9632 pSession->pConnectBssDesc->bssId,
9633 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009634 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
9635 pRoamInfo = &roamInfo;
9636 }
9637 else
9638 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009639 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009640 }
9641 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
9642 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9643 }
9644 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009645 case eSIR_SME_IBSS_INACTIVE:
9646 sessionId = csrFindIbssSession( pMac );
9647 if( CSR_SESSION_ID_INVALID != sessionId )
9648 {
9649 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009650 if(!pSession)
9651 {
9652 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9653 return;
9654 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009655 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
9656 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
9657 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9658 }
9659 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009660 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
9661 sessionId = csrFindIbssSession( pMac );
9662 if( CSR_SESSION_ID_INVALID != sessionId )
9663 {
9664 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009665 if(!pSession)
9666 {
9667 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9668 return;
9669 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009670 // update the connection state information
9671 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009672#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9673 {
9674 vos_log_ibss_pkt_type *pIbssLog;
9675 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -07009676 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9677 if(pIbssLog)
9678 {
9679 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
9680 if(pNewBss)
9681 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309682 vos_mem_copy(pIbssLog->bssid, pNewBss->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009683 if(pNewBss->ssId.length)
9684 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309685 vos_mem_copy(pIbssLog->ssid, pNewBss->ssId.ssId,
9686 pNewBss->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07009687 }
9688 pIbssLog->operatingChannel = pNewBss->channelNumber;
9689 }
9690 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
9691 {
9692 //***U8 is not enough for beacon interval
9693 pIbssLog->beaconInterval = (v_U8_t)bi;
9694 }
9695 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9696 }
9697 }
9698#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009699 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009700
9701 if ((eCSR_ENCRYPT_TYPE_NONE ==
9702 pSession->connectedProfile.EncryptionType ))
9703 {
9704 csrRoamIssueSetContextReq( pMac, sessionId,
9705 pSession->connectedProfile.EncryptionType,
9706 pSession->pConnectBssDesc,
9707 &Broadcastaddr,
9708 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
9709 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009710 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
9711 roamStatus = eCSR_ROAM_IBSS_IND;
Kiet Lam64c1b492013-07-12 13:56:44 +05309712 vos_mem_copy(&roamInfo.bssid, &pNewBss->bssId,
9713 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009714 pRoamInfo = &roamInfo;
9715 //This BSSID is th ereal BSSID, let's save it
9716 if(pSession->pConnectBssDesc)
9717 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309718 vos_mem_copy(pSession->pConnectBssDesc->bssId,
9719 &pNewBss->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009720 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009721 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009722 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Jeff Johnson295189b2012-06-20 16:38:30 -07009723 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009724 // detection by LIM that the capabilities of the associated AP have changed.
9725 case eSIR_SME_AP_CAPS_CHANGED:
9726 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009727 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED");
Jeff Johnson295189b2012-06-20 16:38:30 -07009728 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
9729 if( HAL_STATUS_SUCCESS( status ) )
9730 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009731 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
9732 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309733 (eCSR_ROAM_SUBSTATE_NONE == pMac->roam.curSubState[sessionId]) ||
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009734 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
9735 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
9736 )
9737 {
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309738 smsLog(pMac, LOGW, "Calling csrRoamDisconnectInternal");
9739 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009740 }
9741 else
9742 {
9743 smsLog(pMac, LOGW,
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05309744 FL("Skipping csrScanForCapabilityChange as "
9745 "CSR is in state %s and sub-state %s"),
9746 macTraceGetcsrRoamState(
9747 pMac->roam.curState[sessionId]),
9748 macTraceGetcsrRoamSubState(
9749 pMac->roam.curSubState[sessionId]));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309750 /* We ignore the caps change event if CSR is not in full connected state.
9751 * Send one event to PE to reset limSentCapsChangeNtf
9752 * Once limSentCapsChangeNtf set 0, lim can send sub sequent CAPS change event
9753 * otherwise lim cannot send any CAPS change events to SME */
9754 csrSendResetApCapsChanged(pMac, &pApNewCaps->bssId);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009755 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009756 }
9757 break;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309758
Jeff Johnson295189b2012-06-20 16:38:30 -07009759 default:
9760 roamStatus = eCSR_ROAM_FAILED;
9761 result = eCSR_ROAM_RESULT_NONE;
9762 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009763 } // end switch on statusChangeCode
9764 if(eCSR_ROAM_RESULT_NONE != result)
9765 {
9766 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
9767 }
9768 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009769 case eWNI_SME_IBSS_NEW_PEER_IND:
9770 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07009771#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9772 {
9773 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07009774 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9775 if(pIbssLog)
9776 {
9777 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309778 vos_mem_copy(pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009779 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9780 }
9781 }
9782#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009783 sessionId = csrFindIbssSession( pMac );
9784 if( CSR_SESSION_ID_INVALID != sessionId )
9785 {
9786 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009787
9788 if(!pSession)
9789 {
9790 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9791 return;
9792 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009793 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
9794 if(pSession->pConnectBssDesc)
9795 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309796 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
9797 sizeof(tCsrBssid));
9798 vos_mem_copy(&roamInfo.bssid, pSession->pConnectBssDesc->bssId,
9799 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009800 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
9801 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309802 roamInfo.pbFrames = vos_mem_malloc((pIbssPeerInd->mesgLen
9803 - sizeof(tSmeIbssPeerInd)));
9804 if ( NULL == roamInfo.pbFrames )
9805 status = eHAL_STATUS_FAILURE;
9806 else
9807 status = eHAL_STATUS_SUCCESS;
9808 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07009809 {
9810 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
Kiet Lam64c1b492013-07-12 13:56:44 +05309811 vos_mem_copy(roamInfo.pbFrames,
9812 ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
9813 roamInfo.nBeaconLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07009814 }
9815 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9816 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9817 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05309818 roamInfo.pBssDesc = vos_mem_malloc(pSession->pConnectBssDesc->length);
9819 if ( NULL == roamInfo.pBssDesc )
9820 status = eHAL_STATUS_FAILURE;
9821 else
9822 status = eHAL_STATUS_SUCCESS;
9823 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07009824 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309825 vos_mem_copy(roamInfo.pBssDesc,
9826 pSession->pConnectBssDesc,
9827 pSession->pConnectBssDesc->length);
Jeff Johnson295189b2012-06-20 16:38:30 -07009828 }
9829 if(HAL_STATUS_SUCCESS(status))
9830 {
9831 pRoamInfo = &roamInfo;
9832 }
9833 else
9834 {
9835 if(roamInfo.pbFrames)
9836 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309837 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -07009838 }
9839 if(roamInfo.pBssDesc)
9840 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309841 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07009842 }
9843 }
9844 }
9845 else
9846 {
9847 pRoamInfo = &roamInfo;
9848 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009849 if ((eCSR_ENCRYPT_TYPE_NONE ==
9850 pSession->connectedProfile.EncryptionType ))
9851 {
9852 csrRoamIssueSetContextReq( pMac, sessionId,
9853 pSession->connectedProfile.EncryptionType,
9854 pSession->pConnectBssDesc,
9855 &(pIbssPeerInd->peerAddr),
9856 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9857 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009858 }
9859 else
9860 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009861 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009862 }
9863 //send up the sec type for the new peer
9864 if (pRoamInfo)
9865 {
9866 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9867 }
9868 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9869 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
9870 if(pRoamInfo)
9871 {
9872 if(roamInfo.pbFrames)
9873 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309874 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -07009875 }
9876 if(roamInfo.pBssDesc)
9877 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309878 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07009879 }
9880 }
9881 }
9882 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009883 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
9884 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
9885 sessionId = csrFindIbssSession( pMac );
9886 if( CSR_SESSION_ID_INVALID != sessionId )
9887 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009888#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9889 {
9890 vos_log_ibss_pkt_type *pIbssLog;
9891
9892 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9893 if(pIbssLog)
9894 {
9895 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
9896 if(pIbssPeerInd)
9897 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309898 vos_mem_copy(pIbssLog->peerMacAddr,
9899 &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009900 }
9901 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9902 }
9903 }
9904#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009905 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM");
Jeff Johnson295189b2012-06-20 16:38:30 -07009906 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9907 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9908 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05309909 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
9910 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009911 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9912 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
9913 }
9914 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009915 case eWNI_SME_SETCONTEXT_RSP:
9916 {
9917 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
9918 tListElem *pEntry;
9919 tSmeCmd *pCommand;
9920
9921 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9922 if ( pEntry )
9923 {
9924 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9925 if ( eSmeCommandSetKey == pCommand->command )
9926 {
Sandeep Puligilla9f384742014-04-11 02:27:04 +05309927 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009928 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009929
9930 if(!pSession)
9931 {
9932 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9933 return;
9934 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009935
9936#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9937 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
9938 {
9939 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +05309940 vos_mem_set(&setKeyEvent,
9941 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009942 if( pRsp->peerMacAddr[0] & 0x01 )
9943 {
9944 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
9945 }
9946 else
9947 {
9948 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
9949 }
9950 setKeyEvent.encryptionModeMulticast =
9951 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9952 setKeyEvent.encryptionModeUnicast =
9953 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309954 vos_mem_copy(setKeyEvent.bssid,
9955 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009956 setKeyEvent.authMode =
9957 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -07009958 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009959 {
9960 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9961 }
9962 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9963 }
9964#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
9965 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
9966 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009967 csrRoamStopWaitForKeyTimer( pMac );
9968
Jeff Johnson295189b2012-06-20 16:38:30 -07009969 //We are done with authentication, whethere succeed or not
9970 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009971 //We do it here because this linkup function is not called after association
9972 //when a key needs to be set.
9973 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
9974 {
9975 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
9976 }
9977 }
Jeff Johnson43971f52012-07-17 12:26:56 -07009978 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009979 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309980 vos_mem_copy(&roamInfo.peerMac,
9981 &pRsp->peerMacAddr, sizeof(tCsrBssid));
Jeff Johnsone7245742012-09-05 17:12:55 -07009982 //Make sure we install the GTK before indicating to HDD as authenticated
9983 //This is to prevent broadcast packets go out after PTK and before GTK.
Kiet Lam64c1b492013-07-12 13:56:44 +05309984 if ( vos_mem_compare( &Broadcastaddr, pRsp->peerMacAddr,
9985 sizeof(tSirMacAddr) ) )
Jeff Johnsone7245742012-09-05 17:12:55 -07009986 {
Yathish9f22e662012-12-10 14:21:35 -08009987#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
9988 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
9989 {
9990 tpSirSetActiveModeSetBncFilterReq pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +05309991 pMsg = vos_mem_malloc(sizeof(tSirSetActiveModeSetBncFilterReq));
Yathish9f22e662012-12-10 14:21:35 -08009992 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
9993 pMsg->length = pal_cpu_to_be16(sizeof( tANI_U8));
9994 pMsg->seesionId = sessionId;
9995 status = palSendMBMessage(pMac->hHdd, pMsg );
9996 }
9997#endif
Sandeep Puligilla9f384742014-04-11 02:27:04 +05309998 /* OBSS SCAN Indication will be sent to Firmware to start OBSS Scan */
Sandeep Puligilla332ea912014-02-04 00:16:24 +05309999 if( CSR_IS_CHANNEL_24GHZ(pSession->connectedProfile.operationChannel)
10000 && IS_HT40_OBSS_SCAN_FEATURE_ENABLE )
10001 {
10002 tpSirSmeHT40OBSSScanInd pMsg;
10003 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSScanInd));
10004 pMsg->messageType =
10005 pal_cpu_to_be16((tANI_U16)eWNI_SME_HT40_OBSS_SCAN_IND);
10006 pMsg->length =
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010007 pal_cpu_to_be16(sizeof( tSirSmeHT40OBSSScanInd));
10008 vos_mem_copy(pMsg->peerMacAddr,
10009 pSession->connectedProfile.bssid,
10010 sizeof(tSirMacAddr));
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010011 status = palSendMBMessage(pMac->hHdd,
10012 pMsg );
10013 }
10014 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -070010015 }
10016 else
10017 {
10018 result = eCSR_ROAM_RESULT_NONE;
10019 }
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010020 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010021 }
10022 else
10023 {
10024 result = eCSR_ROAM_RESULT_FAILURE;
Arif Hussaina7c8e412013-11-20 11:06:42 -080010025 smsLog(pMac, LOGE, "CSR: Roam Completion setkey "
10026 "command failed(%d) PeerMac "MAC_ADDRESS_STR,
10027 pRsp->statusCode, MAC_ADDR_ARRAY(pRsp->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070010028 }
10029 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10030 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -070010031 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
10032 // can go ahead and initiate the TSPEC if any are pending
10033 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010034#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070010035 //Send Adjacent AP repot to new AP.
10036 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
10037 pSession->isPrevApInfoValid &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010038 pSession->connectedProfile.isESEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070010039 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010040#ifdef FEATURE_WLAN_ESE_UPLOAD
10041 csrSendEseAdjacentApRepInd(pMac, pSession);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010042#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010043 csrEseSendAdjacentApRepMsg(pMac, pSession);
Jeff Johnson295189b2012-06-20 16:38:30 -070010044#endif
10045 pSession->isPrevApInfoValid = FALSE;
10046 }
10047#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010048 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10049 {
10050 csrReleaseCommandSetKey( pMac, pCommand );
10051 }
10052 }
10053 else
10054 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010055 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010056 }
10057 }
10058 else
10059 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010060 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010061 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010062 smeProcessPendingQueue( pMac );
10063 }
10064 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010065 case eWNI_SME_REMOVEKEY_RSP:
10066 {
10067 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
10068 tListElem *pEntry;
10069 tSmeCmd *pCommand;
10070
10071 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10072 if ( pEntry )
10073 {
10074 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10075 if ( eSmeCommandRemoveKey == pCommand->command )
10076 {
10077 sessionId = pCommand->sessionId;
10078 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010079
10080 if(!pSession)
10081 {
10082 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10083 return;
10084 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010085#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10086 {
10087 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053010088 vos_mem_set(&removeKeyEvent,
10089 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010090 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
10091 removeKeyEvent.encryptionModeMulticast =
10092 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10093 removeKeyEvent.encryptionModeUnicast =
10094 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010095 vos_mem_copy( removeKeyEvent.bssid,
10096 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010097 removeKeyEvent.authMode =
10098 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -070010099 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010100 {
10101 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10102 }
10103 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
10104 }
10105#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -070010106 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010107 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010108 vos_mem_copy(&roamInfo.peerMac, &pRsp->peerMacAddr,
10109 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010110 result = eCSR_ROAM_RESULT_NONE;
10111 pRoamInfo = &roamInfo;
10112 }
10113 else
10114 {
10115 result = eCSR_ROAM_RESULT_FAILURE;
10116 }
10117 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10118 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
10119 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10120 {
10121 csrReleaseCommandRemoveKey( pMac, pCommand );
10122 }
10123 }
10124 else
10125 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010126 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010127 }
10128 }
10129 else
10130 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010131 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010132 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010133 smeProcessPendingQueue( pMac );
10134 }
10135 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010136 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010137 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010138 csrRoamStatsRspProcessor( pMac, pSirMsg );
10139 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010140#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080010141 case eWNI_SME_GET_ROAM_RSSI_RSP:
10142 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
10143 csrRoamRssiRspProcessor( pMac, pSirMsg );
10144 break;
10145#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010146#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010147 case eWNI_SME_GET_TSM_STATS_RSP:
10148 smsLog( pMac, LOG2, FL("TSM Stats rsp from PE"));
10149 csrTsmStatsRspProcessor( pMac, pSirMsg );
10150 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010151#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -070010152 case eWNI_SME_GET_RSSI_REQ:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010153 smsLog( pMac, LOG2, FL("GetRssiReq from self"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010154 csrUpdateRssi( pMac, pSirMsg );
10155 break;
10156
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053010157 case eWNI_SME_GET_SNR_REQ:
10158 smsLog( pMac, LOG2, FL("GetSnrReq from self"));
10159 csrUpdateSnr(pMac, pSirMsg);
10160 break;
10161
Jeff Johnson295189b2012-06-20 16:38:30 -070010162#ifdef WLAN_FEATURE_VOWIFI_11R
10163 case eWNI_SME_FT_PRE_AUTH_RSP:
10164 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
10165 break;
10166#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010167 case eWNI_SME_MAX_ASSOC_EXCEEDED:
10168 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010169 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 -070010170 sessionId = pSmeMaxAssocInd->sessionId;
10171 roamInfo.sessionId = sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053010172 vos_mem_copy(&roamInfo.peerMac, pSmeMaxAssocInd->peerMac,
10173 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010174 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
10175 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
10176 break;
10177
10178 case eWNI_SME_BTAMP_LOG_LINK_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010179 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010180 btampEstablishLogLinkHdlr( pSirMsg );
10181 break;
Jeff Johnsone7245742012-09-05 17:12:55 -070010182 case eWNI_SME_RSSI_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010183 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread"));
Jeff Johnsone7245742012-09-05 17:12:55 -070010184 csrRoamRssiIndHdlr( pMac, pSirMsg );
10185 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010186#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
10187 case eWNI_SME_CANDIDATE_FOUND_IND:
10188 smsLog( pMac, LOG2, FL("Candidate found indication from PE"));
10189 csrNeighborRoamCandidateFoundIndHdlr( pMac, pSirMsg );
10190 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070010191 case eWNI_SME_HANDOFF_REQ:
10192 smsLog( pMac, LOG2, FL("Handoff Req from self"));
10193 csrNeighborRoamHandoffReqHdlr( pMac, pSirMsg );
10194 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010195#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010196
10197 default:
10198 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010199 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -070010200}
10201
Jeff Johnson295189b2012-06-20 16:38:30 -070010202void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
10203 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
10204{
10205 if(pSession)
10206 {
10207 if(pSession->bRefAssocStartCnt)
10208 {
10209 pSession->bRefAssocStartCnt--;
10210 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
10211 //Need to call association_completion because there is an assoc_start pending.
10212 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
10213 eCSR_ROAM_ASSOCIATION_COMPLETION,
10214 eCSR_ROAM_RESULT_FAILURE);
10215 }
10216 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
10217 }
10218 else
10219 {
10220 smsLog(pMac, LOGW, FL(" pSession is NULL"));
10221 }
10222}
10223
10224
10225eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
10226{
10227 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010228 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
10229 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
10230 {
10231 status = csrScanRequestLostLink1( pMac, sessionId );
10232 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010233 return(status);
10234}
10235
Jeff Johnson295189b2012-06-20 16:38:30 -070010236//return a boolean to indicate whether roaming completed or continue.
10237tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
10238 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
10239{
10240 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
10241 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
10242 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10243 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010244 if(!pSession)
10245 {
10246 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10247 return eANI_BOOLEAN_FALSE;
10248 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010249 //Check whether time is up
10250 if(pSession->fCancelRoaming || fForce ||
10251 ((curTime - pSession->roamingStartTime) > roamTime) ||
10252 eCsrReassocRoaming == pSession->roamingReason ||
10253 eCsrDynamicRoaming == pSession->roamingReason)
10254 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010255 smsLog(pMac, LOGW, FL(" indicates roaming completion"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010256 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
10257 {
10258 //roaming is cancelled, tell HDD to indicate disconnect
10259 //Because LIM overload deauth_ind for both deauth frame and missed beacon
10260 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
10261 //to be eSIR_BEACON_MISSED
10262 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
10263 {
10264 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10265 }
10266 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
10267 {
10268 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
10269 }
10270 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
10271 {
10272 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
10273 }
10274 else
10275 {
10276 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10277 }
10278 }
10279 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10280 pSession->roamingReason = eCsrNotRoaming;
10281 }
10282 else
10283 {
10284 pSession->roamResult = roamResult;
10285 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
10286 {
10287 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10288 pSession->roamingReason = eCsrNotRoaming;
10289 }
10290 else
10291 {
10292 fCompleted = eANI_BOOLEAN_FALSE;
10293 }
10294 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010295 return(fCompleted);
10296}
10297
Jeff Johnson295189b2012-06-20 16:38:30 -070010298void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
10299{
10300 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010301
10302 if(!pSession)
10303 {
10304 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10305 return;
10306 }
10307
Jeff Johnson295189b2012-06-20 16:38:30 -070010308 if(CSR_IS_ROAMING(pSession))
10309 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010310 smsLog(pMac, LOGW, " Cancelling roaming");
Jeff Johnson295189b2012-06-20 16:38:30 -070010311 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
10312 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
10313 {
10314 //No need to do anything in here because the handler takes care of it
10315 }
10316 else
10317 {
10318 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
10319 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
10320 //Roaming is stopped after here
10321 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
10322 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053010323 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010324 csrRoamStopRoamingTimer(pMac, sessionId);
10325 }
10326 }
10327}
10328
Jeff Johnson295189b2012-06-20 16:38:30 -070010329void csrRoamRoamingTimerHandler(void *pv)
10330{
10331 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10332 tpAniSirGlobal pMac = pInfo->pMac;
10333 tANI_U32 sessionId = pInfo->sessionId;
10334 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010335
10336 if(!pSession)
10337 {
10338 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10339 return;
10340 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010341
10342 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
10343 {
10344 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
10345 {
10346 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
10347 pSession->roamingReason = eCsrNotRoaming;
10348 }
10349 }
10350}
10351
Jeff Johnson295189b2012-06-20 16:38:30 -070010352eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
10353{
10354 eHalStatus status;
10355 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010356
10357 if(!pSession)
10358 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010359 smsLog(pMac, LOGE, FL(" session %d not found"), sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -070010360 return eHAL_STATUS_FAILURE;
10361 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010362
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010363 smsLog(pMac, LOG1, " csrScanStartRoamingTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070010364 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010365 status = vos_timer_start(&pSession->hTimerRoaming, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010366
10367 return (status);
10368}
10369
Jeff Johnson295189b2012-06-20 16:38:30 -070010370eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
10371{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010372 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerRoaming));
Jeff Johnson295189b2012-06-20 16:38:30 -070010373}
10374
Jeff Johnson295189b2012-06-20 16:38:30 -070010375void csrRoamWaitForKeyTimeOutHandler(void *pv)
10376{
10377 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10378 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010379 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080010380 eHalStatus status = eHAL_STATUS_FAILURE;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010381
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010382 smsLog(pMac, LOGW, FL("WaitForKey timer expired in state=%s sub-state=%s"),
10383 macTraceGetNeighbourRoamState(
10384 pMac->roam.neighborRoamInfo.neighborRoamState),
10385 macTraceGetcsrRoamSubState(
10386 pMac->roam.curSubState[pInfo->sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010387
Jeff Johnson295189b2012-06-20 16:38:30 -070010388 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
10389 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010390#ifdef FEATURE_WLAN_LFR
10391 if (csrNeighborRoamIsHandoffInProgress(pMac))
10392 {
10393 /*
10394 * Enable heartbeat timer when hand-off is in progress
10395 * and Key Wait timer expired.
10396 */
10397 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010398 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010399 pMac->roam.configParam.HeartbeatThresh24);
10400 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10401 pMac->roam.configParam.HeartbeatThresh24,
10402 NULL, eANI_BOOLEAN_FALSE);
10403 }
10404#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010405 smsLog(pMac, LOGW, " SME pre-auth state timeout. ");
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010406
Jeff Johnson295189b2012-06-20 16:38:30 -070010407 //Change the substate so command queue is unblocked.
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010408 if (CSR_ROAM_SESSION_MAX > pInfo->sessionId)
10409 {
10410 csrRoamSubstateChange(pMac, eCSR_ROAM_SUBSTATE_NONE,
10411 pInfo->sessionId);
10412 }
10413
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010414 if (pSession)
10415 {
10416 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
10417 {
10418 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10419 smeProcessPendingQueue(pMac);
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080010420 if( (pSession->connectedProfile.AuthType ==
10421 eCSR_AUTH_TYPE_SHARED_KEY) &&
10422 ( (pSession->connectedProfile.EncryptionType ==
10423 eCSR_ENCRYPT_TYPE_WEP40) ||
10424 (pSession->connectedProfile.EncryptionType ==
10425 eCSR_ENCRYPT_TYPE_WEP104) ))
10426 {
10427 status = sme_AcquireGlobalLock( &pMac->sme );
10428 if ( HAL_STATUS_SUCCESS( status ) )
10429 {
10430 csrRoamDisconnect( pMac, pInfo->sessionId,
10431 eCSR_DISCONNECT_REASON_UNSPECIFIED );
10432 sme_ReleaseGlobalLock( &pMac->sme );
10433 }
10434 }
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010435 }
10436 else
10437 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010438 smsLog(pMac, LOGW, "%s: could not post link up",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010439 __func__);
10440 }
10441 }
10442 else
10443 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010444 smsLog(pMac, LOGW, "%s: session not found", __func__);
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010445 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010446 }
10447
10448}
10449
Jeff Johnson295189b2012-06-20 16:38:30 -070010450eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
10451{
10452 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010453#ifdef FEATURE_WLAN_LFR
10454 if (csrNeighborRoamIsHandoffInProgress(pMac))
10455 {
10456 /* Disable heartbeat timer when hand-off is in progress */
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010457 smsLog(pMac, LOG2, FL("disabling HB timer in state=%s sub-state=%s"),
10458 macTraceGetNeighbourRoamState(
10459 pMac->roam.neighborRoamInfo.neighborRoamState),
10460 macTraceGetcsrRoamSubState(
10461 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]
10462 ));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010463 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
10464 }
10465#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010466 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010467 status = vos_timer_start(&pMac->roam.hTimerWaitForKey, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010468
10469 return (status);
10470}
10471
Jeff Johnson295189b2012-06-20 16:38:30 -070010472eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
10473{
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010474 smsLog(pMac, LOG2, FL("WaitForKey timer stopped in state=%s sub-state=%s"),
10475 macTraceGetNeighbourRoamState(
10476 pMac->roam.neighborRoamInfo.neighborRoamState),
10477 macTraceGetcsrRoamSubState(
10478 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010479#ifdef FEATURE_WLAN_LFR
10480 if (csrNeighborRoamIsHandoffInProgress(pMac))
10481 {
10482 /*
10483 * Enable heartbeat timer when hand-off is in progress
10484 * and Key Wait timer got stopped for some reason
10485 */
10486 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010487 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010488 pMac->roam.configParam.HeartbeatThresh24);
10489 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10490 pMac->roam.configParam.HeartbeatThresh24,
10491 NULL, eANI_BOOLEAN_FALSE);
10492 }
10493#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010494 return (vos_timer_stop(&pMac->roam.hTimerWaitForKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070010495}
10496
Jeff Johnson295189b2012-06-20 16:38:30 -070010497void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
10498 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
10499{
10500 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
10501 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010502 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
10503 /* To silence the KW tool Null chaeck is added */
10504 if(!pSession)
10505 {
10506 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10507 return;
10508 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010509
10510 if(pCommand)
10511 {
10512 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010513 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070010514 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010515 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
10516 {
10517 //if success, force roaming completion
10518 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
10519 }
10520 else
10521 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010522 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010523 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d"), roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -070010524 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
10525 }
10526}
10527
Jeff Johnson295189b2012-06-20 16:38:30 -070010528eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
10529{
10530 eHalStatus status = eHAL_STATUS_SUCCESS;
10531 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
10532 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
10533 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
10534 tCsrRoamInfo *pRoamInfo = NULL;
10535 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010536 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -070010537 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010538 /* To silence the KW tool Null chaeck is added */
10539 if(!pSession)
10540 {
10541 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10542 return eHAL_STATUS_FAILURE;
10543 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010544 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010545 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -070010546 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
10547 if ( eWNI_SME_DISASSOC_IND == type )
10548 {
10549 result = eCSR_ROAM_RESULT_DISASSOC_IND;
10550 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
10551 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010552 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010553 }
10554 else if ( eWNI_SME_DEAUTH_IND == type )
10555 {
10556 result = eCSR_ROAM_RESULT_DEAUTH_IND;
10557 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
10558 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Madan Mohan Koyyalamudi6a808932012-11-06 16:05:54 -080010559 /* Convert into proper reason code */
10560 pSession->joinFailStatusCode.reasonCode =
10561 (pDeauthIndMsg->reasonCode == eSIR_BEACON_MISSED) ?
Agarwal Ashish838f1f32013-03-11 20:54:52 +053010562 0 : pDeauthIndMsg->reasonCode;
10563 /* cfg layer expects 0 as reason code if
10564 the driver dosent know the reason code
10565 eSIR_BEACON_MISSED is defined as locally */
Jeff Johnson295189b2012-06-20 16:38:30 -070010566 }
10567 else
10568 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010569 smsLog(pMac, LOGW, FL("gets an unknown type (%d)"), type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010570 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010571 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070010572 }
10573
10574 // call profile lost link routine here
Jeff Johnson295189b2012-06-20 16:38:30 -070010575 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -070010576 {
10577 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_LOSTLINK_DETECTED, result);
10578 }
10579
10580 if ( eWNI_SME_DISASSOC_IND == type )
10581 {
10582 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
10583 }
10584 else if ( eWNI_SME_DEAUTH_IND == type )
10585 {
10586 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
10587 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010588 if(!HAL_STATUS_SUCCESS(status))
10589 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010590 //If fail to send confirmation to PE, not to trigger roaming
10591 fToRoam = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010592 }
10593
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010594 //prepare to tell HDD to disconnect
Kiet Lam64c1b492013-07-12 13:56:44 +053010595 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010596 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10597 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010598 if( eWNI_SME_DISASSOC_IND == type)
10599 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010600 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010601 vos_mem_copy(roamInfo.peerMac, pDisassocIndMsg->peerMacAddr,
10602 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010603 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
10604 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010605 else if( eWNI_SME_DEAUTH_IND == type )
10606 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010607 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010608 vos_mem_copy(roamInfo.peerMac, pDeauthIndMsg->peerMacAddr,
10609 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010610 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
10611 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010612 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)"), roamInfo.staId);
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010613
10614 /* See if we can possibly roam. If so, start the roaming process and notify HDD
10615 that we are roaming. But if we cannot possibly roam, or if we are unable to
10616 currently roam, then notify HDD of the lost link */
Jeff Johnson295189b2012-06-20 16:38:30 -070010617 if(fToRoam)
10618 {
10619 //Only remove the connected BSS in infrastructure mode
10620 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10621 //Not to do anying for lostlink with WDS
10622 if( pMac->roam.configParam.nRoamingTime )
10623 {
10624 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
10625 ( eWNI_SME_DEAUTH_IND == type ) ?
10626 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
10627 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010628 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010629 //For IBSS, we need to give some more info to HDD
10630 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
10631 {
10632 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
10633 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10634 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
10635 }
10636 else
10637 {
10638 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
10639 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010640 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010641 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
10642 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
10643 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10644 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
10645 }
10646 else
10647 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010648 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010649 fToRoam = eANI_BOOLEAN_FALSE;
10650 }
10651 }
10652 else
10653 {
10654 //We are told not to roam, indicate lostlink
10655 fToRoam = eANI_BOOLEAN_FALSE;
10656 }
10657 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010658 if(!fToRoam)
10659 {
Madan Mohan Koyyalamudiaf854cf2012-10-30 17:56:25 -070010660 //Tell HDD about the lost link
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010661 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010662 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010663 /* Don't call csrRoamCallCallback for GO/SoftAp case as this indication
10664 * was already given as part of eWNI_SME_DISASSOC_IND msg handling in
10665 * csrRoamCheckForLinkStatusChange API.
10666 */
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010667 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
10668 }
10669
10670 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -070010671 Still enable idle scan for polling in case concurrent sessions are running */
10672 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
10673 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010674 csrScanStartIdleScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010675 }
10676 }
10677
10678 return (status);
10679}
10680
Jeff Johnson295189b2012-06-20 16:38:30 -070010681eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
10682{
10683 eHalStatus status = eHAL_STATUS_SUCCESS;
10684 tListElem *pEntry = NULL;
10685 tSmeCmd *pCommand = NULL;
10686 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010687
10688 if(!pSession)
10689 {
10690 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10691 return eHAL_STATUS_FAILURE;
10692 }
10693
Jeff Johnson295189b2012-06-20 16:38:30 -070010694 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010695 //Only remove the connected BSS in infrastructure mode
10696 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10697 if(pMac->roam.configParam.nRoamingTime)
10698 {
10699 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
10700 {
10701 //before starting the lost link logic release the roam command for handoff
10702 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
10703 if(pEntry)
10704 {
10705 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
10706 }
10707 if(pCommand)
10708 {
10709 if (( eSmeCommandRoam == pCommand->command ) &&
10710 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
10711 {
10712 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10713 {
10714 csrReleaseCommandRoam( pMac, pCommand );
10715 }
10716 }
10717 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010718 smsLog( pMac, LOGW, "Lost link roaming started ...");
Jeff Johnson295189b2012-06-20 16:38:30 -070010719 }
10720 }
10721 else
10722 {
10723 //We are told not to roam, indicate lostlink
10724 status = eHAL_STATUS_FAILURE;
10725 }
10726
10727 return (status);
10728}
Jeff Johnson295189b2012-06-20 16:38:30 -070010729void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
10730{
10731 tListElem *pEntry;
10732 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070010733 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10734 if ( pEntry )
10735 {
10736 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10737 if ( eSmeCommandWmStatusChange == pCommand->command )
10738 {
10739 // Nothing to process in a Lost Link completion.... It just kicks off a
10740 // roaming sequence.
10741 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10742 {
10743 csrReleaseCommandWmStatusChange( pMac, pCommand );
10744 }
10745 else
10746 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010747 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command");
Jeff Johnson295189b2012-06-20 16:38:30 -070010748 }
10749
10750 }
10751 else
10752 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010753 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010754 }
10755 }
10756 else
10757 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010758 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010759 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010760 smeProcessPendingQueue( pMac );
10761}
10762
Jeff Johnson295189b2012-06-20 16:38:30 -070010763void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
10764{
10765 eHalStatus status = eHAL_STATUS_FAILURE;
10766 tSirSmeRsp *pSirSmeMsg;
10767 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010768
10769 if(!pSession)
10770 {
10771 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
10772 return;
10773 }
10774
Jeff Johnson295189b2012-06-20 16:38:30 -070010775 switch ( pCommand->u.wmStatusChangeCmd.Type )
10776 {
10777 case eCsrDisassociated:
10778 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
10779 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
10780 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010781 case eCsrDeauthenticated:
10782 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
10783 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
10784 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010785 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010786 smsLog(pMac, LOGW, FL("gets an unknown command %d"), pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010787 break;
10788 }
10789 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
10790 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
10791 {
10792 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
10793 {
10794 //This is not good
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010795 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010796 }
10797 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010798 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
10799 // command here since there is nothing else to do.
10800 csrRoamWmStatusChangeComplete( pMac );
10801}
10802
Jeff Johnson295189b2012-06-20 16:38:30 -070010803//This function returns band and mode information.
10804//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
10805//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -070010806static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10807 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -070010808{
Jeff Johnson295189b2012-06-20 16:38:30 -070010809 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
10810 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
10811 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070010812 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -070010813
Jeff Johnson295189b2012-06-20 16:38:30 -070010814 //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 -070010815 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
10816 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
10817 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
10818 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -070010819 {
10820 switch( pMac->roam.configParam.uCfgDot11Mode )
10821 {
10822 case eCSR_CFG_DOT11_MODE_11A:
10823 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10824 eBand = eCSR_BAND_5G;
10825 break;
10826 case eCSR_CFG_DOT11_MODE_11B:
10827 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10828 eBand = eCSR_BAND_24;
10829 break;
10830 case eCSR_CFG_DOT11_MODE_11G:
10831 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10832 eBand = eCSR_BAND_24;
10833 break;
10834 case eCSR_CFG_DOT11_MODE_11N:
10835 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010836 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10837 break;
10838#ifdef WLAN_FEATURE_11AC
10839 case eCSR_CFG_DOT11_MODE_11AC:
10840 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10841 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010842 /* If the operating channel is in 2.4 GHz band, check for
10843 * INI item to disable VHT operation in 2.4 GHz band
10844 */
10845 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10846 !pMac->roam.configParam.enableVhtFor24GHz)
10847 {
10848 /* Disable 11AC operation */
10849 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10850 }
10851 else
10852 {
10853 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10854 }
10855 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010856 }
10857 else
10858 {
10859 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10860 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10861 }
10862 break;
10863 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
10864 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10865 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010866 /* If the operating channel is in 2.4 GHz band, check for
10867 * INI item to disable VHT operation in 2.4 GHz band
10868 */
10869 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10870 !pMac->roam.configParam.enableVhtFor24GHz)
10871 {
10872 /* Disable 11AC operation */
10873 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10874 }
10875 else
10876 {
10877 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
10878 }
10879 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010880 }
10881 else
10882 {
10883 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10884 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10885 }
10886 break;
10887#endif
10888 case eCSR_CFG_DOT11_MODE_AUTO:
10889 eBand = pMac->roam.configParam.eBand;
10890 if (eCSR_BAND_24 == eBand)
10891 {
10892 // WiFi tests require IBSS networks to start in 11b mode
10893 // without any change to the default parameter settings
10894 // on the adapter. We use ACU to start an IBSS through
10895 // creation of a startIBSS profile. This startIBSS profile
10896 // has Auto MACProtocol and the adapter property setting
10897 // for dot11Mode is also AUTO. So in this case, let's
10898 // start the IBSS network in 11b mode instead of 11g mode.
10899 // So this is for Auto=profile->MacProtocol && Auto=Global.
10900 // dot11Mode && profile->channel is < 14, then start the IBSS
10901 // in b mode.
10902 //
10903 // Note: we used to have this start as an 11g IBSS for best
10904 // performance... now to specify that the user will have to
10905 // set the do11Mode in the property page to 11g to force it.
10906 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10907 }
10908 else
10909 {
10910#ifdef WLAN_FEATURE_11AC
10911 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10912 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010913 /* If the operating channel is in 2.4 GHz band, check for
10914 * INI item to disable VHT operation in 2.4 GHz band
10915 */
10916 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10917 !pMac->roam.configParam.enableVhtFor24GHz)
10918 {
10919 /* Disable 11AC operation */
10920 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10921 }
10922 else
10923 {
10924 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10925 }
10926 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010927 }
10928 else
10929 {
10930 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10931 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10932 }
10933#else
10934 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10935 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10936#endif
10937 }
10938 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010939 default:
10940 // Global dot11 Mode setting is 11a/b/g.
10941 // use the channel number to determine the Mode setting.
10942 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10943 {
10944 eBand = pMac->roam.configParam.eBand;
10945 if(eCSR_BAND_24 == eBand)
10946 {
10947 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
10948 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10949 }
10950 else
10951 {
10952 //prefer 5GHz
10953 eBand = eCSR_BAND_5G;
10954 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10955 }
10956 }
10957 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10958 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070010959 // WiFi tests require IBSS networks to start in 11b mode
10960 // without any change to the default parameter settings
10961 // on the adapter. We use ACU to start an IBSS through
10962 // creation of a startIBSS profile. This startIBSS profile
10963 // has Auto MACProtocol and the adapter property setting
10964 // for dot11Mode is also AUTO. So in this case, let's
10965 // start the IBSS network in 11b mode instead of 11g mode.
10966 // So this is for Auto=profile->MacProtocol && Auto=Global.
10967 // dot11Mode && profile->channel is < 14, then start the IBSS
10968 // in b mode.
Jeff Johnson295189b2012-06-20 16:38:30 -070010969 //
Ravi Joshia96ceb42013-05-20 18:52:39 -070010970 // Note: we used to have this start as an 11g IBSS for best
10971 // performance... now to specify that the user will have to
10972 // set the do11Mode in the property page to 11g to force it.
Jeff Johnson295189b2012-06-20 16:38:30 -070010973 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10974 eBand = eCSR_BAND_24;
10975 }
10976 else
10977 {
10978 // else, it's a 5.0GHz channel. Set mode to 11a.
10979 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10980 eBand = eCSR_BAND_5G;
10981 }
10982 break;
10983 }//switch
10984 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
10985 else
10986 {
10987 //dot11 mode is set, lets pick the band
10988 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10989 {
10990 // channel is Auto also.
10991 eBand = pMac->roam.configParam.eBand;
10992 if(eCSR_BAND_ALL == eBand)
10993 {
10994 //prefer 5GHz
10995 eBand = eCSR_BAND_5G;
10996 }
10997 }
10998 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10999 {
11000 eBand = eCSR_BAND_24;
11001 }
11002 else
11003 {
11004 eBand = eCSR_BAND_5G;
11005 }
Ravi Joshia96ceb42013-05-20 18:52:39 -070011006 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011007 if(pBand)
11008 {
11009 *pBand = eBand;
11010 }
11011
11012 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011013 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -070011014 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11015 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011016
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080011017 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
11018 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 -070011019 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011020#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011021 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011022#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011023 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
11024 {
11025 //We cannot do 11n here
11026 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11027 {
11028 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
11029 }
11030 else
11031 {
11032 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11033 }
11034 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011035 return( cfgDot11Mode );
11036}
11037
Jeff Johnson295189b2012-06-20 16:38:30 -070011038eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
11039{
11040 eHalStatus status;
11041 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011042
11043 if(!pSession)
11044 {
11045 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11046 return eHAL_STATUS_FAILURE;
11047 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011048
11049#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11050 {
11051 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011052 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11053 if(pIbssLog)
11054 {
11055 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
11056 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11057 }
11058 }
11059#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011060 // Set the roaming substate to 'stop Bss request'...
11061 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
11062
11063 // attempt to stop the Bss (reason code is ignored...)
11064 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080011065 if(!HAL_STATUS_SUCCESS(status))
11066 {
11067 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
11068 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011069 return (status);
11070}
11071
Jeff Johnson295189b2012-06-20 16:38:30 -070011072//pNumChan is a caller allocated space with the sizeof pChannels
11073eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
11074{
11075
11076 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
11077 (tANI_U8 *)pChannels,
11078 pNumChan));
11079}
11080
Kiran4a17ebe2013-01-31 10:43:43 -080011081tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
11082{
11083 tANI_U32 cfgLength = 0;
11084 tANI_U16 cfgId = 0;
11085 tPowerdBm maxTxPwr = 0;
11086 tANI_U8 *pCountryInfo = NULL;
11087 eHalStatus status;
11088 tANI_U8 count = 0;
11089 tANI_U8 firstChannel;
11090 tANI_U8 maxChannels;
11091
11092 if (CSR_IS_CHANNEL_5GHZ(channel))
11093 {
11094 cfgId = WNI_CFG_MAX_TX_POWER_5;
11095 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
11096 }
11097 else if (CSR_IS_CHANNEL_24GHZ(channel))
11098 {
11099 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
11100 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
11101 }
11102 else
11103 return maxTxPwr;
11104
Kiet Lam64c1b492013-07-12 13:56:44 +053011105 pCountryInfo = vos_mem_malloc(cfgLength);
11106 if ( NULL == pCountryInfo )
11107 status = eHAL_STATUS_FAILURE;
11108 else
11109 status = eHAL_STATUS_SUCCESS;
Kiran4a17ebe2013-01-31 10:43:43 -080011110 if (status != eHAL_STATUS_SUCCESS)
11111 {
11112 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiet Lam64c1b492013-07-12 13:56:44 +053011113 FL("%s: failed to allocate memory, status = %d"),
Kiran4a17ebe2013-01-31 10:43:43 -080011114 __FUNCTION__, status);
11115 goto error;
11116 }
11117 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
11118 if (status != eHAL_STATUS_SUCCESS)
11119 {
11120 goto error;
11121 }
11122 /* Identify the channel and maxtxpower */
11123 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
11124 {
11125 firstChannel = pCountryInfo[count++];
11126 maxChannels = pCountryInfo[count++];
11127 maxTxPwr = pCountryInfo[count++];
11128
11129 if ((channel >= firstChannel) &&
11130 (channel < (firstChannel + maxChannels)))
11131 {
11132 break;
11133 }
11134 }
11135
11136error:
11137 if (NULL != pCountryInfo)
Kiet Lam64c1b492013-07-12 13:56:44 +053011138 vos_mem_free(pCountryInfo);
Kiran4a17ebe2013-01-31 10:43:43 -080011139
11140 return maxTxPwr;
11141}
11142
11143
Jeff Johnson295189b2012-06-20 16:38:30 -070011144tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
11145{
11146 tANI_BOOLEAN fValid = FALSE;
11147 tANI_U32 idxValidChannels;
11148 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11149
11150 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
11151 {
11152 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
11153 {
11154 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
11155 {
11156 fValid = TRUE;
11157 break;
11158 }
11159 }
11160 }
11161 pMac->roam.numValidChannels = len;
11162 return fValid;
11163}
11164
Jeff Johnson295189b2012-06-20 16:38:30 -070011165tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
11166{
11167 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
11168 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011169 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
11170 {
11171 if(channel == pMac->scan.base40MHzChannels.channelList[i])
11172 {
11173 fValid = eANI_BOOLEAN_TRUE;
11174 break;
11175 }
11176 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011177 return (fValid);
11178}
11179
Jeff Johnson295189b2012-06-20 16:38:30 -070011180//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070011181 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011182{
Jeff Johnsone7245742012-09-05 17:12:55 -070011183 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011184 tANI_U8 centerChn;
11185 tANI_U32 ChannelBondingMode;
Sandeep Puligilla60342762014-01-30 21:05:37 +053011186
Jeff Johnson295189b2012-06-20 16:38:30 -070011187 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
11188 {
11189 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
11190 }
11191 else
11192 {
11193 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
11194 }
11195 //Figure what the other side's CB mode
11196 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
11197 {
11198 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
11199 {
Agrawal Ashishf187d512014-04-03 17:01:52 +053011200 // In Case WPA2 and TKIP is the only one cipher suite in Pairwise.
11201 if ((pIes->RSN.present && (pIes->RSN.pwise_cipher_suite_count == 1) &&
11202 !memcmp(&(pIes->RSN.pwise_cipher_suites[0][0]),
11203 "\x00\x0f\xac\x02",4))
11204 //In Case WPA1 and TKIP is the only one cipher suite in Unicast.
11205 ||(pIes->WPA.present && (pIes->WPA.unicast_cipher_count == 1) &&
11206 !memcmp(&(pIes->WPA.unicast_ciphers[0][0]),
11207 "\x00\x50\xf2\x02",4)))
11208
Leela Venkata Kiran Kumar Reddy Chirala10c5a2e2013-12-18 14:41:28 -080011209 {
11210 smsLog(pMac, LOGW, " No channel bonding in TKIP mode ");
11211 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11212 }
11213
11214 else if(pIes->HTInfo.present)
Jeff Johnson295189b2012-06-20 16:38:30 -070011215 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011216 /* This is called during INFRA STA/CLIENT and should use the merged value of
11217 * supported channel width and recommended tx width as per standard
11218 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011219 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070011220 pIes->HTCaps.supportedChannelWidthSet,
11221 pIes->HTInfo.recommendedTxWidthSet,
11222 pIes->HTInfo.secondaryChannelOffset);
11223
11224 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
11225 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070011226 else
Jeff Johnsone7245742012-09-05 17:12:55 -070011227 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11228 switch (eRet) {
11229 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
11230 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
11231 break;
11232 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
11233 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
11234 break;
11235 case PHY_SINGLE_CHANNEL_CENTERED:
11236 default:
11237 centerChn = primaryChn;
11238 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011239 }
Jeff Johnsone7245742012-09-05 17:12:55 -070011240 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070011241 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011242 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Jeff Johnsone7245742012-09-05 17:12:55 -070011243 //eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011244 }
11245 }
11246 }
11247 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011248 return eRet;
11249}
Jeff Johnson295189b2012-06-20 16:38:30 -070011250tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
11251{
11252 tANI_BOOLEAN fFound = FALSE;
11253 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011254 for( idx = 0; idx < pCipherList->numEntries; idx++ )
11255 {
11256 if( pCipherList->encryptionType[idx] == encryptionType )
11257 {
11258 fFound = TRUE;
11259 break;
11260 }
11261 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011262 return fFound;
11263}
Jeff Johnson295189b2012-06-20 16:38:30 -070011264tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
11265{
11266 tANI_BOOLEAN fFound = FALSE;
11267 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011268 for( idx = 0; idx < pAuthList->numEntries; idx++ )
11269 {
11270 if( pAuthList->authType[idx] == authType )
11271 {
11272 fFound = TRUE;
11273 break;
11274 }
11275 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011276 return fFound;
11277}
Jeff Johnson295189b2012-06-20 16:38:30 -070011278tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
11279{
11280 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11281 tCsrScanResultFilter *pScanFilter = NULL;
11282 eHalStatus status = eHAL_STATUS_SUCCESS;
11283
11284 if(pProfile1 && pProfile2)
11285 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011286 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
11287 if ( NULL == pScanFilter )
11288 status = eHAL_STATUS_FAILURE;
11289 else
11290 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011291 if(HAL_STATUS_SUCCESS(status))
11292 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011293 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011294 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
11295 if(HAL_STATUS_SUCCESS(status))
11296 {
11297 fCheck = eANI_BOOLEAN_FALSE;
11298 do
11299 {
11300 tANI_U32 i;
11301 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
11302 {
11303 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
11304 pScanFilter->SSIDs.SSIDList[i].SSID.length,
11305 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
11306 if ( fCheck ) break;
11307 }
11308 if(!fCheck)
11309 {
11310 break;
11311 }
11312 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
11313 || pProfile2->BSSType != pProfile1->BSSType
11314 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
11315 )
11316 {
11317 fCheck = eANI_BOOLEAN_FALSE;
11318 break;
11319 }
11320#ifdef WLAN_FEATURE_VOWIFI_11R
11321 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
11322 {
11323 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
11324 {
11325 fCheck = eANI_BOOLEAN_FALSE;
11326 break;
11327 }
11328 }
11329#endif
11330 //Match found
11331 fCheck = eANI_BOOLEAN_TRUE;
11332 }while(0);
11333 csrFreeScanFilter(pMac, pScanFilter);
11334 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011335 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011336 }
11337 }
11338
11339 return (fCheck);
11340}
11341
Jeff Johnson295189b2012-06-20 16:38:30 -070011342tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
11343{
11344 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11345 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011346 do
11347 {
11348 //Only check for static WEP
11349 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
11350 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
11351 {
11352 fCheck = eANI_BOOLEAN_TRUE;
11353 break;
11354 }
11355 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
11356 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
11357 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
11358 {
11359 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053011360 if (!vos_mem_compare(&pConnProfile->Keys.KeyMaterial[i],
11361 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
Jeff Johnson295189b2012-06-20 16:38:30 -070011362 {
11363 break;
11364 }
11365 }
11366 if( i == CSR_MAX_NUM_KEY)
11367 {
11368 fCheck = eANI_BOOLEAN_TRUE;
11369 }
11370 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011371 return (fCheck);
11372}
11373
Jeff Johnson295189b2012-06-20 16:38:30 -070011374//IBSS
11375
Jeff Johnson295189b2012-06-20 16:38:30 -070011376tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
11377{
11378 tANI_U8 channel = 0;
11379 tANI_U32 idx;
11380 tANI_U32 idxValidChannels;
11381 tANI_BOOLEAN fFound = FALSE;
11382 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11383
11384 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
11385 {
11386 channel = pMac->roam.configParam.AdHocChannel5G;
11387 if(!csrRoamIsChannelValid(pMac, channel))
11388 {
11389 channel = 0;
11390 }
11391 }
11392 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11393 {
11394 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
11395 {
11396 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11397 {
11398 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11399 {
11400 fFound = TRUE;
11401 channel = csrStartIbssChannels50[ idx ];
11402 }
11403 }
11404 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011405 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
11406 if (!fFound)
11407 {
11408 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
11409 {
11410 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idx ]) ) // the max channel# in 11g is 14
11411 {
11412 channel = csrStartIbssChannels50[ idx ];
11413 break;
11414 }
11415 }
11416 }
11417 }//if
11418
11419 return( channel );
11420}
11421
Jeff Johnson295189b2012-06-20 16:38:30 -070011422tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
11423{
11424 tANI_U8 channel = 1;
11425 tANI_U32 idx;
11426 tANI_U32 idxValidChannels;
11427 tANI_BOOLEAN fFound = FALSE;
11428 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11429
11430 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
11431 {
11432 channel = pMac->roam.configParam.AdHocChannel24;
11433 if(!csrRoamIsChannelValid(pMac, channel))
11434 {
11435 channel = 0;
11436 }
11437 }
11438
11439 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11440 {
11441 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
11442 {
11443 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11444 {
11445 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11446 {
11447 fFound = TRUE;
11448 channel = csrStartIbssChannels24[ idx ];
11449 }
11450 }
11451 }
11452 }
11453
11454 return( channel );
11455}
11456
Jeff Johnson295189b2012-06-20 16:38:30 -070011457static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
11458 tCsrRoamStartBssParams *pParam )
11459{
11460 eCsrCfgDot11Mode cfgDot11Mode;
11461 eCsrBand eBand;
11462 tANI_U8 channel = 0;
11463 tSirNwType nwType;
11464 tANI_U8 operationChannel = 0;
11465
11466 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
11467 {
11468 operationChannel = pProfile->ChannelInfo.ChannelList[0];
11469 }
11470
Jeff Johnson295189b2012-06-20 16:38:30 -070011471 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070011472
Jeff Johnson295189b2012-06-20 16:38:30 -070011473 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11474 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
11475 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
11476 )
11477 {
11478 /* This should never happen */
11479 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011480 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070011481 pProfile->csrPersona);
11482 VOS_ASSERT(0);
11483 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011484 switch( cfgDot11Mode )
11485 {
11486 case eCSR_CFG_DOT11_MODE_11G:
11487 nwType = eSIR_11G_NW_TYPE;
11488 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011489 case eCSR_CFG_DOT11_MODE_11B:
11490 nwType = eSIR_11B_NW_TYPE;
11491 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011492 case eCSR_CFG_DOT11_MODE_11A:
11493 nwType = eSIR_11A_NW_TYPE;
11494 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011495 default:
11496 case eCSR_CFG_DOT11_MODE_11N:
11497 case eCSR_CFG_DOT11_MODE_TAURUS:
11498 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
11499 if(eCSR_BAND_24 == eBand)
11500 {
11501 nwType = eSIR_11G_NW_TYPE;
11502 }
11503 else
11504 {
11505 nwType = eSIR_11A_NW_TYPE;
11506 }
11507 break;
11508 }
11509
11510 pParam->extendedRateSet.numRates = 0;
11511
11512 switch ( nwType )
11513 {
11514 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011515 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011516 case eSIR_11A_NW_TYPE:
11517
11518 pParam->operationalRateSet.numRates = 8;
11519
11520 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11521 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11522 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11523 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11524 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11525 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11526 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11527 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11528
11529 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11530 {
11531 channel = csrRoamGetIbssStartChannelNumber50( pMac );
11532 if( 0 == channel &&
11533 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
11534 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
11535 )
11536 {
11537 //We could not find a 5G channel by auto pick, let's try 2.4G channels
11538 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
11539 nwType = eSIR_11B_NW_TYPE;
11540 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11541 pParam->operationalRateSet.numRates = 4;
11542 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11543 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11544 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11545 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11546 }
11547 }
11548 else
11549 {
11550 channel = operationChannel;
11551 }
11552 break;
11553
11554 case eSIR_11B_NW_TYPE:
11555 pParam->operationalRateSet.numRates = 4;
11556 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11557 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11558 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11559 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070011560 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11561 {
11562 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11563 }
11564 else
11565 {
11566 channel = operationChannel;
11567 }
11568
11569 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011570 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070011571 /* For P2P Client and P2P GO, disable 11b rates */
11572 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11573 (pProfile->csrPersona == VOS_P2P_GO_MODE)
11574 )
11575 {
11576 pParam->operationalRateSet.numRates = 8;
11577
11578 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11579 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11580 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11581 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11582 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11583 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11584 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11585 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11586 }
11587 else
Jeff Johnson295189b2012-06-20 16:38:30 -070011588 {
11589 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070011590 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11591 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11592 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11593 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11594
11595 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070011596 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
11597 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
11598 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
11599 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
11600 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
11601 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
11602 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
11603 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
11604 }
11605
11606 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11607 {
11608 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11609 }
11610 else
11611 {
11612 channel = operationChannel;
11613 }
11614
11615 break;
11616 }
11617 pParam->operationChn = channel;
11618 pParam->sirNwType = nwType;
11619}
11620
Jeff Johnson295189b2012-06-20 16:38:30 -070011621static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
11622 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
11623{
11624
11625 if( pParam )
11626 {
11627 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070011628 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011629 pParam->operationChn = pBssDesc->channelId;
Kiet Lam64c1b492013-07-12 13:56:44 +053011630 vos_mem_copy(&pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011631
11632 if( pIes )
11633 {
11634 if(pIes->SuppRates.present)
11635 {
11636 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
11637 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
11638 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011639 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 -070011640 pIes->SuppRates.num_rates);
11641 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
11642 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011643 vos_mem_copy(pParam->operationalRateSet.rate, pIes->SuppRates.rates,
11644 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
Jeff Johnson295189b2012-06-20 16:38:30 -070011645 }
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011646 if (pIes->ExtSuppRates.present)
11647 {
11648 pParam->extendedRateSet.numRates = pIes->ExtSuppRates.num_rates;
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053011649 if(pIes->ExtSuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011650 {
11651 smsLog(pMac, LOGE, FL("num_rates :%d is more than \
11652 SIR_MAC_RATESET_EID_MAX, resetting to \
11653 SIR_MAC_RATESET_EID_MAX"),
11654 pIes->ExtSuppRates.num_rates);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053011655 pIes->ExtSuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011656 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053011657 vos_mem_copy(pParam->extendedRateSet.rate,
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011658 pIes->ExtSuppRates.rates,
11659 sizeof(*pIes->ExtSuppRates.rates) * pIes->ExtSuppRates.num_rates);
11660 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011661 if( pIes->SSID.present )
11662 {
11663 pParam->ssId.length = pIes->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +053011664 vos_mem_copy(pParam->ssId.ssId, pIes->SSID.ssid,
11665 pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011666 }
11667 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070011668 }
11669 else
11670 {
11671 pParam->ssId.length = 0;
11672 pParam->operationalRateSet.numRates = 0;
11673 }
11674 }
11675}
11676
Jeff Johnson295189b2012-06-20 16:38:30 -070011677static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
11678{
11679 tANI_U8 MaxRate = 0;
11680 tANI_U32 i;
11681 tANI_U8 *pRate;
11682
11683 pRate = pSirRateSet->rate;
11684 for ( i = 0; i < pSirRateSet->numRates; i++ )
11685 {
11686 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
11687 }
11688
11689 // Save the max rate in the connected state information...
11690
11691 // modify LastRates variable as well
11692
11693 return;
11694}
11695
Jeff Johnson295189b2012-06-20 16:38:30 -070011696eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
11697 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
11698{
11699 eHalStatus status = eHAL_STATUS_SUCCESS;
11700 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070011701 // Set the roaming substate to 'Start BSS attempt'...
11702 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011703#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11704 //Need to figure out whether we need to log WDS???
11705 if( CSR_IS_IBSS( pProfile ) )
11706 {
11707 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011708 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11709 if(pIbssLog)
11710 {
11711 if(pBssDesc)
11712 {
11713 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
Kiet Lam64c1b492013-07-12 13:56:44 +053011714 vos_mem_copy(pIbssLog->bssid, pBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070011715 }
11716 else
11717 {
11718 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
11719 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011720 vos_mem_copy(pIbssLog->ssid, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011721 if(pProfile->ChannelInfo.numOfChannels == 0)
11722 {
11723 pIbssLog->channelSetting = AUTO_PICK;
11724 }
11725 else
11726 {
11727 pIbssLog->channelSetting = SPECIFIED;
11728 }
11729 pIbssLog->operatingChannel = pParam->operationChn;
11730 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11731 }
11732 }
11733#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
11734 //Put RSN information in for Starting BSS
11735 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
11736 pParam->pRSNIE = pProfile->pRSNReqIE;
11737
Jeff Johnson295189b2012-06-20 16:38:30 -070011738 pParam->privacy = pProfile->privacy;
11739 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
11740 pParam->authType = pProfile->csr80211AuthType;
11741 pParam->beaconInterval = pProfile->beaconInterval;
11742 pParam->dtimPeriod = pProfile->dtimPeriod;
11743 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
11744 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
11745 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
11746 {
11747 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
11748 {
11749 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
11750 }
11751 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011752 pParam->protEnabled = pProfile->protEnabled;
11753 pParam->obssProtEnabled = pProfile->obssProtEnabled;
11754 pParam->ht_protection = pProfile->cfg_protection;
11755 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080011756
Jeff Johnson295189b2012-06-20 16:38:30 -070011757 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
11758 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070011759 pParam->bssPersona = pProfile->csrPersona;
Chet Lanctot8cecea22014-02-11 19:09:36 -080011760
11761#ifdef WLAN_FEATURE_11W
11762 pParam->mfpCapable = (0 != pProfile->MFPCapable);
11763 pParam->mfpRequired = (0 != pProfile->MFPRequired);
11764#endif
11765
Jeff Johnson295189b2012-06-20 16:38:30 -070011766 // When starting an IBSS, start on the channel from the Profile.
11767 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070011768 return (status);
11769}
11770
Jeff Johnson295189b2012-06-20 16:38:30 -070011771static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070011772 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011773{
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011774 tANI_U8 Channel;
Jeff Johnsone7245742012-09-05 17:12:55 -070011775 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011776 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011777
11778 if(!pSession)
11779 {
11780 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11781 return;
11782 }
11783
Jeff Johnson295189b2012-06-20 16:38:30 -070011784 if( pBssDesc )
11785 {
11786 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
11787 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
11788 //The following code has to be do after that.
11789 //For WDS station, use selfMac as the self BSSID
11790 if( CSR_IS_WDS_STA( pProfile ) )
11791 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011792 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
11793 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011794 }
11795 }
11796 else
11797 {
11798 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070011799 //Use the first SSID
11800 if(pProfile->SSIDs.numOfSSIDs)
11801 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011802 vos_mem_copy(&pSession->bssParams.ssId, pProfile->SSIDs.SSIDList,
11803 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011804 }
11805 //For WDS station, use selfMac as the self BSSID
11806 if( CSR_IS_WDS_STA( pProfile ) )
11807 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011808 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
11809 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011810 }
11811 //Use the first BSSID
11812 else if( pProfile->BSSIDs.numOfBSSIDs )
11813 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011814 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid,
11815 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011816 }
11817 else
11818 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011819 vos_mem_set(&pSession->bssParams.bssid, sizeof(tCsrBssid), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011820 }
11821 }
11822 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070011823 //Set operating channel in pProfile which will be used
11824 //in csrRoamSetBssConfigCfg() to determine channel bonding
11825 //mode and will be configured in CFG later
11826 pProfile->operationChannel = Channel;
11827
11828 if(Channel == 0)
11829 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053011830 smsLog(pMac, LOGE, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070011831 }
11832 else
11833 {
11834
11835 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011836 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS( pProfile ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011837 {
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011838 if(CSR_IS_CHANNEL_24GHZ(Channel) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011839 {
Sandeep Puligillae3f239f2014-04-17 02:11:46 +053011840 /* TODO- SAP: HT40 Support in SAP 2.4Ghz mode is not enabled.
11841 so channel bonding in 2.4Ghz is configured as 20MHZ
11842 irrespective of the 'channelBondingMode24GHz' Parameter */
11843 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -070011844 }
11845 else
11846 {
11847 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
11848 }
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011849 smsLog(pMac, LOG1, "## cbMode %d", cbMode);
Jeff Johnsone7245742012-09-05 17:12:55 -070011850 pBssConfig->cbMode = cbMode;
11851 pSession->bssParams.cbMode = cbMode;
11852 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011853 }
11854}
11855
Jeff Johnson295189b2012-06-20 16:38:30 -070011856static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
11857 tANI_BOOLEAN *pfSameIbss )
11858{
11859 eHalStatus status = eHAL_STATUS_SUCCESS;
11860 tANI_BOOLEAN fSameIbss = FALSE;
11861
11862 if ( csrIsConnStateIbss( pMac, sessionId ) )
11863 {
11864 // Check if any profile parameter has changed ? If any profile parameter
11865 // has changed then stop old BSS and start a new one with new parameters
11866 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
11867 {
11868 fSameIbss = TRUE;
11869 }
11870 else
11871 {
11872 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
11873 }
11874 }
11875 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
11876 {
11877 // Disassociate from the connected Infrastructure network...
11878 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
11879 }
11880 else
11881 {
11882 tBssConfigParam *pBssConfig;
11883
Kiet Lam64c1b492013-07-12 13:56:44 +053011884 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
11885 if ( NULL == pBssConfig )
11886 status = eHAL_STATUS_FAILURE;
11887 else
11888 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011889 if(HAL_STATUS_SUCCESS(status))
11890 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011891 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011892 // there is no Bss description before we start an IBSS so we need to adopt
11893 // all Bss configuration parameters from the Profile.
11894 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
11895 if(HAL_STATUS_SUCCESS(status))
11896 {
11897 //save dotMode
11898 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
11899 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070011900 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053011901 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
11902 NULL, pBssConfig,
11903 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011904 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011905
11906 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -070011907 }//Allocate memory
11908 }
11909
11910 if(pfSameIbss)
11911 {
11912 *pfSameIbss = fSameIbss;
11913 }
11914 return( status );
11915}
11916
Jeff Johnson295189b2012-06-20 16:38:30 -070011917static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
11918 tSirSmeNewBssInfo *pNewBss )
11919{
11920 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011921
11922 if(!pSession)
11923 {
11924 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11925 return;
11926 }
11927
Jeff Johnson295189b2012-06-20 16:38:30 -070011928 if( pNewBss )
11929 {
11930 // Set the operating channel.
11931 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
11932 // move the BSSId from the BSS description into the connected state information.
Kiet Lam64c1b492013-07-12 13:56:44 +053011933 vos_mem_copy(&pSession->connectedProfile.bssid, &(pNewBss->bssId),
11934 sizeof( tCsrBssid ));
Jeff Johnson295189b2012-06-20 16:38:30 -070011935 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011936 return;
11937}
11938
Jeff Johnson295189b2012-06-20 16:38:30 -070011939#ifdef FEATURE_WLAN_WAPI
11940eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
11941 tANI_U32 numItems )
11942{
11943 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11944 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011945 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11946 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011947 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011948 return status;
11949 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011950 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011951 pSession = CSR_GET_SESSION( pMac, sessionId );
11952 if(numItems <= CSR_MAX_BKID_ALLOWED)
11953 {
11954 status = eHAL_STATUS_SUCCESS;
11955 //numItems may be 0 to clear the cache
11956 pSession->NumBkidCache = (tANI_U16)numItems;
11957 if(numItems && pBKIDCache)
11958 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011959 vos_mem_copy(pSession->BkidCacheInfo, pBKIDCache,
11960 sizeof(tBkidCacheInfo) * numItems);
11961 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011962 }
11963 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011964 return (status);
11965}
Jeff Johnson295189b2012-06-20 16:38:30 -070011966eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
11967 tBkidCacheInfo *pBkidCache)
11968{
11969 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11970 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011971 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11972 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011973 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011974 return status;
11975 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011976 pSession = CSR_GET_SESSION( pMac, sessionId );
11977 if(pNum && pBkidCache)
11978 {
11979 if(pSession->NumBkidCache == 0)
11980 {
11981 *pNum = 0;
11982 status = eHAL_STATUS_SUCCESS;
11983 }
11984 else if(*pNum >= pSession->NumBkidCache)
11985 {
11986 if(pSession->NumBkidCache > CSR_MAX_PMKID_ALLOWED)
11987 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011988 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 -070011989 pSession->NumBkidCache);
11990 pSession->NumBkidCache = CSR_MAX_PMKID_ALLOWED;
11991 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011992 vos_mem_copy(pBkidCache, pSession->BkidCacheInfo,
11993 sizeof(tBkidCacheInfo) * pSession->NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070011994 *pNum = pSession->NumBkidCache;
11995 status = eHAL_STATUS_SUCCESS;
11996 }
11997 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011998 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070011999}
Jeff Johnson295189b2012-06-20 16:38:30 -070012000tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
12001{
12002 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012003}
12004#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012005eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
12006 tPmkidCacheInfo *pPMKIDCache, tANI_U32 numItems )
12007{
12008 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12009 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012010
12011 if(!pSession)
12012 {
12013 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12014 return eHAL_STATUS_FAILURE;
12015 }
12016
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012017 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070012018 if(numItems <= CSR_MAX_PMKID_ALLOWED)
12019 {
12020#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12021 {
12022 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053012023 vos_mem_set(&secEvent,
12024 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012025 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
12026 secEvent.encryptionModeMulticast =
12027 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
12028 secEvent.encryptionModeUnicast =
12029 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053012030 vos_mem_copy(secEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070012031 secEvent.authMode =
12032 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
12033 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
12034 }
12035#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070012036 status = eHAL_STATUS_SUCCESS;
12037 //numItems may be 0 to clear the cache
12038 pSession->NumPmkidCache = (tANI_U16)numItems;
12039 if(numItems && pPMKIDCache)
12040 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012041 vos_mem_copy(pSession->PmkidCacheInfo, pPMKIDCache,
12042 sizeof(tPmkidCacheInfo) * numItems);
12043 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012044 }
12045 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012046 return (status);
12047}
12048
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012049eHalStatus csrRoamDelPMKIDfromCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
12050 tANI_U8 *pBSSId )
12051{
12052 eHalStatus status = eHAL_STATUS_FAILURE;
12053 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12054 tANI_BOOLEAN fMatchFound = FALSE;
12055 tANI_U32 Index;
12056 if(!pSession)
12057 {
12058 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12059 return eHAL_STATUS_FAILURE;
12060 }
12061 do
12062 {
12063 for( Index=0; Index < pSession->NumPmkidCache; Index++ )
12064 {
Arif Hussaina7c8e412013-11-20 11:06:42 -080012065 smsLog(pMac, LOGW, "Delete PMKID for "
12066 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pBSSId));
Kiet Lamf2f201e2013-11-16 21:24:16 +053012067 if( vos_mem_compare( pBSSId, pSession->PmkidCacheInfo[Index].BSSID, sizeof(tCsrBssid) ) )
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012068 {
12069 fMatchFound = TRUE;
12070 break;
12071 }
12072 }
12073 if( !fMatchFound ) break;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053012074 vos_mem_set(pSession->PmkidCacheInfo[Index].BSSID, sizeof(tCsrBssid), 0);
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012075 status = eHAL_STATUS_SUCCESS;
12076 }
12077 while( 0 );
12078 smsLog(pMac, LOGW, "csrDelPMKID called return match = %d Status = %d",
12079 fMatchFound, status);
12080 return status;
12081}
Jeff Johnson295189b2012-06-20 16:38:30 -070012082tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
12083{
12084 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
12085}
12086
Jeff Johnson295189b2012-06-20 16:38:30 -070012087eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
12088{
12089 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12090 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012091
12092 if(!pSession)
12093 {
12094 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12095 return eHAL_STATUS_FAILURE;
12096 }
12097
Jeff Johnson295189b2012-06-20 16:38:30 -070012098 if(pNum && pPmkidCache)
12099 {
12100 if(pSession->NumPmkidCache == 0)
12101 {
12102 *pNum = 0;
12103 status = eHAL_STATUS_SUCCESS;
12104 }
12105 else if(*pNum >= pSession->NumPmkidCache)
12106 {
12107 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
12108 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012109 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 -070012110 pSession->NumPmkidCache);
12111 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
12112 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012113 vos_mem_copy(pPmkidCache, pSession->PmkidCacheInfo,
12114 sizeof(tPmkidCacheInfo) * pSession->NumPmkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012115 *pNum = pSession->NumPmkidCache;
12116 status = eHAL_STATUS_SUCCESS;
12117 }
12118 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012119 return (status);
12120}
12121
Jeff Johnson295189b2012-06-20 16:38:30 -070012122eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12123{
12124 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12125 tANI_U32 len;
12126 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012127
12128 if(!pSession)
12129 {
12130 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12131 return eHAL_STATUS_FAILURE;
12132 }
12133
Jeff Johnson295189b2012-06-20 16:38:30 -070012134 if(pLen)
12135 {
12136 len = *pLen;
12137 *pLen = pSession->nWpaRsnReqIeLength;
12138 if(pBuf)
12139 {
12140 if(len >= pSession->nWpaRsnReqIeLength)
12141 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012142 vos_mem_copy(pBuf, pSession->pWpaRsnReqIE,
12143 pSession->nWpaRsnReqIeLength);
12144 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012145 }
12146 }
12147 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012148 return (status);
12149}
12150
Jeff Johnson295189b2012-06-20 16:38:30 -070012151eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12152{
12153 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12154 tANI_U32 len;
12155 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012156
12157 if(!pSession)
12158 {
12159 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12160 return eHAL_STATUS_FAILURE;
12161 }
12162
Jeff Johnson295189b2012-06-20 16:38:30 -070012163 if(pLen)
12164 {
12165 len = *pLen;
12166 *pLen = pSession->nWpaRsnRspIeLength;
12167 if(pBuf)
12168 {
12169 if(len >= pSession->nWpaRsnRspIeLength)
12170 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012171 vos_mem_copy(pBuf, pSession->pWpaRsnRspIE,
12172 pSession->nWpaRsnRspIeLength);
12173 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012174 }
12175 }
12176 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012177 return (status);
12178}
Jeff Johnson295189b2012-06-20 16:38:30 -070012179#ifdef FEATURE_WLAN_WAPI
12180eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12181{
12182 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12183 tANI_U32 len;
12184 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012185
12186 if(!pSession)
12187 {
12188 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12189 return eHAL_STATUS_FAILURE;
12190 }
12191
Jeff Johnson295189b2012-06-20 16:38:30 -070012192 if(pLen)
12193 {
12194 len = *pLen;
12195 *pLen = pSession->nWapiReqIeLength;
12196 if(pBuf)
12197 {
12198 if(len >= pSession->nWapiReqIeLength)
12199 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012200 vos_mem_copy(pBuf, pSession->pWapiReqIE,
12201 pSession->nWapiReqIeLength);
12202 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012203 }
12204 }
12205 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012206 return (status);
12207}
Jeff Johnson295189b2012-06-20 16:38:30 -070012208eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12209{
12210 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12211 tANI_U32 len;
12212 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012213
12214 if(!pSession)
12215 {
12216 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12217 return eHAL_STATUS_FAILURE;
12218 }
12219
Jeff Johnson295189b2012-06-20 16:38:30 -070012220 if(pLen)
12221 {
12222 len = *pLen;
12223 *pLen = pSession->nWapiRspIeLength;
12224 if(pBuf)
12225 {
12226 if(len >= pSession->nWapiRspIeLength)
12227 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012228 vos_mem_copy(pBuf, pSession->pWapiRspIE,
12229 pSession->nWapiRspIeLength);
12230 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012231 }
12232 }
12233 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012234 return (status);
12235}
12236#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012237eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
12238{
12239 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
12240 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012241
12242 if(!pSession)
12243 {
12244 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12245 return (retStatus);
12246 }
12247
Jeff Johnson295189b2012-06-20 16:38:30 -070012248 if(CSR_IS_ROAMING(pSession))
12249 {
12250 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
12251 pSession->fRoaming = eANI_BOOLEAN_FALSE;
12252 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012253 return (retStatus);
12254}
12255
Jeff Johnson295189b2012-06-20 16:38:30 -070012256//This function remove the connected BSS from te cached scan result
12257eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
12258 tCsrRoamConnectedProfile *pConnProfile)
12259{
12260 eHalStatus status = eHAL_STATUS_FAILURE;
12261 tCsrScanResultFilter *pScanFilter = NULL;
12262 tListElem *pEntry;
12263 tCsrScanResult *pResult;
12264 tDot11fBeaconIEs *pIes;
12265 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070012266 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
12267 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
12268 {
12269 do
12270 {
12271 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
Kiet Lam64c1b492013-07-12 13:56:44 +053012272 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
12273 if ( NULL == pScanFilter )
12274 status = eHAL_STATUS_FAILURE;
12275 else
12276 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012277 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012278 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
12279 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
12280 if ( NULL == pScanFilter->BSSIDs.bssid )
12281 status = eHAL_STATUS_FAILURE;
12282 else
12283 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012284 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012285 vos_mem_copy(pScanFilter->BSSIDs.bssid, &pConnProfile->bssid,
12286 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012287 pScanFilter->BSSIDs.numOfBSSIDs = 1;
12288 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
12289 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012290 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
12291 if ( NULL == pScanFilter->SSIDs.SSIDList )
12292 status = eHAL_STATUS_FAILURE;
12293 else
12294 status = eHAL_STATUS_SUCCESS;
12295 if (!HAL_STATUS_SUCCESS(status)) break;
12296 vos_mem_copy(&pScanFilter->SSIDs.SSIDList[0].SSID,
12297 &pConnProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012298 }
12299 pScanFilter->authType.numEntries = 1;
12300 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
12301 pScanFilter->BSSType = pConnProfile->BSSType;
12302 pScanFilter->EncryptionType.numEntries = 1;
12303 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
12304 pScanFilter->mcEncryptionType.numEntries = 1;
12305 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
12306 //We ignore the channel for now, BSSID should be enough
12307 pScanFilter->ChannelInfo.numOfChannels = 0;
12308 //Also ignore the following fields
12309 pScanFilter->uapsd_mask = 0;
12310 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070012311 pScanFilter->bOSENAssociation = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012312 pScanFilter->countryCode[0] = 0;
12313 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012314 csrLLLock(&pMac->scan.scanResultList);
12315 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
12316 while( pEntry )
12317 {
12318 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
12319 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
12320 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
12321 pScanFilter, NULL, NULL, NULL, &pIes);
12322 //Release the IEs allocated by csrMatchBSS is needed
12323 if( !pResult->Result.pvIes )
12324 {
12325 //need to free the IEs since it is allocated by csrMatchBSS
Kiet Lam64c1b492013-07-12 13:56:44 +053012326 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012327 }
12328 if(fMatch)
12329 {
12330 //We found the one
12331 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
12332 {
12333 //Free the memory
12334 csrFreeScanResultEntry( pMac, pResult );
12335 }
12336 break;
12337 }
12338 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
12339 }//while
12340 csrLLUnlock(&pMac->scan.scanResultList);
12341 }while(0);
12342 if(pScanFilter)
12343 {
12344 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +053012345 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012346 }
12347 }
12348 return (status);
12349}
12350
Jeff Johnson295189b2012-06-20 16:38:30 -070012351//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070012352eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
12353{
12354 eHalStatus status = eHAL_STATUS_SUCCESS;
12355 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012356 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
12357 {
12358 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
12359 {
12360 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
12361 {
12362 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012363 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012364 status = eHAL_STATUS_CSR_WRONG_STATE;
12365 break;
12366 }
12367 if( csrIsConnStateInfra( pMac, sessionId ) )
12368 {
12369 if( chnId &&
12370 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
12371 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012372 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070012373 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
12374 status = eHAL_STATUS_CSR_WRONG_STATE;
12375 break;
12376 }
12377 }
12378 }
12379 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012380 return ( status );
12381}
12382
Jeff Johnson295189b2012-06-20 16:38:30 -070012383static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
12384{
12385 eHalStatus status = eHAL_STATUS_SUCCESS;
12386 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12387 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012388
12389 if(!pSession)
12390 {
12391 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12392 return eHAL_STATUS_FAILURE;
12393 }
12394
Jeff Johnson295189b2012-06-20 16:38:30 -070012395 if ( csrIsConnStateIbss( pMac, sessionId ) )
12396 {
12397 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
12398 }
12399 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
12400 {
12401 // Disassociate from the connected Infrastructure network...
12402 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
12403 }
12404 else
12405 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012406 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
12407 //Otherwise we need to add code to handle the
12408 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
12409 //send stop_bss to PE, before we can continue.
12410 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012411 vos_mem_set(&bssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012412 /* Assume HDD provide bssid in profile */
Kiet Lam64c1b492013-07-12 13:56:44 +053012413 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0],
12414 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012415 // there is no Bss description before we start an WDS so we need
12416 // to adopt all Bss configuration parameters from the Profile.
12417 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
12418 if(HAL_STATUS_SUCCESS(status))
12419 {
12420 //Save profile for late use
12421 csrFreeRoamProfile( pMac, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +053012422 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
12423 if (pSession->pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -070012424 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012425 vos_mem_set(pSession->pCurRoamProfile,
12426 sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012427 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
12428 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012429 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070012430 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012431 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
12432 NULL, &bssConfig,
12433 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012434 }
12435 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012436
Jeff Johnson295189b2012-06-20 16:38:30 -070012437 return( status );
12438}
12439
Jeff Johnson295189b2012-06-20 16:38:30 -070012440////////////////////Mail box
12441
Jeff Johnson295189b2012-06-20 16:38:30 -070012442//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
12443//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012444static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
12445 tSirBssDescription *pBssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -070012446 tANI_U8 *pBuf, tANI_U8 uapsdMask)
12447{
12448 tCsrChannelSet channelGroup;
12449 tSirMacCapabilityInfo *pAP_capabilityInfo;
12450 tAniBool fTmp;
12451 tANI_BOOLEAN found = FALSE;
12452 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012453 tANI_S8 pwrLimit = 0;
12454 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070012455 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
12456 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
12457 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
12458 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070012459 // 802.11h
12460 //We can do this because it is in HOST CPU order for now.
12461 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080012462 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
12463 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
12464 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012465 fTmp = (tAniBool)pal_cpu_to_be32(1);
12466 }
12467 else
12468 fTmp = (tAniBool)0;
12469
12470 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
Kiet Lam64c1b492013-07-12 13:56:44 +053012471 vos_mem_copy(pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool));
Jeff Johnson295189b2012-06-20 16:38:30 -070012472 pBuf += sizeof(tAniBool);
12473 *pBuf++ = MIN_STA_PWR_CAP_DBM; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012474 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070012475 // This is required for 11k test VoWiFi Ent: Test 2.
12476 // We need the power capabilities for Assoc Req.
12477 // This macro is provided by the halPhyCfg.h. We pick our
12478 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080012479 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
12480 if (0 != pwrLimit)
12481 {
12482 *pBuf++ = pwrLimit;
12483 }
12484 else
12485 {
12486 *pBuf++ = MAX_STA_PWR_CAP_DBM;
12487 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012488 size = sizeof(pMac->roam.validChannelList);
12489 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
12490 {
12491 *pBuf++ = (tANI_U8)size; //tSirSupChnl->numChnl
12492 for ( i = 0; i < size; i++)
12493 {
12494 *pBuf++ = pMac->roam.validChannelList[ i ]; //tSirSupChnl->channelList[ i ]
12495
12496 }
12497 }
12498 else
12499 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012500 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012501 *pBuf++ = 0; //tSirSupChnl->numChnl
12502 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012503 //Check whether it is ok to enter UAPSD
12504#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12505 if( btcIsReadyForUapsd(pMac) )
12506#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12507 {
12508 *pBuf++ = uapsdMask;
12509 }
12510#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12511 else
12512 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012513 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070012514 *pBuf++ = 0;
12515 }
12516#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12517
Jeff Johnson295189b2012-06-20 16:38:30 -070012518 // move the entire BssDescription into the join request.
Kiet Lam64c1b492013-07-12 13:56:44 +053012519 vos_mem_copy(pBuf, pBssDescription,
12520 pBssDescription->length + sizeof( pBssDescription->length ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012521 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
12522}
12523
Jeff Johnson295189b2012-06-20 16:38:30 -070012524/*
12525 * The communication between HDD and LIM is thru mailbox (MB).
12526 * Both sides will access the data structure "tSirSmeJoinReq".
12527 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
12528 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
12529 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
12530 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
12531 */
12532eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012533 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012534{
12535 eHalStatus status = eHAL_STATUS_SUCCESS;
12536 tSirSmeJoinReq *pMsg;
12537 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012538 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070012539 tANI_U16 msgLen, wTmp, ieLen;
12540 tSirMacRateSet OpRateSet;
12541 tSirMacRateSet ExRateSet;
12542 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12543 tANI_U32 dwTmp;
12544 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012545 tANI_U32 ucDot11Mode = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012546
12547 if(!pSession)
12548 {
12549 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12550 return eHAL_STATUS_FAILURE;
12551 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012552 /* To satisfy klockworks */
12553 if (NULL == pBssDescription)
12554 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012555 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012556 return eHAL_STATUS_FAILURE;
12557 }
12558
Jeff Johnson295189b2012-06-20 16:38:30 -070012559 do {
12560 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
12561 pSession->joinFailStatusCode.reasonCode = 0;
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -070012562 memcpy (&pSession->joinFailStatusCode.bssId, &pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012563 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
12564 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
12565 // IE fields, but the length field in the bssDescription needs to be interpreted to
12566 // determine length of the IE fields.
12567 //
12568 // So, take the size of the JoinReq, subtract the size of the bssDescription and
12569 // add in the length from the bssDescription (then add the size of the 'length' field
12570 // itself because that is NOT included in the length field).
12571 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
12572 pBssDescription->length + sizeof( pBssDescription->length ) +
12573 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 +053012574 pMsg = vos_mem_malloc(msgLen);
12575 if (NULL == pMsg)
12576 status = eHAL_STATUS_FAILURE;
12577 else
12578 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012579 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012580 vos_mem_set(pMsg, msgLen , 0);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012581 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012582 pMsg->length = pal_cpu_to_be16(msgLen);
12583 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012584 // sessionId
12585 *pBuf = (tANI_U8)sessionId;
12586 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012587 // transactionId
12588 *pBuf = 0;
12589 *( pBuf + 1 ) = 0;
12590 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012591 // ssId
12592 if( pIes->SSID.present && pIes->SSID.num_ssid )
12593 {
12594 // ssId len
12595 *pBuf = pIes->SSID.num_ssid;
12596 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053012597 vos_mem_copy(pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -070012598 pBuf += pIes->SSID.num_ssid;
12599 }
12600 else
12601 {
12602 *pBuf = 0;
12603 pBuf++;
12604 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012605 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053012606 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
12607 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012608 pBuf += sizeof(tSirMacAddr);
12609 // bsstype
12610 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
12611 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
Kiet Lam64c1b492013-07-12 13:56:44 +053012612 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070012613 pBuf += sizeof(tSirBssType);
12614 // dot11mode
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012615 ucDot11Mode = csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
12616 if (pBssDescription->channelId <= 14 &&
12617 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
12618 WNI_CFG_DOT11_MODE_11AC == ucDot11Mode)
12619 {
12620 //Need to disable VHT operation in 2.4 GHz band
12621 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
12622 }
12623 *pBuf = (tANI_U8)ucDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -070012624 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012625 //Persona
12626 *pBuf = (tANI_U8)pProfile->csrPersona;
12627 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070012628 //CBMode
12629 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
12630 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012631
12632 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -070012633 FL("CSR PERSONA=%d CSR CbMode %d"), pProfile->csrPersona, pSession->bssParams.cbMode);
12634
Jeff Johnson295189b2012-06-20 16:38:30 -070012635 // uapsdPerAcBitmask
12636 *pBuf = pProfile->uapsd_mask;
12637 pBuf++;
12638
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012639
12640
Jeff Johnson295189b2012-06-20 16:38:30 -070012641 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012642 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012643 {
12644 // OperationalRateSet
12645 if (OpRateSet.numRates) {
12646 *pBuf++ = OpRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012647 vos_mem_copy(pBuf, OpRateSet.rate, OpRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012648 pBuf += OpRateSet.numRates;
12649 } else *pBuf++ = 0;
12650 // ExtendedRateSet
12651 if (ExRateSet.numRates) {
12652 *pBuf++ = ExRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012653 vos_mem_copy(pBuf, ExRateSet.rate, ExRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012654 pBuf += ExRateSet.numRates;
12655 } else *pBuf++ = 0;
12656 }
12657 else
12658 {
12659 *pBuf++ = 0;
12660 *pBuf++ = 0;
12661 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012662 // rsnIE
12663 if ( csrIsProfileWpa( pProfile ) )
12664 {
12665 // Insert the Wpa IE into the join request
12666 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
12667 (tCsrWpaIe *)( wpaRsnIE ) );
12668 }
12669 else if( csrIsProfileRSN( pProfile ) )
12670 {
12671 // Insert the RSN IE into the join request
12672 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12673 (tCsrRSNIe *)( wpaRsnIE ) );
12674 }
12675#ifdef FEATURE_WLAN_WAPI
12676 else if( csrIsProfileWapi( pProfile ) )
12677 {
12678 // Insert the WAPI IE into the join request
12679 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12680 (tCsrWapiIe *)( wpaRsnIE ) );
12681 }
12682#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012683 else
12684 {
12685 ieLen = 0;
12686 }
12687 //remember the IE for future use
12688 if( ieLen )
12689 {
12690 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
12691 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012692 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 -070012693 ieLen = DOT11F_IE_RSN_MAX_LEN;
12694 }
12695#ifdef FEATURE_WLAN_WAPI
12696 if( csrIsProfileWapi( pProfile ) )
12697 {
12698 //Check whether we need to allocate more memory
12699 if(ieLen > pSession->nWapiReqIeLength)
12700 {
12701 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
12702 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012703 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012704 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012705 pSession->pWapiReqIE = vos_mem_malloc(ieLen);
12706 if (NULL == pSession->pWapiReqIE)
12707 status = eHAL_STATUS_FAILURE;
12708 else
12709 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012710 if(!HAL_STATUS_SUCCESS(status)) break;
12711 }
12712 pSession->nWapiReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012713 vos_mem_copy(pSession->pWapiReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012714 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012715 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012716 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012717 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012718 pBuf += ieLen;
12719 }
12720 else//should be WPA/WPA2 otherwise
12721#endif /* FEATURE_WLAN_WAPI */
12722 {
12723 //Check whether we need to allocate more memory
12724 if(ieLen > pSession->nWpaRsnReqIeLength)
12725 {
12726 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
12727 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012728 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012729 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012730 pSession->pWpaRsnReqIE = vos_mem_malloc(ieLen);
12731 if (NULL == pSession->pWpaRsnReqIE)
12732 status = eHAL_STATUS_FAILURE;
12733 else
12734 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012735 if(!HAL_STATUS_SUCCESS(status)) break;
12736 }
12737 pSession->nWpaRsnReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012738 vos_mem_copy(pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012739 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012740 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012741 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012742 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012743 pBuf += ieLen;
12744 }
12745 }
12746 else
12747 {
12748 //free whatever old info
12749 pSession->nWpaRsnReqIeLength = 0;
12750 if(pSession->pWpaRsnReqIE)
12751 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012752 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012753 pSession->pWpaRsnReqIE = NULL;
12754 }
12755#ifdef FEATURE_WLAN_WAPI
12756 pSession->nWapiReqIeLength = 0;
12757 if(pSession->pWapiReqIE)
12758 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012759 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012760 pSession->pWapiReqIE = NULL;
12761 }
12762#endif /* FEATURE_WLAN_WAPI */
12763 //length is two bytes
12764 *pBuf = 0;
12765 *(pBuf + 1) = 0;
12766 pBuf += 2;
12767 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012768#ifdef FEATURE_WLAN_ESE
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012769 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012770 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012771 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070012772 //length is two bytes
12773 *pBuf = 0;
12774 *(pBuf + 1) = 0;
12775 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012776 }
12777 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012778 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012779 // cckmIE
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012780 if( csrIsProfileESE( pProfile ) )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012781 {
12782 // Insert the CCKM IE into the join request
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012783#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070012784 ieLen = pSession->suppCckmIeInfo.cckmIeLen;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080012785 vos_mem_copy((void *) (wpaRsnIE),
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070012786 pSession->suppCckmIeInfo.cckmIe, ieLen);
12787#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012788 ieLen = csrConstructEseCckmIe( pMac,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012789 pSession,
12790 pProfile,
12791 pBssDescription,
12792 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070012793 pSession->nWpaRsnReqIeLength,
12794 (void *)( wpaRsnIE ) );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012795#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012796 }
12797 else
12798 {
12799 ieLen = 0;
12800 }
12801 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
12802 if( ieLen )
12803 {
12804 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
12805 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012806 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012807 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012808 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012809 pBuf += ieLen;
12810 }
12811 else
12812 {
12813 //Indicate you have no CCKM IE
12814 //length is two bytes
12815 *pBuf = 0;
12816 *(pBuf + 1) = 0;
12817 pBuf += 2;
12818 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012819 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012820#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -070012821 // addIEScan
Agarwal Ashish4f616132013-12-30 23:32:50 +053012822 if (pProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070012823 {
12824 ieLen = pProfile->nAddIEScanLength;
Agarwal Ashish4f616132013-12-30 23:32:50 +053012825 memset(pSession->addIEScan, 0 , pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070012826 pSession->nAddIEScanLength = ieLen;
Agarwal Ashish4f616132013-12-30 23:32:50 +053012827 vos_mem_copy(pSession->addIEScan, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012828 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012829 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012830 pBuf += sizeof(tANI_U16);
Agarwal Ashish4f616132013-12-30 23:32:50 +053012831 vos_mem_copy(pBuf, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012832 pBuf += ieLen;
12833 }
12834 else
12835 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053012836 memset(pSession->addIEScan, 0, pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070012837 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012838 *pBuf = 0;
12839 *(pBuf + 1) = 0;
12840 pBuf += 2;
12841 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012842 // addIEAssoc
12843 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
12844 {
12845 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070012846 if(ieLen > pSession->nAddIEAssocLength)
12847 {
12848 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
Kiet Lam64c1b492013-07-12 13:56:44 +053012849 {
12850 vos_mem_free(pSession->pAddIEAssoc);
12851 }
12852 pSession->pAddIEAssoc = vos_mem_malloc(ieLen);
12853 if (NULL == pSession->pAddIEAssoc)
12854 status = eHAL_STATUS_FAILURE;
12855 else
12856 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012857 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012858 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012859 pSession->nAddIEAssocLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012860 vos_mem_copy(pSession->pAddIEAssoc, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012861 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012862 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012863 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012864 vos_mem_copy(pBuf, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012865 pBuf += ieLen;
12866 }
12867 else
12868 {
12869 pSession->nAddIEAssocLength = 0;
12870 if(pSession->pAddIEAssoc)
12871 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012872 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070012873 pSession->pAddIEAssoc = NULL;
12874 }
12875 *pBuf = 0;
12876 *(pBuf + 1) = 0;
12877 pBuf += 2;
12878 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012879
12880 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012881 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012882 //Unmask any AC in reassoc that is ACM-set
12883 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
12884 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012885 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012886 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
12887 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012888#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012889 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012890#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012891 }
12892 else
12893 {
12894 uapsd_mask = 0;
12895 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012896 }
12897 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012898
Jeff Johnson295189b2012-06-20 16:38:30 -070012899 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012900 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012901 pBuf += sizeof(tANI_U32);
12902
Jeff Johnson295189b2012-06-20 16:38:30 -070012903 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012904 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012905 pBuf += sizeof(tANI_U32);
Chet Lanctot186b5732013-03-18 10:26:30 -070012906#ifdef WLAN_FEATURE_11W
12907 //MgmtEncryption
12908 if (pProfile->MFPEnabled)
12909 {
12910 dwTmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
12911 }
12912 else
12913 {
12914 dwTmp = pal_cpu_to_be32(eSIR_ED_NONE);
12915 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012916 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Chet Lanctot186b5732013-03-18 10:26:30 -070012917 pBuf += sizeof(tANI_U32);
12918#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012919#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012920 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053012921 if (csrIsProfile11r( pProfile )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012922#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala09dd66b2013-04-01 17:13:01 +053012923 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012924 (pIes->ESEVersion.present) && (pMac->roam.configParam.isEseIniFeatureEnabled))
Saurabh Gupta775073c2013-02-14 13:31:36 +053012925#endif
12926 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012927 {
12928 // is11Rconnection;
12929 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012930 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool)) ;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012931 pBuf += sizeof(tAniBool);
12932 }
12933 else
12934 {
12935 // is11Rconnection;
12936 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012937 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012938 pBuf += sizeof(tAniBool);
12939 }
12940#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012941#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012942
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012943 // isESEFeatureIniEnabled
12944 if (TRUE == pMac->roam.configParam.isEseIniFeatureEnabled)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012945 {
12946 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012947 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012948 pBuf += sizeof(tAniBool);
12949 }
12950 else
12951 {
12952 dwTmp = pal_cpu_to_be32(FALSE);
Srinivas Girigowda18112782013-11-27 12:21:19 -080012953 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012954 pBuf += sizeof(tAniBool);
12955 }
12956
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012957 /* A profile can not be both ESE and 11R. But an 802.11R AP
12958 * may be advertising support for ESE as well. So if we are
12959 * associating Open or explicitly ESE then we will get ESE.
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012960 * If we are associating explictly 11R only then we will get
12961 * 11R.
12962 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012963 if ((csrIsProfileESE(pProfile) ||
12964 ((pIes->ESEVersion.present)
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012965 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070012966 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
12967 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
12968 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -070012969#ifdef WLAN_FEATURE_11W
12970 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
12971#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012972 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012973 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012974 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012975 // isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012976 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012977 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012978 pBuf += sizeof(tAniBool);
12979 }
12980 else
12981 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012982 //isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012983 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012984 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012985 pBuf += sizeof(tAniBool);
12986 }
12987
12988 if (eWNI_SME_JOIN_REQ == messageType)
12989 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012990 tESETspecInfo eseTspec;
12991 // ESE-Tspec IEs in the ASSOC request is presently not supported
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012992 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012993 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
12994 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
12995 pBuf += sizeof(tESETspecInfo);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012996 }
12997 else if (eWNI_SME_REASSOC_REQ == messageType)
12998 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012999 if ((csrIsProfileESE(pProfile) ||
13000 ((pIes->ESEVersion.present)
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013001 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013002 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
13003 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
13004 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
Chet Lanctot186b5732013-03-18 10:26:30 -070013005#ifdef WLAN_FEATURE_11W
13006 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
13007#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013008 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013009 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070013010 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013011 tESETspecInfo eseTspec;
13012 // ESE Tspec information
13013 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13014 eseTspec.numTspecs = sme_QosESERetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &eseTspec.tspec[0]);
13015 *pBuf = eseTspec.numTspecs;
Jeff Johnson295189b2012-06-20 16:38:30 -070013016 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013017 // Copy the TSPEC information only if present
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013018 if (eseTspec.numTspecs) {
13019 vos_mem_copy(pBuf, (void*)&eseTspec.tspec[0],
13020 (eseTspec.numTspecs*sizeof(tTspecInfo)));
Jeff Johnson295189b2012-06-20 16:38:30 -070013021 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013022 pBuf += sizeof(eseTspec.tspec);
Jeff Johnson295189b2012-06-20 16:38:30 -070013023 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013024 else
Jeff Johnson295189b2012-06-20 16:38:30 -070013025 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013026 tESETspecInfo eseTspec;
13027 // ESE-Tspec IEs in the ASSOC request is presently not supported
Jeff Johnson295189b2012-06-20 16:38:30 -070013028 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013029 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13030 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
13031 pBuf += sizeof(tESETspecInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070013032 }
13033 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013034#endif // FEATURE_WLAN_ESE
13035#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070013036 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013037 if (pMac->roam.configParam.isFastTransitionEnabled
13038#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053013039 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013040#endif
13041 )
Jeff Johnson295189b2012-06-20 16:38:30 -070013042 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013043 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013044 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013045 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070013046 }
13047 else
13048 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013049 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013050 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013051 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070013052 }
13053#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070013054#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053013055 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070013056 {
13057 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013058 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013059 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013060 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070013061 }
13062 else
13063 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013064 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013065 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013066 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070013067 }
13068#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013069
13070 // txLdpcIniFeatureEnabled
13071 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
13072 pBuf++;
13073
Kiran4a17ebe2013-01-31 10:43:43 -080013074 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
13075 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
13076 {
13077 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
13078 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
13079 csrApplyPower2Current(pMac);
13080 }
13081
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080013082#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080013083 // txBFIniFeatureEnabled
13084 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
13085 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080013086
13087 // txBFCsnValue
13088 *pBuf = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
13089 pBuf++;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080013090#endif
krunal soni5afa96c2013-09-06 22:19:02 -070013091 *pBuf = (tANI_U8)pMac->roam.configParam.isAmsduSupportInAMPDU;
13092 pBuf++;
13093
Sandeep Puligillaaea98a22013-12-04 13:36:32 +053013094 // WME
13095 if(pMac->roam.roamSession[sessionId].fWMMConnection)
13096 {
13097 //WME enabled
13098 dwTmp = pal_cpu_to_be32(TRUE);
13099 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13100 pBuf += sizeof(tAniBool);
13101 }
13102 else
13103 {
13104 dwTmp = pal_cpu_to_be32(FALSE);
13105 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13106 pBuf += sizeof(tAniBool);
13107 }
13108
13109 // QOS
13110 if(pMac->roam.roamSession[sessionId].fQOSConnection)
13111 {
13112 //QOS enabled
13113 dwTmp = pal_cpu_to_be32(TRUE);
13114 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13115 pBuf += sizeof(tAniBool);
13116 }
13117 else
13118 {
13119 dwTmp = pal_cpu_to_be32(FALSE);
13120 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13121 pBuf += sizeof(tAniBool);
13122 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013123 //BssDesc
13124 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
13125 (tANI_U8)pProfile->uapsd_mask);
krunal soni5afa96c2013-09-06 22:19:02 -070013126
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013127 status = palSendMBMessage(pMac->hHdd, pMsg );
13128 if(!HAL_STATUS_SUCCESS(status))
13129 {
13130 break;
13131 }
13132 else
13133 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013134#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013135 if (eWNI_SME_JOIN_REQ == messageType)
13136 {
13137 //Tush-QoS: notify QoS module that join happening
13138 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
13139 }
13140 else if (eWNI_SME_REASSOC_REQ == messageType)
13141 {
13142 //Tush-QoS: notify QoS module that reassoc happening
13143 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
13144 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013145#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013146 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013147 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013148 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013149}
13150
Jeff Johnson295189b2012-06-20 16:38:30 -070013151//
13152eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13153{
13154 eHalStatus status = eHAL_STATUS_SUCCESS;
13155 tSirSmeDisassocReq *pMsg;
13156 tANI_U8 *pBuf;
13157 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013158 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13159 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13160 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013161 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013162 pMsg = vos_mem_malloc(sizeof(tSirSmeDisassocReq));
13163 if (NULL == pMsg)
13164 status = eHAL_STATUS_FAILURE;
13165 else
13166 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013167 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013168 vos_mem_set(pMsg, sizeof( tSirSmeDisassocReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013169 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
13170 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013171 pBuf = &pMsg->sessionId;
13172 // sessionId
13173 *pBuf++ = (tANI_U8)sessionId;
13174 // transactionId
13175 *pBuf = 0;
13176 *( pBuf + 1 ) = 0;
13177 pBuf += sizeof(tANI_U16);
13178
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053013179 if ( (pSession->pCurRoamProfile != NULL) &&
13180 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
13181 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013182 {
13183 // Set the bssid address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013184 vos_mem_copy((tSirMacAddr *)pBuf, pSession->selfMacAddr,
13185 sizeof( tSirMacAddr ));
13186 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013187 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070013188 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013189 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
13190 //perMacAddr is passed as bssId for softAP
13191 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013192 pBuf = pBuf + sizeof ( tSirMacAddr );
13193 }
13194 else
13195 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013196 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013197 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
13198 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013199 pBuf = pBuf + sizeof ( tSirMacAddr );
Kiet Lam64c1b492013-07-12 13:56:44 +053013200 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ));
13201 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013202 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070013203 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013204 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 // reasonCode
13210 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013211 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
13212 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013213 if(!HAL_STATUS_SUCCESS(status))
13214 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013215 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013216 break;
13217 }
13218 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013219 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
13220 Here we should not send the disassoc over the air to the AP */
13221 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
13222#ifdef WLAN_FEATURE_VOWIFI_11R
13223 && csrRoamIs11rAssoc(pMac)
13224#endif
13225 )
13226 {
13227 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
13228 }
13229 pBuf += sizeof(tANI_U8);
13230 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013231 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013232 return( status );
13233}
Jeff Johnson295189b2012-06-20 16:38:30 -070013234eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
13235{
13236 eHalStatus status = eHAL_STATUS_SUCCESS;
13237 tSirSmeTkipCntrMeasReq *pMsg;
13238 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013239 do
13240 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013241 pMsg = vos_mem_malloc(sizeof( tSirSmeTkipCntrMeasReq ));
13242 if ( NULL == pMsg )
13243 status = eHAL_STATUS_FAILURE;
13244 else
13245 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013246 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013247 vos_mem_set(pMsg, sizeof( tSirSmeTkipCntrMeasReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013248 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
13249 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013250 pBuf = &pMsg->sessionId;
13251 // sessionId
13252 *pBuf++ = (tANI_U8)sessionId;
13253 // transactionId
13254 *pBuf = 0;
13255 *( pBuf + 1 ) = 0;
13256 pBuf += sizeof(tANI_U16);
13257 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053013258 vos_mem_copy(pMsg->bssId, bssId, sizeof( tSirMacAddr ));
13259 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013260 pBuf = pBuf + sizeof ( tSirMacAddr );
13261 // bEnable
13262 *pBuf = (tANI_BOOLEAN)bEnable;
13263 if(!HAL_STATUS_SUCCESS(status))
13264 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013265 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013266 break;
13267 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013268 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013269 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013270 return( status );
13271}
Jeff Johnson295189b2012-06-20 16:38:30 -070013272eHalStatus
13273csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
13274 VOS_MODULE_ID modId, tSirMacAddr bssId,
13275 void *pUsrContext, void *pfnSapEventCallback,
13276 tANI_U8 *pAssocStasBuf )
13277{
13278 eHalStatus status = eHAL_STATUS_SUCCESS;
13279 tSirSmeGetAssocSTAsReq *pMsg;
13280 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
13281 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013282 do
13283 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013284 pMsg = vos_mem_malloc(sizeof( tSirSmeGetAssocSTAsReq ));
13285 if ( NULL == pMsg )
13286 status = eHAL_STATUS_FAILURE;
13287 else
13288 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013289 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013290 vos_mem_set(pMsg, sizeof( tSirSmeGetAssocSTAsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013291 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013292 pBuf = (tANI_U8 *)&pMsg->bssId;
13293 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013294 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013295 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013296 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013297 // modId
13298 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013299 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013300 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013301 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080013302 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void *));
13303 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013304 // pfnSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080013305 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void*));
13306 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013307 // pAssocStasBuf
krunal soni4f802b22014-02-11 17:01:13 -080013308 vos_mem_copy(pBuf, pAssocStasBuf, sizeof(void*));
13309 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013310 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013311 status = palSendMBMessage( pMac->hHdd, pMsg );
13312 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013313 return( status );
13314 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013315eHalStatus
13316csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
13317 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
13318 {
13319 eHalStatus status = eHAL_STATUS_SUCCESS;
13320 tSirSmeGetWPSPBCSessionsReq *pMsg;
13321 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
krunal soni4f802b22014-02-11 17:01:13 -080013322
Jeff Johnson295189b2012-06-20 16:38:30 -070013323 do
13324 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013325 pMsg = vos_mem_malloc(sizeof(tSirSmeGetWPSPBCSessionsReq));
13326 if ( NULL == pMsg )
13327 status = eHAL_STATUS_FAILURE;
13328 else
13329 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013330 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013331 vos_mem_set(pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013332 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013333 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
lukez3c809222013-05-03 10:23:02 -070013334 VOS_ASSERT(pBuf);
13335
Jeff Johnson295189b2012-06-20 16:38:30 -070013336 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013337 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080013338 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void*));
13339 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070013340 // pSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080013341 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void *));
13342 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070013343 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013344 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013345 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013346 // MAC Address of STA in WPS session
Kiet Lam64c1b492013-07-12 13:56:44 +053013347 vos_mem_copy((tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
Jeff Johnson295189b2012-06-20 16:38:30 -070013348 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070013349 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013350 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013351 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013352 return( status );
13353}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013354
13355eHalStatus
13356csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
13357{
13358 tpSirChangeBIParams pMsg;
13359 tANI_U16 len = 0;
13360 eHalStatus status = eHAL_STATUS_SUCCESS;
13361 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13362
13363 if(!pSession)
13364 {
13365 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13366 return eHAL_STATUS_FAILURE;
13367 }
13368
13369 //NO need to update the Beacon Params if update beacon parameter flag is not set
13370 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
13371 return eHAL_STATUS_SUCCESS;
13372
13373 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
13374
13375 /* Create the message and send to lim */
13376 len = sizeof(tSirChangeBIParams);
Kiet Lam64c1b492013-07-12 13:56:44 +053013377 pMsg = vos_mem_malloc(len);
13378 if ( NULL == pMsg )
13379 status = eHAL_STATUS_FAILURE;
13380 else
13381 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013382 if(HAL_STATUS_SUCCESS(status))
13383 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013384 vos_mem_set(pMsg, sizeof(tSirChangeBIParams), 0);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013385 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
13386 pMsg->length = len;
13387
13388 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013389 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
13390 sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -080013391 smsLog( pMac, LOG1, FL("CSR Attempting to change BI for Bssid= "MAC_ADDRESS_STR),
13392 MAC_ADDR_ARRAY(pMsg->bssId));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013393 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013394 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013395 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
13396 status = palSendMBMessage(pMac->hHdd, pMsg);
13397 }
13398 return status;
13399}
13400
Jeff Johnson295189b2012-06-20 16:38:30 -070013401eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13402{
13403 eHalStatus status = eHAL_STATUS_SUCCESS;
13404 tSirSmeDeauthReq *pMsg;
13405 tANI_U8 *pBuf;
13406 tANI_U16 wTmp;
13407 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13408 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13409 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013410 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013411 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthReq ));
13412 if ( NULL == pMsg )
13413 status = eHAL_STATUS_FAILURE;
13414 else
13415 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013416 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013417 vos_mem_set(pMsg, sizeof( tSirSmeDeauthReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013418 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
13419 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
13420 //sessionId
13421 pBuf = &pMsg->sessionId;
13422 *pBuf++ = (tANI_U8)sessionId;
13423
13424 //tansactionId
13425 *pBuf = 0;
13426 *(pBuf + 1 ) = 0;
13427 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013428 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070013429 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070013430 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
13431 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013432 vos_mem_copy( (tSirMacAddr *)pBuf, pSession->selfMacAddr,
13433 sizeof( pMsg->peerMacAddr ) );
13434 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013435 pBuf = pBuf + sizeof(tSirMacAddr);
13436 }
13437 else
13438 {
13439 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013440 vos_mem_copy( (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13441 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013442 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013443 }
13444 if(!HAL_STATUS_SUCCESS(status))
13445 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013446 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013447 break;
13448 }
13449 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013450 vos_mem_copy( (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13451 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013452 pBuf = pBuf + sizeof(tSirMacAddr);
13453 if(!HAL_STATUS_SUCCESS(status))
13454 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013455 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013456 break;
13457 }
13458 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013459 vos_mem_copy( pBuf, &wTmp,sizeof( tANI_U16 ) );
13460 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013461 if(!HAL_STATUS_SUCCESS(status))
13462 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013463 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013464 break;
13465 }
13466 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013467 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013468 return( status );
13469}
13470
Jeff Johnson295189b2012-06-20 16:38:30 -070013471eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
13472{
13473 eHalStatus status = eHAL_STATUS_SUCCESS;
13474 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013475 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013476 pMsg = vos_mem_malloc(sizeof( tSirSmeDisassocCnf ));
13477 if ( NULL == pMsg )
13478 status = eHAL_STATUS_FAILURE;
13479 else
13480 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013481 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013482 vos_mem_set(pMsg, sizeof( tSirSmeDisassocCnf), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013483 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
13484 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13485 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013486 vos_mem_copy(pMsg->peerMacAddr, pDisassocInd->peerMacAddr,
13487 sizeof(pMsg->peerMacAddr));
13488 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013489 if(!HAL_STATUS_SUCCESS(status))
13490 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013491 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013492 break;
13493 }
13494//To test reconn
Kiet Lam64c1b492013-07-12 13:56:44 +053013495 vos_mem_copy(pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
13496 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013497 if(!HAL_STATUS_SUCCESS(status))
13498 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013499 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013500 break;
13501 }
13502//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070013503 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013504 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013505 return( status );
13506}
13507
Jeff Johnson295189b2012-06-20 16:38:30 -070013508eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
13509{
13510 eHalStatus status = eHAL_STATUS_SUCCESS;
13511 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013512 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013513 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthCnf ));
13514 if ( NULL == pMsg )
13515 status = eHAL_STATUS_FAILURE;
13516 else
13517 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013518 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013519 vos_mem_set(pMsg, sizeof( tSirSmeDeauthCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013520 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
13521 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13522 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013523 vos_mem_copy(pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
13524 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013525 if(!HAL_STATUS_SUCCESS(status))
13526 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013527 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013528 break;
13529 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013530 vos_mem_copy(pMsg->peerMacAddr, pDeauthInd->peerMacAddr,
13531 sizeof(pMsg->peerMacAddr));
13532 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013533 if(!HAL_STATUS_SUCCESS(status))
13534 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013535 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013536 break;
13537 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013538 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013539 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013540 return( status );
13541}
Jeff Johnson295189b2012-06-20 16:38:30 -070013542eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
13543{
13544 eHalStatus status = eHAL_STATUS_SUCCESS;
13545 tSirSmeAssocCnf *pMsg;
13546 tANI_U8 *pBuf;
13547 tSirResultCodes statusCode;
13548 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013549 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013550 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocCnf ));
13551 if ( NULL == pMsg )
13552 status = eHAL_STATUS_FAILURE;
13553 else
13554 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013555 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013556 vos_mem_set(pMsg, sizeof( tSirSmeAssocCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013557 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
13558 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013559 pBuf = (tANI_U8 *)&pMsg->statusCode;
13560 if(HAL_STATUS_SUCCESS(Halstatus))
13561 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13562 else
13563 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053013564 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes));
Jeff Johnson295189b2012-06-20 16:38:30 -070013565 pBuf += sizeof(tSirResultCodes);
13566 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013567 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13568 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013569 pBuf += sizeof (tSirMacAddr);
13570 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013571 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13572 sizeof(tSirMacAddr));
13573 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013574 pBuf += sizeof (tSirMacAddr);
13575 // aid
13576 wTmp = pal_cpu_to_be16(pAssocInd->aid);
Kiet Lam64c1b492013-07-12 13:56:44 +053013577 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013578 pBuf += sizeof (tANI_U16);
13579 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013580 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13581 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013582 pBuf += sizeof (tSirMacAddr);
13583 // alternateChannelId
13584 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070013585 status = palSendMBMessage( pMac->hHdd, pMsg );
13586 if(!HAL_STATUS_SUCCESS(status))
13587 {
13588 //pMsg is freed by palSendMBMessage
13589 break;
13590 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013591 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013592 return( status );
13593}
Jeff Johnson295189b2012-06-20 16:38:30 -070013594eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
13595 tpSirSmeAssocInd pAssocInd,
13596 eHalStatus Halstatus,
13597 tANI_U8 sessionId)
13598{
13599 tSirMsgQ msgQ;
Jeff Johnson295189b2012-06-20 16:38:30 -070013600 tSirSmeAssocIndToUpperLayerCnf *pMsg;
13601 tANI_U8 *pBuf;
13602 tSirResultCodes statusCode;
13603 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013604 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013605 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocIndToUpperLayerCnf ));
13606 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13607 vos_mem_set(pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ), 0);
Jeff Johnsone7245742012-09-05 17:12:55 -070013608
Jeff Johnson295189b2012-06-20 16:38:30 -070013609 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
13610 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
13611
13612 pMsg->sessionId = sessionId;
13613
13614 pBuf = (tANI_U8 *)&pMsg->statusCode;
13615 if(HAL_STATUS_SUCCESS(Halstatus))
13616 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13617 else
13618 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053013619 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes)) ;
Jeff Johnson295189b2012-06-20 16:38:30 -070013620 pBuf += sizeof(tSirResultCodes);
13621 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013622 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013623 pBuf += sizeof (tSirMacAddr);
13624 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013625 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13626 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013627 pBuf += sizeof (tSirMacAddr);
13628 // StaId
13629 wTmp = pal_cpu_to_be16(pAssocInd->staId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013630 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013631 pBuf += sizeof (tANI_U16);
13632 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013633 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013634 pBuf += sizeof (tSirMacAddr);
13635 // alternateChannelId
13636 *pBuf = 11;
13637 pBuf += sizeof (tANI_U8);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013638 // Instead of copying roam Info, we just copy only WmmEnabled, RsnIE information
Jeff Johnson295189b2012-06-20 16:38:30 -070013639 //Wmm
13640 *pBuf = pAssocInd->wmmEnabledSta;
13641 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013642 //RSN IE
Kiet Lam64c1b492013-07-12 13:56:44 +053013643 vos_mem_copy((tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070013644 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070013645 //Additional IE
Kiet Lam64c1b492013-07-12 13:56:44 +053013646 vos_mem_copy((void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
Jeff Johnson295189b2012-06-20 16:38:30 -070013647 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070013648 //reassocReq
13649 *pBuf = pAssocInd->reassocReq;
13650 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013651 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
13652 msgQ.bodyptr = pMsg;
13653 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013654 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013655 } while( 0 );
Kiet Lam64c1b492013-07-12 13:56:44 +053013656 return( eHAL_STATUS_SUCCESS );
Jeff Johnson295189b2012-06-20 16:38:30 -070013657}
Jeff Johnson295189b2012-06-20 16:38:30 -070013658
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013659eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -070013660 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
13661 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
13662 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
13663 tANI_U8 *pKeyRsc )
13664{
13665 tSirSmeSetContextReq *pMsg;
13666 tANI_U16 msgLen;
13667 eHalStatus status = eHAL_STATUS_FAILURE;
13668 tAniEdType tmpEdType;
13669 tAniKeyDirection tmpDirection;
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +053013670 tANI_U8 *pBuf = NULL;
13671 tANI_U8 *p = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013672 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013673 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070013674 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013675 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
13676 // key set. Since we only support upto one key, we always allocate memory for 1 key
13677 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
13678 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
13679 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
13680 ( sizeof( pMsg->keyMaterial.key ) );
13681
Kiet Lam64c1b492013-07-12 13:56:44 +053013682 pMsg = vos_mem_malloc(msgLen);
13683 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13684 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013685 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
13686 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013687 //sessionId
13688 pBuf = &pMsg->sessionId;
13689 *pBuf = (tANI_U8)sessionId;
13690 pBuf++;
13691 // transactionId
13692 *pBuf = 0;
13693 *(pBuf + 1) = 0;
13694 pBuf += sizeof(tANI_U16);
13695 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013696 vos_mem_copy(pBuf, (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013697
13698 pBuf += sizeof(tSirMacAddr);
13699
13700 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013701 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
13702 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013703
13704 pBuf += sizeof(tSirMacAddr);
13705
13706 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013707 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
13708 // in the tSirKeyMaterial keyMaterial; field).
13709 //
13710 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
13711 // shorter than this max size. Is LIM interpreting this ok ?
13712 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 -070013713 // set pMsg->keyMaterial.edType
13714 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013715 vos_mem_copy(p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013716 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070013717 // set the pMsg->keyMaterial.numKeys field
13718 *p = numKeys;
13719 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070013720 // set pSirKey->keyId = keyId;
13721 *p = keyId;
13722 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013723 // set pSirKey->unicast = (tANI_U8)fUnicast;
13724 *p = (tANI_U8)fUnicast;
13725 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070013726 // set pSirKey->keyDirection = aniKeyDirection;
13727 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
Kiet Lam64c1b492013-07-12 13:56:44 +053013728 vos_mem_copy(p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection));
Jeff Johnson295189b2012-06-20 16:38:30 -070013729 p += sizeof(tAniKeyDirection);
13730 // pSirKey->keyRsc = ;;
Kiet Lam64c1b492013-07-12 13:56:44 +053013731 vos_mem_copy(p, pKeyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -070013732 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070013733 // set pSirKey->paeRole
13734 *p = paeRole; // 0 is Supplicant
13735 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013736 // set pSirKey->keyLength = keyLength;
13737 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013738 if ( keyLength && pKey )
13739 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013740 vos_mem_copy(p, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013741 if(keyLength == 16)
13742 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013743 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 -070013744 keyId, edType, pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
13745 pKey[5], pKey[6], pKey[7], pKey[8],
13746 pKey[9], pKey[10], pKey[11], pKey[12], pKey[13], pKey[14], pKey[15]);
13747 }
13748 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013749 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013750 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013751 return( status );
13752}
13753
Jeff Johnson295189b2012-06-20 16:38:30 -070013754eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
13755 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
13756{
13757 eHalStatus status;
13758 tSirSmeStartBssReq *pMsg;
13759 tANI_U8 *pBuf = NULL;
13760 tANI_U8 *wTmpBuf = NULL;
13761 tANI_U16 msgLen, wTmp;
13762 tANI_U32 dwTmp;
13763 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070013764 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070013765 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070013766 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013767
13768 if(!pSession)
13769 {
13770 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13771 return eHAL_STATUS_FAILURE;
13772 }
13773
Jeff Johnson295189b2012-06-20 16:38:30 -070013774 do {
13775 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
13776 pSession->joinFailStatusCode.reasonCode = 0;
13777 msgLen = sizeof(tSirSmeStartBssReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053013778 pMsg = vos_mem_malloc(msgLen);
13779 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13780 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013781 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013782 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013783 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013784 //sessionId
13785 *pBuf = (tANI_U8)sessionId;
13786 pBuf++;
13787 // transactionId
13788 *pBuf = 0;
13789 *(pBuf + 1) = 0;
13790 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013791 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053013792 vos_mem_copy(pBuf, pParam->bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013793 pBuf += sizeof(tSirMacAddr);
13794 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013795 vos_mem_copy(pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013796 pBuf += sizeof(tSirMacAddr);
13797 // beaconInterval
13798 if( pBssDesc && pBssDesc->beaconInterval )
13799 {
13800 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
13801 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013802 else if(pParam->beaconInterval)
13803 {
13804 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
13805 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013806 else
13807 {
13808 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
13809 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -070013810 if(csrIsconcurrentsessionValid (pMac, sessionId,
13811 pParam->bssPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -070013812 == eHAL_STATUS_SUCCESS )
13813 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013814 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070013815 pParam->bssPersona);
13816 //Update the beacon Interval
13817 pParam->beaconInterval = wTmp;
13818 }
13819 else
13820 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013821 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070013822 status = eHAL_STATUS_FAILURE;
Kiet Lam64c1b492013-07-12 13:56:44 +053013823 vos_mem_free(pMsg);
Jeff Johnsone7245742012-09-05 17:12:55 -070013824 return status;
13825 }
13826
Kiet Lam64c1b492013-07-12 13:56:44 +053013827 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013828 pBuf += sizeof(tANI_U16);
13829 // dot11mode
13830 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
13831 pBuf += 1;
13832 // bssType
13833 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013834 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013835 pBuf += sizeof(tSirBssType);
13836 // ssId
13837 if( pParam->ssId.length )
13838 {
13839 // ssId len
13840 *pBuf = pParam->ssId.length;
13841 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053013842 vos_mem_copy(pBuf, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070013843 pBuf += pParam->ssId.length;
13844 }
13845 else
13846 {
13847 *pBuf = 0;
13848 pBuf++;
13849 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013850 // set the channel Id
13851 *pBuf = pParam->operationChn;
13852 pBuf++;
13853 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070013854 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013855 vos_mem_copy(pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState));
Jeff Johnsone7245742012-09-05 17:12:55 -070013856 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070013857
Jeff Johnson295189b2012-06-20 16:38:30 -070013858 // Set privacy
13859 *pBuf = pParam->privacy;
13860 pBuf++;
13861
13862 //Set Uapsd
13863 *pBuf = pParam->ApUapsdEnable;
13864 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013865 //Set SSID hidden
13866 *pBuf = pParam->ssidHidden;
13867 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013868 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
13869 pBuf++;
13870
13871 //Ht protection Enable/Disable
13872 *pBuf = (tANI_U8)pParam->protEnabled;
13873 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013874 //Enable Beacons to Receive for OBSS protection Enable/Disable
13875 *pBuf = (tANI_U8)pParam->obssProtEnabled;
13876 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013877 //set cfg related to protection
13878 wTmp = pal_cpu_to_be16( pParam->ht_protection );
Kiet Lam64c1b492013-07-12 13:56:44 +053013879 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013880 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013881 // Set Auth type
13882 authType = pal_cpu_to_be32(pParam->authType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013883 vos_mem_copy(pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013884 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013885 // Set DTIM
13886 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
Kiet Lam64c1b492013-07-12 13:56:44 +053013887 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013888 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013889 // Set wps_state
13890 *pBuf = pParam->wps_state;
13891 pBuf++;
krunal sonie9002db2013-11-25 14:24:17 -080013892 // set isCoalesingInIBSSAllowed
13893 *pBuf = pMac->isCoalesingInIBSSAllowed;
13894 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013895 //Persona
13896 *pBuf = (tANI_U8)pParam->bssPersona;
13897 pBuf++;
13898
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080013899 //txLdpcIniFeatureEnabled
13900 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
13901 pBuf++;
krunal soni4f087d22013-07-29 16:32:26 -070013902
Chet Lanctot8cecea22014-02-11 19:09:36 -080013903#ifdef WLAN_FEATURE_11W
13904 // Set MFP capable/required
13905 *pBuf = (tANI_U8)pParam->mfpCapable;
13906 pBuf++;
13907 *pBuf = (tANI_U8)pParam->mfpRequired;
13908 pBuf++;
13909#endif
13910
krunal soni4f087d22013-07-29 16:32:26 -070013911 // set RSN IE
Jeff Johnson295189b2012-06-20 16:38:30 -070013912 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
13913 {
13914 status = eHAL_STATUS_INVALID_PARAMETER;
Kiet Lam64c1b492013-07-12 13:56:44 +053013915 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013916 break;
13917 }
13918 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
Kiet Lam64c1b492013-07-12 13:56:44 +053013919 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013920 pBuf += sizeof(tANI_U16);
13921 if( wTmp )
13922 {
13923 wTmp = pParam->nRSNIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +053013924 vos_mem_copy(pBuf, pParam->pRSNIE, wTmp);
Jeff Johnson295189b2012-06-20 16:38:30 -070013925 pBuf += wTmp;
13926 }
13927 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013928 vos_mem_copy(pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013929 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070013930 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
13931 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053013932 vos_mem_copy(pBuf, pParam->operationalRateSet.rate,
13933 pParam->operationalRateSet.numRates );
Jeff Johnson295189b2012-06-20 16:38:30 -070013934 pBuf += pParam->operationalRateSet.numRates ;
13935 *pBuf++ = pParam->extendedRateSet.numRates;
13936 if(0 != pParam->extendedRateSet.numRates)
13937 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013938 vos_mem_copy(pBuf, pParam->extendedRateSet.rate,
13939 pParam->extendedRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070013940 pBuf += pParam->extendedRateSet.numRates;
13941 }
krunal sonie9002db2013-11-25 14:24:17 -080013942
Jeff Johnson295189b2012-06-20 16:38:30 -070013943 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
13944 pMsg->length = pal_cpu_to_be16(msgLen);
13945
13946 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013947 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013948 return( status );
13949}
13950
Jeff Johnson295189b2012-06-20 16:38:30 -070013951eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
13952{
13953 eHalStatus status = eHAL_STATUS_FAILURE;
13954 tSirSmeStopBssReq *pMsg;
13955 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13956 tANI_U8 *pBuf;
13957 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013958
13959 if(!pSession)
13960 {
13961 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13962 return eHAL_STATUS_FAILURE;
13963 }
13964
Jeff Johnson295189b2012-06-20 16:38:30 -070013965 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013966 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
13967 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13968 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013969 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13970 pBuf = &pMsg->sessionId;
13971 //sessionId
13972 *pBuf = (tANI_U8)sessionId;
13973 pBuf++;
13974 // transactionId
13975 *pBuf = 0;
13976 pBuf += sizeof(tANI_U16);
13977 //reason code
13978 *pBuf = 0;
13979 pBuf += sizeof(tSirResultCodes);
13980 // bssid
13981 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13982 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13983 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013984 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->selfMacAddr,
13985 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013986 }
13987 else
13988 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013989 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
13990 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013991 }
13992 pBuf += sizeof(tSirMacAddr);
13993 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
13994 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013995 status = palSendMBMessage( pMac->hHdd, pMsg );
13996#if 0
Kiet Lam64c1b492013-07-12 13:56:44 +053013997 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
13998 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13999 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014000 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
14001 pMsg->reasonCode = 0;
14002 // bssid
14003 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
14004 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
14005 {
14006 pbBssid = (tANI_U8 *)&pSession->selfMacAddr;
14007 }
14008 else
14009 {
14010 pbBssid = (tANI_U8 *)&pSession->connectedProfile.bssid;
14011 }
Kiet Lam64c1b492013-07-12 13:56:44 +053014012 vos_mem_copy(&pMsg->bssId, pbBssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014013 pMsg->transactionId = 0;
14014 pMsg->sessionId = (tANI_U8)sessionId;
14015 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeStopBssReq ));
14016 status = palSendMBMessage( pMac->hHdd, pMsg );
14017#endif
14018 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014019 return( status );
14020}
14021
Jeff Johnson295189b2012-06-20 16:38:30 -070014022eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
14023 tCsrRoamModifyProfileFields *pModProfileFields,
14024 tANI_U32 *pRoamId, v_BOOL_t fForce)
14025{
Jeff Johnson295189b2012-06-20 16:38:30 -070014026 eHalStatus status = eHAL_STATUS_FAILURE;
14027 tANI_U32 roamId = 0;
14028 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014029 if((csrIsConnStateConnected(pMac, sessionId)) &&
Kiet Lam64c1b492013-07-12 13:56:44 +053014030 (fForce || (!vos_mem_compare( &pModProfileFields,
14031 &pSession->connectedProfile.modifyProfileFields,
14032 sizeof(tCsrRoamModifyProfileFields)))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070014033 {
14034 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
14035 if(pRoamId)
14036 {
14037 *pRoamId = roamId;
14038 }
14039
Jeff Johnson295189b2012-06-20 16:38:30 -070014040 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
14041 eCsrSmeIssuedReassocToSameAP, roamId,
14042 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014043 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014044 return status;
14045}
Jeff Johnson295189b2012-06-20 16:38:30 -070014046static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
14047{
14048 eHalStatus status = eHAL_STATUS_SUCCESS;
14049 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +053014050 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014051 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
14052 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
14053 return (status);
14054}
Jeff Johnson295189b2012-06-20 16:38:30 -070014055eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
14056{
14057 eHalStatus status = eHAL_STATUS_SUCCESS;
14058 tListElem *pEntry = NULL;
14059 tSmeCmd *pCommand = NULL;
14060 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014061 do
14062 {
14063 if(pMsg == NULL)
14064 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014065 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014066 status = eHAL_STATUS_FAILURE;
14067 break;
14068 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014069 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
14070 if(pEntry)
14071 {
14072 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14073 if(eSmeCommandAddStaSession == pCommand->command)
14074 {
14075 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014076 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014077 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070014078 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014079 //Remove this command out of the active list
14080 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
14081 {
14082 //Now put this command back on the avilable command list
14083 csrReleaseCommand(pMac, pCommand);
14084 }
14085 smeProcessPendingQueue( pMac );
14086 }
14087 else
14088 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014089 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 -070014090 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014091 status = eHAL_STATUS_FAILURE;
14092 break;
14093 }
14094 }
14095 else
14096 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014097 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 -070014098 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014099 status = eHAL_STATUS_FAILURE;
14100 break;
14101 }
14102 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014103 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014104}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014105eHalStatus csrSendMBAddSelfStaReqMsg(tpAniSirGlobal pMac,
14106 tAddStaForSessionCmd *pAddStaReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070014107{
14108 tSirSmeAddStaSelfReq *pMsg;
14109 tANI_U16 msgLen;
14110 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014111 do {
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014112 msgLen = sizeof(tSirSmeAddStaSelfReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053014113 pMsg = vos_mem_malloc(msgLen);
14114 if ( NULL == pMsg ) break;
14115 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014116 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
14117 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014118 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053014119 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr,
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014120 (tANI_U8 *)&pAddStaReq->selfMacAddr, sizeof(tSirMacAddr));
14121
14122 pMsg->currDeviceMode = pAddStaReq->currDeviceMode;
14123
Arif Hussain24bafea2013-11-15 15:10:03 -080014124 smsLog( pMac, LOG1, FL("selfMac="MAC_ADDRESS_STR),
14125 MAC_ADDR_ARRAY(pMsg->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014126 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014127 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014128 return( status );
14129}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014130eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac,
14131 tANI_U32 sessionId,
14132 tSirMacAddr sessionMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -070014133{
14134 eHalStatus status = eHAL_STATUS_SUCCESS;
14135 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014136 pCommand = csrGetCommandBuffer(pMac);
14137 if(NULL == pCommand)
14138 {
14139 status = eHAL_STATUS_RESOURCES;
14140 }
14141 else
14142 {
14143 pCommand->command = eSmeCommandAddStaSession;
14144 pCommand->sessionId = (tANI_U8)sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053014145 vos_mem_copy(pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr,
14146 sizeof( tSirMacAddr ) );
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014147 pCommand->u.addStaSessionCmd.currDeviceMode = pMac->sme.currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070014148 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
14149 if( !HAL_STATUS_SUCCESS( status ) )
14150 {
14151 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014152 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014153 }
14154 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014155 return (status);
14156}
Jeff Johnson295189b2012-06-20 16:38:30 -070014157eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14158{
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014159 return csrSendMBAddSelfStaReqMsg(pMac, &pCommand->u.addStaSessionCmd);
Jeff Johnson295189b2012-06-20 16:38:30 -070014160}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014161eHalStatus csrRoamOpenSession(tpAniSirGlobal pMac,
14162 csrRoamCompleteCallback callback,
14163 void *pContext, tANI_U8 *pSelfMacAddr,
14164 tANI_U8 *pbSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -070014165{
14166 eHalStatus status = eHAL_STATUS_SUCCESS;
14167 tANI_U32 i;
14168 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070014169 *pbSessionId = CSR_SESSION_ID_INVALID;
14170 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14171 {
14172 if( !CSR_IS_SESSION_VALID( pMac, i ) )
14173 {
14174 pSession = CSR_GET_SESSION( pMac, i );
14175 status = eHAL_STATUS_SUCCESS;
14176 pSession->sessionActive = eANI_BOOLEAN_TRUE;
14177 pSession->sessionId = (tANI_U8)i;
14178 pSession->callback = callback;
14179 pSession->pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053014180 vos_mem_copy(&pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070014181 *pbSessionId = (tANI_U8)i;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014182 status = vos_timer_init(&pSession->hTimerRoaming, VOS_TIMER_TYPE_SW,
14183 csrRoamRoamingTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070014184 &pSession->roamingTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014185 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014186 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014187 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014188 break;
14189 }
14190#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014191 status = vos_timer_init(&pSession->hTimerJoinRetry, VOS_TIMER_TYPE_SW,
14192 csrRoamJoinRetryTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070014193 &pSession->joinRetryTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014194 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014195 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014196 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014197 break;
14198 }
14199#endif
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014200 status = csrIssueAddStaForSessionReq (pMac, i, pSelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014201 break;
14202 }
14203 }
14204 if( CSR_ROAM_SESSION_MAX == i )
14205 {
14206 //No session is available
14207 status = eHAL_STATUS_RESOURCES;
14208 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014209 return ( status );
14210}
Jeff Johnson295189b2012-06-20 16:38:30 -070014211eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
14212{
14213 eHalStatus status = eHAL_STATUS_SUCCESS;
14214 tListElem *pEntry = NULL;
14215 tSmeCmd *pCommand = NULL;
14216 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014217 do
14218 {
14219 if(pMsg == NULL)
14220 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014221 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014222 status = eHAL_STATUS_FAILURE;
14223 break;
14224 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014225 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
14226 if(pEntry)
14227 {
14228 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14229 if(eSmeCommandDelStaSession == pCommand->command)
14230 {
14231 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070014232 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014233 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014234 //This session is done.
14235 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014236 if(pCommand->u.delStaSessionCmd.callback)
14237 {
14238
14239 status = sme_ReleaseGlobalLock( &pMac->sme );
14240 if ( HAL_STATUS_SUCCESS( status ) )
14241 {
14242 pCommand->u.delStaSessionCmd.callback(
14243 pCommand->u.delStaSessionCmd.pContext);
14244 status = sme_AcquireGlobalLock( &pMac->sme );
14245 if (! HAL_STATUS_SUCCESS( status ) )
14246 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014247 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014248 return status;
14249 }
14250 }
14251 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014252 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014253 }
14254 }
14255
14256 //Remove this command out of the active list
14257 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
14258 {
14259 //Now put this command back on the avilable command list
14260 csrReleaseCommand(pMac, pCommand);
14261 }
14262 smeProcessPendingQueue( pMac );
14263 }
14264 else
14265 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014266 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 -070014267 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014268 status = eHAL_STATUS_FAILURE;
14269 break;
14270 }
14271 }
14272 else
14273 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014274 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 -070014275 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014276 status = eHAL_STATUS_FAILURE;
14277 break;
14278 }
14279 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014280 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014281}
Jeff Johnson295189b2012-06-20 16:38:30 -070014282eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
14283{
14284 tSirSmeDelStaSelfReq *pMsg;
14285 tANI_U16 msgLen;
14286 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014287 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070014288 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
14289 sizeof( tSirBssType )*/;
Kiet Lam64c1b492013-07-12 13:56:44 +053014290 pMsg = vos_mem_malloc(msgLen);
14291 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14292 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014293 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
14294 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014295 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053014296 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr,
14297 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014298 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014299 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014300 return( status );
14301}
Jeff Johnson295189b2012-06-20 16:38:30 -070014302eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
14303 tSirMacAddr sessionMacAddr,
14304 csrRoamSessionCloseCallback callback,
14305 void *pContext)
14306{
14307 eHalStatus status = eHAL_STATUS_SUCCESS;
14308 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014309 pCommand = csrGetCommandBuffer(pMac);
14310 if(NULL == pCommand)
14311 {
14312 status = eHAL_STATUS_RESOURCES;
14313 }
14314 else
14315 {
14316 pCommand->command = eSmeCommandDelStaSession;
14317 pCommand->sessionId = (tANI_U8)sessionId;
14318 pCommand->u.delStaSessionCmd.callback = callback;
14319 pCommand->u.delStaSessionCmd.pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053014320 vos_mem_copy(pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr,
14321 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014322 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
14323 if( !HAL_STATUS_SUCCESS( status ) )
14324 {
14325 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014326 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014327 }
14328 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014329 return (status);
14330}
Jeff Johnson295189b2012-06-20 16:38:30 -070014331eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14332{
14333 return csrSendMBDelSelfStaReqMsg( pMac,
14334 pCommand->u.delStaSessionCmd.selfMacAddr );
14335}
Jeff Johnson295189b2012-06-20 16:38:30 -070014336static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
14337{
14338 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
14339 tListElem *pEntry, *pNext;
14340 tSmeCmd *pCommand;
14341 tDblLinkList localList;
14342
14343 vos_mem_zero(&localList, sizeof(tDblLinkList));
14344 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
14345 {
14346 smsLog(pMac, LOGE, FL(" failed to open list"));
14347 return;
14348 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014349 csrLLLock(pList);
14350 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
14351 while(pEntry != NULL)
14352 {
14353 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
14354 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14355 if(pCommand->sessionId == sessionId)
14356 {
14357 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
14358 {
14359 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
14360 }
14361 }
14362 pEntry = pNext;
14363 }
14364 csrLLUnlock(pList);
14365
14366 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
14367 {
14368 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14369 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
14370 }
14371 csrLLClose(&localList);
14372}
14373
Jeff Johnson295189b2012-06-20 16:38:30 -070014374void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
14375{
14376 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14377 {
14378 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014379 csrRoamStop(pMac, sessionId);
14380 csrFreeConnectBssDesc(pMac, sessionId);
14381 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
14382 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014383 vos_timer_destroy(&pSession->hTimerRoaming);
Jeff Johnson295189b2012-06-20 16:38:30 -070014384#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014385 vos_timer_destroy(&pSession->hTimerJoinRetry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014386#endif
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014387 purgeSmeSessionCmdList(pMac, sessionId, &pMac->sme.smeCmdPendingList);
14388 if (pMac->fScanOffload)
14389 {
14390 purgeSmeSessionCmdList(pMac, sessionId,
14391 &pMac->sme.smeScanCmdPendingList);
14392 }
14393
Jeff Johnson295189b2012-06-20 16:38:30 -070014394 purgeCsrSessionCmdList(pMac, sessionId);
14395 csrInitSession(pMac, sessionId);
14396 }
14397}
14398
Jeff Johnson295189b2012-06-20 16:38:30 -070014399eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
14400 tANI_BOOLEAN fSync,
14401 csrRoamSessionCloseCallback callback,
14402 void *pContext )
14403{
14404 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014405 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14406 {
14407 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14408 if(fSync)
14409 {
14410 csrCleanupSession(pMac, sessionId);
14411 }
14412 else
14413 {
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014414 purgeSmeSessionCmdList(pMac, sessionId,
14415 &pMac->sme.smeCmdPendingList);
14416 if (pMac->fScanOffload)
14417 {
14418 purgeSmeSessionCmdList(pMac, sessionId,
14419 &pMac->sme.smeScanCmdPendingList);
14420 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014421 purgeCsrSessionCmdList(pMac, sessionId);
14422 status = csrIssueDelStaForSessionReq( pMac, sessionId,
14423 pSession->selfMacAddr, callback, pContext);
14424 }
14425 }
14426 else
14427 {
14428 status = eHAL_STATUS_INVALID_PARAMETER;
14429 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014430 return ( status );
14431}
14432
Jeff Johnson295189b2012-06-20 16:38:30 -070014433static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
14434{
14435 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014436
14437 if(!pSession)
14438 {
14439 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14440 return;
14441 }
14442
Jeff Johnson295189b2012-06-20 16:38:30 -070014443 pSession->sessionActive = eANI_BOOLEAN_FALSE;
14444 pSession->sessionId = CSR_SESSION_ID_INVALID;
14445 pSession->callback = NULL;
14446 pSession->pContext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014447 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
14448 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
14449 csrFreeRoamProfile( pMac, sessionId );
14450 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
14451 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
14452 csrFreeConnectBssDesc(pMac, sessionId);
14453 csrScanEnable(pMac);
Kiet Lam64c1b492013-07-12 13:56:44 +053014454 vos_mem_set(&pSession->selfMacAddr, sizeof(tCsrBssid), 0);
14455 if (pSession->pWpaRsnReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014456 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014457 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014458 pSession->pWpaRsnReqIE = NULL;
14459 }
14460 pSession->nWpaRsnReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014461 if (pSession->pWpaRsnRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014462 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014463 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014464 pSession->pWpaRsnRspIE = NULL;
14465 }
14466 pSession->nWpaRsnRspIeLength = 0;
14467#ifdef FEATURE_WLAN_WAPI
Kiet Lam64c1b492013-07-12 13:56:44 +053014468 if (pSession->pWapiReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014469 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014470 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014471 pSession->pWapiReqIE = NULL;
14472 }
14473 pSession->nWapiReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014474 if (pSession->pWapiRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014475 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014476 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014477 pSession->pWapiRspIE = NULL;
14478 }
14479 pSession->nWapiRspIeLength = 0;
14480#endif /* FEATURE_WLAN_WAPI */
Agarwal Ashish4f616132013-12-30 23:32:50 +053014481 if (pSession->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070014482 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053014483 memset(pSession->addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH);
Jeff Johnson295189b2012-06-20 16:38:30 -070014484 }
14485 pSession->nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053014486
Kiet Lam64c1b492013-07-12 13:56:44 +053014487 if (pSession->pAddIEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070014488 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014489 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070014490 pSession->pAddIEAssoc = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053014491 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014492 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014493}
14494
Jeff Johnson295189b2012-06-20 16:38:30 -070014495eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
14496{
14497 eHalStatus status = eHAL_STATUS_FAILURE;
14498 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070014499 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14500 {
14501 if( CSR_IS_SESSION_VALID( pMac, i ) )
14502 {
14503 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
14504 {
14505 //Found it
14506 status = eHAL_STATUS_SUCCESS;
14507 *pSessionId = i;
14508 break;
14509 }
14510 }
14511 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014512 return( status );
14513}
14514
Jeff Johnson295189b2012-06-20 16:38:30 -070014515//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
14516//session because for IBSS, the bssid changes.
14517static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
14518{
14519 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
14520 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070014521 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14522 {
14523 if( CSR_IS_SESSION_VALID( pMac, i ) )
14524 {
14525 pSession = CSR_GET_SESSION( pMac, i );
14526 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
14527 {
14528 //Found it
14529 nRet = i;
14530 break;
14531 }
14532 }
14533 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014534 return (nRet);
14535}
Jeff Johnson295189b2012-06-20 16:38:30 -070014536static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
14537{
14538 /* Update the current BSS info in ho control block based on connected
14539 profile info from pmac global structure */
14540
Arif Hussain24bafea2013-11-15 15:10:03 -080014541 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= "MAC_ADDRESS_STR,
14542 MAC_ADDR_ARRAY(bssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070014543 /* Check for user misconfig of RSSI trigger threshold */
14544 pMac->roam.configParam.vccRssiThreshold =
14545 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
14546 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
14547 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070014548 /* Check for user misconfig of UL MAC Loss trigger threshold */
14549 pMac->roam.configParam.vccUlMacLossThreshold =
14550 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
14551 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014552#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14553 {
14554 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014555 /* Indicate the neighbor roal algorithm about the connect indication */
14556 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
14557 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
14558 }
14559#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014560}
14561
Jeff Johnson295189b2012-06-20 16:38:30 -070014562static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
14563{
14564 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014565
14566 if(!pSession)
14567 {
14568 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14569 return;
14570 }
14571
Jeff Johnson295189b2012-06-20 16:38:30 -070014572 //Only to handle the case for Handover on infra link
14573 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
14574 {
14575 return;
14576 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014577 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
14578 csrRoamDeregStatisticsReq(pMac);
14579 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14580#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14581 /* Indicate the neighbor roal algorithm about the disconnect indication */
14582 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
14583#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070014584
14585 //Remove this code once SLM_Sessionization is supported
14586 //BMPS_WORKAROUND_NOT_NEEDED
14587 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070014588 csrIsInfraApStarted( pMac ) &&
14589 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070014590 {
14591 pMac->roam.configParam.doBMPSWorkaround = 0;
14592 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014593}
14594
Jeff Johnson295189b2012-06-20 16:38:30 -070014595void csrRoamTlStatsTimerHandler(void *pv)
14596{
14597 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
14598 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014599 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14600
Jeff Johnsone7245742012-09-05 17:12:55 -070014601 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
14602
Jeff Johnson295189b2012-06-20 16:38:30 -070014603#if 0
14604 // TODO Persession .???
14605 //req TL for stats
14606 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
14607 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014608 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014609 }
14610 else
14611 {
14612 //save in SME
14613 csrRoamSaveStatsFromTl(pMac, tlStats);
14614 }
14615#endif
14616 if(!pMac->roam.tlStatsReqInfo.timerRunning)
14617 {
14618 if(pMac->roam.tlStatsReqInfo.periodicity)
14619 {
14620 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014621 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
14622 pMac->roam.tlStatsReqInfo.periodicity);
14623 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014624 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014625 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014626 return;
14627 }
14628 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
14629 }
14630 }
14631}
Jeff Johnson295189b2012-06-20 16:38:30 -070014632void csrRoamPeStatsTimerHandler(void *pv)
14633{
14634 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
14635 eHalStatus status;
14636 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
14637 VOS_STATUS vosStatus;
14638 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070014639 pPeStatsReqListEntry->timerRunning = FALSE;
14640 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
14641 {
14642 // If we entered here, meaning the timer could not be successfully
14643 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
14644
14645 /* Destroy the timer */
14646 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
14647 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14648 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014649 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014650 }
14651
14652 // Free the entry
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014653 vos_mem_free(pPeStatsReqListEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014654 pPeStatsReqListEntry = NULL;
14655 }
14656 else
14657 {
14658 if(!pPeStatsReqListEntry->rspPending)
14659 {
14660 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
14661 pPeStatsReqListEntry->staId);
14662 if(!HAL_STATUS_SUCCESS(status))
14663 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014664 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014665 }
14666 else
14667 {
14668 pPeStatsReqListEntry->rspPending = TRUE;
14669 }
14670 }
14671
14672 //send down a req
14673 if(pPeStatsReqListEntry->periodicity &&
14674 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
14675 {
14676 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
14677 if(ePMC_FULL_POWER == powerState)
14678 {
14679 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
14680 {
14681 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
14682 }
14683 }
14684 else
14685 {
14686 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
14687 {
14688 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
14689 }
14690 }
14691 //start timer
14692 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
14693 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14694 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014695 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014696 return;
14697 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014698 pPeStatsReqListEntry->timerRunning = TRUE;
14699
14700 }
14701
14702 }
14703}
Jeff Johnson295189b2012-06-20 16:38:30 -070014704void csrRoamStatsClientTimerHandler(void *pv)
14705{
14706 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070014707 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
14708 {
14709#if 0
14710 // TODO Stats fix for multisession
14711 //start the timer
14712 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
14713
14714 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14715 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014716 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014717 }
14718#endif
14719 }
14720#if 0
14721 //send up the stats report
14722 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
14723 pStaEntry->staId, pStaEntry->pContext);
14724#endif
14725}
14726
14727
14728
Jeff Johnson295189b2012-06-20 16:38:30 -070014729eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
14730{
14731 tAniGetPEStatsReq *pMsg;
14732 eHalStatus status = eHAL_STATUS_SUCCESS;
Kiet Lam64c1b492013-07-12 13:56:44 +053014733 pMsg = vos_mem_malloc(sizeof(tAniGetPEStatsReq));
14734 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070014735 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053014736 smsLog(pMac, LOGE, FL( "Failed to allocate mem for stats req "));
Kiet Lam64c1b492013-07-12 13:56:44 +053014737 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014738 }
14739 // need to initiate a stats request to PE
14740 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_STATISTICS_REQ);
14741 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
14742 pMsg->staId = staId;
14743 pMsg->statsMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070014744 status = palSendMBMessage(pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070014745 if(!HAL_STATUS_SUCCESS(status))
14746 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053014747 smsLog(pMac, LOG1, FL("Failed to send down the stats req "));
Jeff Johnson295189b2012-06-20 16:38:30 -070014748 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014749 return status;
14750}
Jeff Johnson295189b2012-06-20 16:38:30 -070014751void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
14752{
14753 tAniGetPEStatsRsp *pSmeStatsRsp;
14754 eHalStatus status = eHAL_STATUS_FAILURE;
14755 tListElem *pEntry = NULL;
14756 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
14757 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
14758 tANI_U32 tempMask = 0;
14759 tANI_U8 counter = 0;
14760 tANI_U8 *pStats = NULL;
14761 tANI_U32 length = 0;
14762 v_PVOID_t pvosGCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014763 v_S7_t rssi = 0, snr = 0;
14764 tANI_U32 *pRssi = NULL, *pSnr = NULL;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014765 tANI_U32 linkCapacity;
Jeff Johnson295189b2012-06-20 16:38:30 -070014766 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
14767 if(pSmeStatsRsp->rc)
14768 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014769 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014770 goto post_update;
14771 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014772 tempMask = pSmeStatsRsp->statsMask;
14773 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070014774 /* subtract all statistics from this length, and after processing the entire
14775 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
14776 * in this 'stats' message.
14777 */
14778 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070014779 //new stats info from PE, fill up the stats strucutres in PMAC
14780 while(tempMask)
14781 {
14782 if(tempMask & 1)
14783 {
14784 switch(counter)
14785 {
14786 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014787 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014788 vos_mem_copy((tANI_U8 *)&pMac->roam.summaryStatsInfo,
14789 pStats, sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014790 pStats += sizeof(tCsrSummaryStatsInfo);
14791 length -= sizeof(tCsrSummaryStatsInfo);
14792 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014793 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014794 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014795 vos_mem_copy((tANI_U8 *)&pMac->roam.classAStatsInfo,
14796 pStats, sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014797 pStats += sizeof(tCsrGlobalClassAStatsInfo);
14798 length -= sizeof(tCsrGlobalClassAStatsInfo);
14799 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014800 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014801 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014802 vos_mem_copy((tANI_U8 *)&pMac->roam.classBStatsInfo,
14803 pStats, sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014804 pStats += sizeof(tCsrGlobalClassBStatsInfo);
14805 length -= sizeof(tCsrGlobalClassBStatsInfo);
14806 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014807 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014808 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014809 vos_mem_copy((tANI_U8 *)&pMac->roam.classCStatsInfo,
14810 pStats, sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014811 pStats += sizeof(tCsrGlobalClassCStatsInfo);
14812 length -= sizeof(tCsrGlobalClassCStatsInfo);
14813 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014814 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014815 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014816 if( CSR_MAX_STA > pSmeStatsRsp->staId )
14817 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014818 vos_mem_copy((tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
14819 pStats, sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014820 }
14821 else
14822 {
14823 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014824 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014825 VOS_ASSERT( 0 );
14826 }
14827 if(!HAL_STATUS_SUCCESS(status))
14828 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014829 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014830 }
14831 pStats += sizeof(tCsrPerStaStatsInfo);
14832 length -= sizeof(tCsrPerStaStatsInfo);
14833 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014834 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014835 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014836 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014837 }
14838 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014839 tempMask >>=1;
14840 counter++;
14841 }
14842 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
14843 if (length != 0)
14844 {
14845 pRssi = (tANI_U32*)pStats;
14846 rssi = (v_S7_t)*pRssi;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014847 pStats += sizeof(tANI_U32);
14848 length -= sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070014849 }
14850 else
14851 {
14852 /* If riva is not sending rssi, continue to use the hack */
14853 rssi = RSSI_HACK_BMPS;
14854 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014855
Jeff Johnson295189b2012-06-20 16:38:30 -070014856 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014857
14858 if (length != 0)
14859 {
14860 linkCapacity = *(tANI_U32*)pStats;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014861 pStats += sizeof(tANI_U32);
14862 length -= sizeof(tANI_U32);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014863 }
14864 else
14865 {
14866 linkCapacity = 0;
14867 }
14868
14869 WDA_UpdateLinkCapacity(pvosGCtx, pSmeStatsRsp->staId, linkCapacity);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014870
14871 if (length != 0)
14872 {
14873 pSnr = (tANI_U32*)pStats;
14874 snr = (v_S7_t)*pSnr;
14875 }
14876 else
14877 {
14878 snr = SNR_HACK_BMPS;
14879 }
14880
14881 WDA_UpdateSnrBmps(pvosGCtx, pSmeStatsRsp->staId, snr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014882post_update:
14883 //make sure to update the pe stats req list
14884 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
14885 if(pEntry)
14886 {
14887 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
14888 pPeStaEntry->rspPending = FALSE;
14889
14890 }
14891 //check the one timer cases
14892 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
14893 if(pEntry)
14894 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014895 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014896 if(pTempStaEntry->timerExpired)
14897 {
14898 //send up the stats report
14899 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
14900 pTempStaEntry->staId, pTempStaEntry->pContext);
14901 //also remove from the client list
14902 csrRoamRemoveStatListEntry(pMac, pEntry);
14903 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014904 }
14905 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014906}
Jeff Johnson295189b2012-06-20 16:38:30 -070014907tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14908{
14909 tListElem *pEntry = NULL;
14910 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014911 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014912 if(!pEntry)
14913 {
14914 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014915 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070014916 return NULL;
14917 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014918 while( pEntry )
14919 {
14920 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014921 if(pTempStaEntry->statsMask == statsMask)
14922 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014923 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014924 break;
14925 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014926 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
14927 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014928 return pEntry;
14929}
14930
Jeff Johnson295189b2012-06-20 16:38:30 -070014931tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
14932 tANI_BOOLEAN update)
14933{
14934 tListElem *pEntry;
14935 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014936 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014937 if(!pEntry)
14938 {
14939 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014940 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014941 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014942 return NULL;
14943 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014944 while( pEntry )
14945 {
14946 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014947 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
14948 (pTempStaEntry->statsMask == pStaEntry->statsMask))
14949 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014950 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014951 if(update)
14952 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014953 pTempStaEntry->periodicity = pStaEntry->periodicity;
14954 pTempStaEntry->callback = pStaEntry->callback;
14955 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070014956 }
14957 break;
14958 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014959 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14960 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014961 return pEntry;
14962}
Jeff Johnson295189b2012-06-20 16:38:30 -070014963tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14964{
14965 tListElem *pEntry;
14966 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014967 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014968 if(!pEntry)
14969 {
14970 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014971 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014972 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014973 return NULL;
14974 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014975 while( pEntry )
14976 {
14977 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014978 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
14979 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014980 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014981 break;
14982 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014983 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14984 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014985 return pEntry;
14986}
Jeff Johnson295189b2012-06-20 16:38:30 -070014987eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
14988 csrRoamLinkQualityIndCallback callback,
14989 void *pContext)
14990{
14991 pMac->roam.linkQualityIndInfo.callback = callback;
14992 pMac->roam.linkQualityIndInfo.context = pContext;
14993 if( NULL == callback )
14994 {
14995 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
14996 }
14997 else
14998 {
14999 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070015000 /* do we need to invoke the callback to notify client of initial value ?? */
15001 }
15002 return eHAL_STATUS_SUCCESS;
15003}
Jeff Johnson295189b2012-06-20 16:38:30 -070015004void csrRoamVccTrigger(tpAniSirGlobal pMac)
15005{
15006 eCsrRoamLinkQualityInd newVccLinkQuality;
15007 tANI_U32 ul_mac_loss = 0;
15008 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070015009 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
15010 /*-------------------------------------------------------------------------
15011 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070015012 Check for a change in link quality and notify client if necessary
15013 -------------------------------------------------------------------------*/
15014 ul_mac_loss_trigger_threshold =
15015 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070015016 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015017 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015018 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070015019 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
15020 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015021 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070015022 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
15023 }
15024 else
15025 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015026 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070015027 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
15028 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015029 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
15030 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070015031 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
15032 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015033 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070015034 if(NULL != pMac->roam.linkQualityIndInfo.callback)
15035 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015036 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015037 newVccLinkQuality );
15038
15039 /* we now invoke the callback once to notify client of initial value */
15040 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
15041 pMac->roam.linkQualityIndInfo.context );
15042 //event: EVENT_WLAN_VCC
15043 }
15044 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015045 pMac->roam.vccLinkQuality = newVccLinkQuality;
15046
Jeff Johnson295189b2012-06-20 16:38:30 -070015047}
Jeff Johnson295189b2012-06-20 16:38:30 -070015048VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
15049 v_U8_t rssiNotification,
15050 void * context)
15051{
15052 tpAniSirGlobal pMac = PMAC_STRUCT( context );
15053 eCsrRoamLinkQualityInd newVccLinkQuality;
15054 // TODO : Session info unavailable
15055 tANI_U32 sessionId = 0;
15056 VOS_STATUS status = VOS_STATUS_SUCCESS;
15057 /*-------------------------------------------------------------------------
15058 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070015059 Check for a change in link quality and notify client if necessary
15060 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015061 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015062 pMac->roam.configParam.vccRssiThreshold);
15063 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
15064 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015065 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070015066 return VOS_STATUS_SUCCESS;
15067 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015068 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
15069 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015070 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070015071 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
15072 }
15073 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
15074 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015075 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070015076 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
15077 }
15078 else
15079 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015080 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070015081 //Set to this so the code below won't do anything
15082 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070015083 VOS_ASSERT(0);
15084 }
15085
Jeff Johnson295189b2012-06-20 16:38:30 -070015086 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
15087 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015088 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070015089 if(NULL != pMac->roam.linkQualityIndInfo.callback)
15090 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015091 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015092 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070015093 /* we now invoke the callback once to notify client of initial value */
15094 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
15095 pMac->roam.linkQualityIndInfo.context );
15096 //event: EVENT_WLAN_VCC
15097 }
15098 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015099 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070015100 return status;
15101}
Jeff Johnson295189b2012-06-20 16:38:30 -070015102tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
15103 tDblLinkList *pStaList,
15104 tCsrStatsClientReqInfo *pStaEntry)
15105{
15106 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015107 //if same entity requested for same set of stats with different periodicity &
15108 // callback update it
15109 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
15110 {
15111
Kiet Lam64c1b492013-07-12 13:56:44 +053015112 pNewStaEntry = vos_mem_malloc(sizeof(tCsrStatsClientReqInfo));
15113 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015114 {
15115 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015116 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070015117 return NULL;
15118 }
15119
Jeff Johnson295189b2012-06-20 16:38:30 -070015120 pNewStaEntry->callback = pStaEntry->callback;
15121 pNewStaEntry->pContext = pStaEntry->pContext;
15122 pNewStaEntry->periodicity = pStaEntry->periodicity;
15123 pNewStaEntry->requesterId = pStaEntry->requesterId;
15124 pNewStaEntry->statsMask = pStaEntry->statsMask;
15125 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
15126 pNewStaEntry->pMac = pStaEntry->pMac;
15127 pNewStaEntry->staId = pStaEntry->staId;
15128 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
15129
15130 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
15131 }
15132 return pNewStaEntry;
15133}
15134
Jeff Johnson295189b2012-06-20 16:38:30 -070015135tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
15136 tDblLinkList *pStaList,
15137 tCsrPeStatsReqInfo *pStaEntry)
15138{
15139 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053015140 pNewStaEntry = vos_mem_malloc(sizeof(tCsrPeStatsReqInfo));
15141 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015142 {
15143 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015144 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070015145 return NULL;
15146 }
15147
Jeff Johnson295189b2012-06-20 16:38:30 -070015148 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
15149 pNewStaEntry->numClient = pStaEntry->numClient;
15150 pNewStaEntry->periodicity = pStaEntry->periodicity;
15151 pNewStaEntry->statsMask = pStaEntry->statsMask;
15152 pNewStaEntry->pMac = pStaEntry->pMac;
15153 pNewStaEntry->staId = pStaEntry->staId;
15154 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
15155 pNewStaEntry->rspPending = pStaEntry->rspPending;
15156
15157 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015158 return pNewStaEntry;
15159}
Jeff Johnson295189b2012-06-20 16:38:30 -070015160eHalStatus csrGetRssi(tpAniSirGlobal pMac,
15161 tCsrRssiCallback callback,
15162 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
15163{
15164 eHalStatus status = eHAL_STATUS_SUCCESS;
15165 vos_msg_t msg;
15166 tANI_U32 sessionId;
15167
15168 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015169 smsLog(pMac, LOG2, FL("called"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015170 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
15171 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070015172 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015173 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053015174 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015175 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015176 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
15177
15178 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
15179 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
15180 pMsg->sessionId = sessionId;
15181 pMsg->staId = staId;
15182 pMsg->rssiCallback = callback;
15183 pMsg->pDevContext = pContext;
15184 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070015185 msg.type = eWNI_SME_GET_RSSI_REQ;
15186 msg.bodyptr = pMsg;
15187 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015188 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
15189 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015190 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053015191 vos_mem_free((void *)pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015192 status = eHAL_STATUS_FAILURE;
15193 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015194 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015195 return status;
15196}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015197
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015198eHalStatus csrGetSnr(tpAniSirGlobal pMac,
15199 tCsrSnrCallback callback,
15200 tANI_U8 staId, tCsrBssid bssId,
15201 void *pContext)
15202{
15203 eHalStatus status = eHAL_STATUS_SUCCESS;
15204 vos_msg_t msg;
15205 tANI_U32 sessionId;
15206
15207 tAniGetSnrReq *pMsg;
15208
15209 smsLog(pMac, LOG2, FL("called"));
15210
15211 pMsg =(tAniGetSnrReq *)vos_mem_malloc(sizeof(tAniGetSnrReq));
15212 if (NULL == pMsg )
15213 {
15214 smsLog(pMac, LOGE, "%s: failed to allocate mem for req",__func__);
15215 return status;
15216 }
15217
15218 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
15219
15220 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_SNR_REQ);
15221 pMsg->msgLen = (tANI_U16)sizeof(tAniGetSnrReq);
15222 pMsg->sessionId = sessionId;
15223 pMsg->staId = staId;
15224 pMsg->snrCallback = callback;
15225 pMsg->pDevContext = pContext;
15226 msg.type = eWNI_SME_GET_SNR_REQ;
15227 msg.bodyptr = pMsg;
15228 msg.reserved = 0;
15229
15230 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
15231 {
15232 smsLog(pMac, LOGE, "%s failed to post msg to self", __func__);
15233 vos_mem_free((v_VOID_t *)pMsg);
15234 status = eHAL_STATUS_FAILURE;
15235 }
15236
15237 smsLog(pMac, LOG2, FL("returned"));
15238 return status;
15239}
15240
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015241#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015242eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
15243 tCsrRssiCallback callback,
15244 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
15245{
15246 eHalStatus status = eHAL_STATUS_SUCCESS;
15247 tAniGetRssiReq *pMsg;
15248
Kiet Lam64c1b492013-07-12 13:56:44 +053015249 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
15250 if ( NULL == pMsg )
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015251 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015252 smsLog(pMac, LOGE, FL("Failed to allocate mem for req"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015253 return eHAL_STATUS_FAILURE;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015254 }
15255 // need to initiate a stats request to PE
15256 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
15257 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
15258 pMsg->staId = staId;
15259 pMsg->rssiCallback = callback;
15260 pMsg->pDevContext = pContext;
15261 pMsg->pVosContext = pVosContext;
15262 status = palSendMBMessage(pMac->hHdd, pMsg );
15263 if(!HAL_STATUS_SUCCESS(status))
15264 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015265 smsLog(pMac, LOGE, FL(" Failed to send down get rssi req"));
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070015266 //pMsg is freed by palSendMBMessage
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015267 status = eHAL_STATUS_FAILURE;
15268 }
15269 return status;
15270}
15271#endif
15272
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015273
15274
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015275#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015276eHalStatus csrGetTsmStats(tpAniSirGlobal pMac,
15277 tCsrTsmStatsCallback callback,
15278 tANI_U8 staId,
15279 tCsrBssid bssId,
15280 void *pContext,
15281 void* pVosContext,
15282 tANI_U8 tid)
15283{
15284 eHalStatus status = eHAL_STATUS_SUCCESS;
15285 tAniGetTsmStatsReq *pMsg = NULL;
15286
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015287 pMsg = (tAniGetTsmStatsReq*)vos_mem_malloc(sizeof(tAniGetTsmStatsReq));
15288 if (NULL == pMsg)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015289 {
15290 smsLog(pMac, LOGE, "csrGetTsmStats: failed to allocate mem for req");
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015291 return eHAL_STATUS_FAILED_ALLOC;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015292 }
15293 // need to initiate a stats request to PE
15294 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_TSM_STATS_REQ);
15295 pMsg->msgLen = (tANI_U16)sizeof(tAniGetTsmStatsReq);
15296 pMsg->staId = staId;
15297 pMsg->tid = tid;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015298 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015299 pMsg->tsmStatsCallback = callback;
15300 pMsg->pDevContext = pContext;
15301 pMsg->pVosContext = pVosContext;
15302 status = palSendMBMessage(pMac->hHdd, pMsg );
15303 if(!HAL_STATUS_SUCCESS(status))
15304 {
15305 smsLog(pMac, LOG1, " csrGetTsmStats: failed to send down the rssi req");
15306 //pMsg is freed by palSendMBMessage
15307 status = eHAL_STATUS_FAILURE;
15308 }
15309 return status;
15310}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015311#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015312
15313
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053015314/* ---------------------------------------------------------------------------
15315 \fn csrGetTLSTAState
15316 \helper function to get teh TL STA State whenever the function is called.
15317
15318 \param staId - The staID to be passed to the TL
15319 to get the relevant TL STA State
15320 \return the state as tANI_U16
15321 ---------------------------------------------------------------------------*/
15322tANI_U16 csrGetTLSTAState(tpAniSirGlobal pMac, tANI_U8 staId)
15323{
15324 WLANTL_STAStateType tlSTAState;
15325 tlSTAState = WLANTL_STA_INIT;
15326
15327 //request TL for STA State
15328 if ( !VOS_IS_STATUS_SUCCESS(WLANTL_GetSTAState(pMac->roam.gVosContext, staId, &tlSTAState)) )
15329 {
15330 smsLog(pMac, LOGE, FL("csrGetTLSTAState:couldn't get the STA state from TL"));
15331 }
15332
15333 return tlSTAState;
15334}
15335
Jeff Johnson295189b2012-06-20 16:38:30 -070015336eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
15337 tANI_U32 statsMask,
15338 tCsrStatsCallback callback,
15339 tANI_U32 periodicity, tANI_BOOLEAN cache,
15340 tANI_U8 staId, void *pContext)
15341{
15342 tCsrStatsClientReqInfo staEntry;
15343 tCsrStatsClientReqInfo *pStaEntry = NULL;
15344 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
15345 tListElem *pEntry = NULL;
15346 tANI_BOOLEAN found = FALSE;
15347 eHalStatus status = eHAL_STATUS_SUCCESS;
15348 tANI_BOOLEAN insertInClientList = FALSE;
15349 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070015350 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070015351
15352 if( csrIsAllSessionDisconnected(pMac) )
15353 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015354 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070015355 return eHAL_STATUS_FAILURE;
15356 }
Hanumantha Reddy Pothula449aadf2014-02-07 13:53:35 +053015357
15358 if (csrNeighborMiddleOfRoaming((tHalHandle)pMac))
15359 {
15360 smsLog(pMac, LOG1, FL("in the middle of roaming states"));
15361 return eHAL_STATUS_FAILURE;
15362 }
15363
Jeff Johnson295189b2012-06-20 16:38:30 -070015364 if((!statsMask) && (!callback))
15365 {
15366 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015367 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070015368 return eHAL_STATUS_FAILURE;
15369 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015370 //for the search list method for deregister
15371 staEntry.requesterId = requesterId;
15372 staEntry.statsMask = statsMask;
15373 //requester wants to deregister or just an error
15374 if((statsMask) && (!callback))
15375 {
15376 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
15377 if(!pEntry)
15378 {
15379 //msg
15380 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015381 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015382 return eHAL_STATUS_FAILURE;
15383 }
15384 else
15385 {
15386 //clean up & return
15387 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070015388 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015389 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015390 pStaEntry->pPeStaEntry->numClient--;
15391 //check if we need to delete the entry from peStatsReqList too
15392 if(!pStaEntry->pPeStaEntry->numClient)
15393 {
15394 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
15395 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015396 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070015397
Jeff Johnson295189b2012-06-20 16:38:30 -070015398 //check if we need to stop the tl stats timer too
15399 pMac->roam.tlStatsReqInfo.numClient--;
15400 if(!pMac->roam.tlStatsReqInfo.numClient)
15401 {
15402 if(pMac->roam.tlStatsReqInfo.timerRunning)
15403 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015404 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
15405 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015406 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015407 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015408 return eHAL_STATUS_FAILURE;
15409 }
15410 }
15411 pMac->roam.tlStatsReqInfo.periodicity = 0;
15412 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
15413 }
15414 vos_timer_stop( &pStaEntry->timer );
Jeff Johnson295189b2012-06-20 16:38:30 -070015415 // Destroy the vos timer...
15416 vosStatus = vos_timer_destroy( &pStaEntry->timer );
15417 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15418 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015419 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to destroy Client req timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015420 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015421 csrRoamRemoveStatListEntry(pMac, pEntry);
15422 pStaEntry = NULL;
15423 return eHAL_STATUS_SUCCESS;
15424 }
15425 }
15426
15427 if(cache && !periodicity)
15428 {
15429 //return the cached stats
15430 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15431 }
15432 else
15433 {
15434 //add the request in the client req list
15435 staEntry.callback = callback;
15436 staEntry.pContext = pContext;
15437 staEntry.periodicity = periodicity;
15438 staEntry.pPeStaEntry = NULL;
15439 staEntry.staId = staId;
15440 staEntry.pMac = pMac;
15441 staEntry.timerExpired = FALSE;
15442
15443
Jeff Johnson295189b2012-06-20 16:38:30 -070015444 //if periodic report requested with non cached result from PE/TL
15445 if(periodicity)
15446 {
15447
15448 //if looking for stats from PE
15449 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15450 {
15451
15452 //check if same request made already & waiting for rsp
15453 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
15454 periodicity, &found, staId);
15455 if(!pPeStaEntry)
15456 {
15457 //bail out, maxed out on number of req for PE
15458 return eHAL_STATUS_FAILURE;
15459 }
15460 else
15461 {
15462 staEntry.pPeStaEntry = pPeStaEntry;
15463 }
15464
15465 }
15466 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
15467 if(statsMask & (1 << eCsrGlobalClassDStats))
15468 {
15469 if(cache && pMac->roam.tlStatsReqInfo.numClient)
15470 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015471 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015472 }
15473 else
15474 {
15475
15476 //update periodicity
15477 if(pMac->roam.tlStatsReqInfo.periodicity)
15478 {
15479 pMac->roam.tlStatsReqInfo.periodicity =
15480 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
15481 }
15482 else
15483 {
15484 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
15485 }
15486 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
15487 {
15488 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
15489 }
15490
15491 if(!pMac->roam.tlStatsReqInfo.timerRunning)
15492 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015493 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015494 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015495 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015496 //req TL for class D stats
15497 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
15498 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015499 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015500 }
15501 else
15502 {
15503 //save in SME
15504 csrRoamSaveStatsFromTl(pMac, pTlStats);
15505 }
15506 vos_mem_free(pTlStats);
15507 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015508 }
15509 else
15510 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015511 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015512 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015513
Jeff Johnson295189b2012-06-20 16:38:30 -070015514 if(pMac->roam.tlStatsReqInfo.periodicity)
15515 {
15516 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015517 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
15518 pMac->roam.tlStatsReqInfo.periodicity);
15519 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015520 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015521 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015522 return eHAL_STATUS_FAILURE;
15523 }
15524 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
15525 }
15526 }
15527 }
15528 pMac->roam.tlStatsReqInfo.numClient++;
15529 }
15530
15531 insertInClientList = TRUE;
15532 }
15533 //if one time report requested with non cached result from PE/TL
15534 else if(!cache && !periodicity)
15535 {
15536 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15537 {
15538 //send down a req
15539 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
15540 if(!HAL_STATUS_SUCCESS(status))
15541 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015542 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015543 }
15544 //so that when the stats rsp comes back from PE we respond to upper layer
15545 //right away
15546 staEntry.timerExpired = TRUE;
15547 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015548 }
15549 if(statsMask & (1 << eCsrGlobalClassDStats))
15550 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015551 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015552 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015553 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015554 //req TL for class D stats
15555 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
15556 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015557 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015558 }
15559 else
15560 {
15561 //save in SME
15562 csrRoamSaveStatsFromTl(pMac, pTlStats);
15563 }
15564 vos_mem_free(pTlStats);
15565 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015566 }
15567 else
15568 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015569 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015570 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015571
15572 }
15573 //if looking for stats from TL only
15574 if(!insertInClientList)
15575 {
15576 //return the stats
15577 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15578 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015579 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015580 if(insertInClientList)
15581 {
15582 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
15583 if(!pStaEntry)
15584 {
15585 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015586 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015587 return eHAL_STATUS_FAILURE;
15588 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015589 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070015590 //Init & start timer if needed
15591 if(periodicity)
15592 {
15593 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
15594 csrRoamStatsClientTimerHandler, pStaEntry );
15595 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15596 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015597 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015598 return eHAL_STATUS_FAILURE;
15599 }
15600 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
15601 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15602 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015603 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015604 return eHAL_STATUS_FAILURE;
15605 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015606 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015607 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015608 }
15609 return eHAL_STATUS_SUCCESS;
15610}
15611
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015612#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
15613
15614static tSirRetStatus
15615csrRoamScanOffloadPopulateMacHeader(tpAniSirGlobal pMac,
15616 tANI_U8* pBD,
15617 tANI_U8 type,
15618 tANI_U8 subType,
15619 tSirMacAddr peerAddr,
15620 tSirMacAddr selfMacAddr)
15621{
15622 tSirRetStatus statusCode = eSIR_SUCCESS;
15623 tpSirMacMgmtHdr pMacHdr;
15624
15625 /* Prepare MAC management header */
15626 pMacHdr = (tpSirMacMgmtHdr) (pBD);
15627
15628 /* Prepare FC */
15629 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
15630 pMacHdr->fc.type = type;
15631 pMacHdr->fc.subType = subType;
15632
15633 /* Prepare Address 1 */
Kiet Lam64c1b492013-07-12 13:56:44 +053015634 vos_mem_copy((tANI_U8 *) pMacHdr->da, (tANI_U8 *) peerAddr,
15635 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015636
15637 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
15638
15639 /* Prepare Address 3 */
Kiet Lam64c1b492013-07-12 13:56:44 +053015640 vos_mem_copy((tANI_U8 *) pMacHdr->bssId, (tANI_U8 *) peerAddr,
15641 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015642 return statusCode;
15643} /*** csrRoamScanOffloadPopulateMacHeader() ***/
15644
15645static tSirRetStatus
15646csrRoamScanOffloadPrepareProbeReqTemplate(tpAniSirGlobal pMac,
15647 tANI_U8 nChannelNum,
15648 tANI_U32 dot11mode,
15649 tSirMacAddr selfMacAddr,
15650 tANI_U8 *pFrame,
15651 tANI_U16 *pusLen)
15652{
15653 tDot11fProbeRequest pr;
15654 tANI_U32 nStatus, nBytes, nPayload;
15655 tSirRetStatus nSirStatus;
15656 /*Bcast tx*/
15657 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
15658 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
15659
15660
Kiet Lam64c1b492013-07-12 13:56:44 +053015661 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015662
15663 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
15664
15665 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
15666 {
15667 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
15668 }
15669
15670
15671 if (IS_DOT11_MODE_HT(dot11mode))
15672 {
15673 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
15674 }
15675
15676
15677 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
15678 if ( DOT11F_FAILED( nStatus ) )
15679 {
15680 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15681 "Failed to calculate the packed size f"
15682 "or a Probe Request (0x%08x).\n", nStatus );
15683
15684
15685 nPayload = sizeof( tDot11fProbeRequest );
15686 }
15687 else if ( DOT11F_WARNED( nStatus ) )
15688 {
15689 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15690 "There were warnings while calculating"
15691 "the packed size for a Probe Request ("
15692 "0x%08x).\n", nStatus );
15693 }
15694
15695 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
15696
15697 /* Prepare outgoing frame*/
Kiet Lam64c1b492013-07-12 13:56:44 +053015698 vos_mem_set(pFrame, nBytes , 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015699
15700
15701 nSirStatus = csrRoamScanOffloadPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015702 SIR_MAC_MGMT_PROBE_REQ, bssId,selfMacAddr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015703
15704 if ( eSIR_SUCCESS != nSirStatus )
15705 {
15706 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15707 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
15708 nSirStatus );
15709 return nSirStatus;
15710 }
15711
15712
15713 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
15714 sizeof( tSirMacMgmtHdr ),
15715 nPayload, &nPayload );
15716 if ( DOT11F_FAILED( nStatus ) )
15717 {
15718 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15719 "Failed to pack a Probe Request (0x%08x).\n", nStatus );
15720 return eSIR_FAILURE;
15721 }
15722 else if ( DOT11F_WARNED( nStatus ) )
15723 {
15724 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce8ad512013-10-30 12:34:42 -070015725 "There were warnings while packing a Probe Request (0x%08x).\n",
15726 nStatus );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015727 }
15728
15729 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
15730 return eSIR_SUCCESS;
15731}
15732
15733eHalStatus csrRoamOffloadScan(tpAniSirGlobal pMac, tANI_U8 command, tANI_U8 reason)
15734{
15735 vos_msg_t msg;
15736 tSirRoamOffloadScanReq *pRequestBuf;
15737 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
15738 tCsrRoamSession *pSession;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015739 tANI_U8 i,j,num_channels = 0, ucDot11Mode;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015740 tANI_U8 *ChannelList = NULL;
15741 tANI_U32 sessionId;
15742 eHalStatus status = eHAL_STATUS_SUCCESS;
15743 tpCsrChannelInfo currChannelListInfo;
Srinivas Girigowda56076852013-08-20 14:00:50 -070015744 tANI_U32 host_channels = 0;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015745 tANI_U8 ChannelCacheStr[128] = {0};
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015746 eCsrBand eBand;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015747 tSirBssDescription *pBssDesc = NULL;
15748 tDot11fBeaconIEs *pIes = NULL;
15749 tANI_U8 minRate = 0, dataRate;
Varun Reddy Yeturu52231ea2014-02-06 12:00:56 -080015750 tANI_U8 operationChannel = 0;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015751
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015752 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
15753
Srinivas Girigowda830bbd02013-06-13 19:44:16 -070015754 if (0 == csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015755 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015756 smsLog( pMac, LOGE,"isRoamOffloadScanEnabled not set");
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015757 return eHAL_STATUS_FAILURE;
15758 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015759
15760 if ((VOS_TRUE == bRoamScanOffloadStarted) && (ROAM_SCAN_OFFLOAD_START == command))
15761 {
15762 smsLog( pMac, LOGE,"Roam Scan Offload is already started");
15763 return eHAL_STATUS_FAILURE;
15764 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015765 status = csrRoamGetSessionIdFromBSSID(pMac,
15766 (tCsrBssid *)pNeighborRoamInfo->currAPbssid,
15767 &sessionId);
15768 /*The Dynamic Config Items Update may happen even if the state is in INIT.
15769 * It is important to ensure that the command is passed down to the FW only
15770 * if the Infra Station is in a connected state.A connected station could also be
15771 * in a PREAUTH or REASSOC states.So, consider not sending the command down in INIT state.
15772 * We also have to ensure that if there is a STOP command we always have to inform Riva,
15773 * irrespective of whichever state we are in.*/
15774 if ((pMac->roam.neighborRoamInfo.neighborRoamState == eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
15775 (command != ROAM_SCAN_OFFLOAD_STOP))
15776 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053015777 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
15778 FL("Scan Command not sent to FW with state = %s and cmd=%d\n"),
15779 macTraceGetNeighbourRoamState(
15780 pMac->roam.neighborRoamInfo.neighborRoamState), command);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015781 return eHAL_STATUS_FAILURE;
15782 }
15783
15784 if ( !HAL_STATUS_SUCCESS( status ) )
15785 {
15786 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to find the sessionId for Roam Offload scan request", __func__);
15787 return eHAL_STATUS_FAILURE;
15788 }
15789 pSession = CSR_GET_SESSION( pMac, sessionId );
krunal soni587bf012014-02-04 12:35:11 -080015790 if (NULL == pSession)
15791 {
15792 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15793 "%s:pSession is null", __func__);
15794 return eHAL_STATUS_FAILURE;
15795 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015796 pBssDesc = pSession->pConnectBssDesc;
15797 if (pBssDesc == NULL)
15798 {
15799 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: pBssDesc not found for current session", __func__);
15800 return eHAL_STATUS_FAILURE;
15801 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015802 pRequestBuf = vos_mem_malloc(sizeof(tSirRoamOffloadScanReq));
15803 if (NULL == pRequestBuf)
15804 {
15805 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to allocate memory for Roam Offload scan request", __func__);
15806 return eHAL_STATUS_FAILED_ALLOC;
15807 }
15808
Kiet Lam64c1b492013-07-12 13:56:44 +053015809 vos_mem_zero(pRequestBuf, sizeof(tSirRoamOffloadScanReq));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015810 /* If command is STOP, then pass down ScanOffloadEnabled as Zero.This will handle the case of
15811 * host driver reloads, but Riva still up and running*/
Mukul Sharma90506b42014-04-24 13:24:12 +053015812 pRequestBuf->Command = command;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015813 if(command == ROAM_SCAN_OFFLOAD_STOP)
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015814 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015815 pRequestBuf->RoamScanOffloadEnabled = 0;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015816 /*For a STOP Command, there is no need to
15817 * go through filling up all the below parameters
15818 * since they are not required for the STOP command*/
15819 goto send_roam_scan_offload_cmd;
15820 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015821 else
15822 pRequestBuf->RoamScanOffloadEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
Kiet Lam64c1b492013-07-12 13:56:44 +053015823 vos_mem_copy(pRequestBuf->ConnectedNetwork.currAPbssid,
15824 pNeighborRoamInfo->currAPbssid,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015825 sizeof(tCsrBssid));
15826 pRequestBuf->ConnectedNetwork.ssId.length =
15827 pMac->roam.roamSession[sessionId].connectedProfile.SSID.length;
15828 vos_mem_copy(pRequestBuf->ConnectedNetwork.ssId.ssId,
15829 pMac->roam.roamSession[sessionId].connectedProfile.SSID.ssId,
15830 pRequestBuf->ConnectedNetwork.ssId.length);
15831 pRequestBuf->ConnectedNetwork.authentication =
15832 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
15833 pRequestBuf->ConnectedNetwork.encryption =
15834 pMac->roam.roamSession[sessionId].connectedProfile.EncryptionType;
15835 pRequestBuf->ConnectedNetwork.mcencryption =
15836 pMac->roam.roamSession[sessionId].connectedProfile.mcEncryptionType;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015837 if (pNeighborRoamInfo->cfgParams.neighborLookupThreshold)
15838 {
15839 pRequestBuf->LookupThreshold =
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015840 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborLookupThreshold * (-1);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015841 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
15842 }
15843 else
15844 {
15845 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Calculate Adaptive Threshold");
15846 operationChannel = pSession->connectedProfile.operationChannel;
15847
15848 if (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
15849 {
15850 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15851 "%s: csrGetParsedBssDescriptionIEs failed", __func__);
15852 vos_mem_free(pRequestBuf);
15853 return eHAL_STATUS_FAILURE;
15854 }
Kaushik, Sushant5874d032014-02-20 17:22:36 +053015855 if(NULL == pIes)
15856 {
15857 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15858 "%s : pIes is Null", __func__);
15859 return eHAL_STATUS_FAILURE;
15860 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015861 if (pIes->SuppRates.present)
15862 {
15863 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Number \t Rate");
15864 /*Check for both basic rates and extended rates.*/
15865 for (i = 0; i < pIes->SuppRates.num_rates; i++)
15866 {
15867 /*Check if the Rate is Mandatory or Not*/
15868 if (csrRatesIsDot11RateSupported(pMac, pIes->SuppRates.rates[i])
15869 && (pIes->SuppRates.rates[i] & 0x80))
15870 {
15871 /*Retrieve the actual data rate*/
15872 dataRate = (pIes->SuppRates.rates[i] & 0x7F)/2;
15873 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
15874 if (minRate == 0)
15875 minRate = dataRate;
15876 else
15877 minRate = (minRate < dataRate) ? minRate:dataRate;
15878 }
15879 }
15880
15881 if (pIes->ExtSuppRates.present)
15882 {
15883 for (i = 0; i < pIes->ExtSuppRates.num_rates; i++)
15884 {
15885 /*Check if the Rate is Mandatory or Not*/
15886 if (csrRatesIsDot11RateSupported(pMac, pIes->ExtSuppRates.rates[i])
15887 && (pIes->ExtSuppRates.rates[i] & 0x80))
15888 {
15889 /*Retrieve the actual data rate*/
15890 dataRate = (pIes->ExtSuppRates.rates[i] & 0x7F)/2;
15891 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
15892 if (minRate == 0)
15893 minRate = dataRate;
15894 else
15895 minRate = (minRate < dataRate) ? minRate:dataRate;
15896 }
15897 }
15898 }
15899 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "MinRate = %d", minRate);
15900 }
15901 else
15902 {
15903 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15904 "%s: Supp Rates not present in pIes", __func__);
15905 vos_mem_free(pRequestBuf);
15906 return eHAL_STATUS_FAILURE;
15907 }
15908 if (NULL != pIes)
15909 {
15910 vos_mem_free(pIes);
15911 pIes = NULL;
15912 }
15913 switch (minRate)
15914 {
15915 case 1:
15916 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_1MBPS;
15917 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_1MBPS;
15918 break;
15919 case 2:
15920 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_2MBPS;
15921 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_2MBPS;
15922 break;
15923 case 5:
15924 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_5_5MBPS;
15925 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_5_5MBPS;
15926 break;
15927 case 6:
15928 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
15929 {
15930 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_2G;
15931 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_2G;
15932 }
15933 else
15934 {
15935 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_5G;
15936 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_5G;
15937 }
15938 break;
15939 case 11:
15940 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_11MBPS;
15941 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_11MBPS;
15942 break;
15943 case 12:
15944 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
15945 {
15946 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_2G;
15947 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_2G;
15948 }
15949 else
15950 {
15951 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_5G;
15952 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_5G;
15953 }
15954 break;
15955 case 24:
15956 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
15957 {
15958 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_2G;
15959 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_2G;
15960 }
15961 else
15962 {
15963 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_5G;
15964 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_5G;
15965 }
15966 break;
15967 default:
15968 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_DEFAULT;
15969 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
15970 break;
15971 }
15972 }
15973 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
15974 "Chnl=%d,MinRate=%d,RxSenThr=%d,LookupThr=%d",
15975 operationChannel, minRate,
15976 pRequestBuf->RxSensitivityThreshold,
15977 pRequestBuf->LookupThreshold);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015978 pRequestBuf->RoamRssiDiff =
15979 pMac->roam.configParam.RoamRssiDiff;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015980 pRequestBuf->StartScanReason = reason;
15981 pRequestBuf->NeighborScanTimerPeriod =
15982 pNeighborRoamInfo->cfgParams.neighborScanPeriod;
15983 pRequestBuf->NeighborRoamScanRefreshPeriod =
15984 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod;
15985 pRequestBuf->NeighborScanChannelMinTime =
15986 pNeighborRoamInfo->cfgParams.minChannelScanTime;
15987 pRequestBuf->NeighborScanChannelMaxTime =
15988 pNeighborRoamInfo->cfgParams.maxChannelScanTime;
15989 pRequestBuf->EmptyRefreshScanPeriod =
15990 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -080015991 /* MAWC feature */
15992 pRequestBuf->MAWCEnabled =
15993 pMac->roam.configParam.MAWCEnabled;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015994#ifdef FEATURE_WLAN_ESE
15995 pRequestBuf->IsESEEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015996#endif
15997 if (
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015998#ifdef FEATURE_WLAN_ESE
15999 ((pNeighborRoamInfo->isESEAssoc) &&
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016000 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived ==
16001 eANI_BOOLEAN_FALSE)) ||
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016002 (pNeighborRoamInfo->isESEAssoc == eANI_BOOLEAN_FALSE) ||
16003#endif // ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016004 currChannelListInfo->numOfChannels == 0)
16005 {
16006
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016007 /*Retrieve the Channel Cache either from ini or from the Occupied Channels list.
16008 * Give Preference to INI Channels.*/
16009 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
16010 {
16011 ChannelList = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
16012 /*The INI channels need to be filtered with respect to the current
16013 * band that is supported.*/
16014 eBand = pMac->roam.configParam.bandCapability;
16015 if ((eCSR_BAND_24 != eBand) && (eCSR_BAND_5G != eBand) && (eCSR_BAND_ALL != eBand))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016016 {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016017 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16018 "Invalid band, No operation carried out (Band %d)", eBand);
16019 vos_mem_free(pRequestBuf);
16020 return eHAL_STATUS_FAILURE;
16021 }
16022 for (i=0; i<pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels; i++)
16023 {
16024 if(((eCSR_BAND_24 == eBand) && CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
16025 ((eCSR_BAND_5G == eBand) && CSR_IS_CHANNEL_5GHZ(*ChannelList)) ||
16026 (eCSR_BAND_ALL == eBand))
16027 {
16028 if(!CSR_IS_CHANNEL_DFS(*ChannelList) &&
16029 csrRoamIsChannelValid(pMac, *ChannelList) &&
16030 *ChannelList && (num_channels < SIR_ROAM_MAX_CHANNELS))
16031 {
16032 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
16033 }
16034 }
16035 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016036 }
16037 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16038 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016039 }
16040 else
16041 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016042 ChannelList = pMac->scan.occupiedChannels.channelList;
16043 for(i=0; i<pMac->scan.occupiedChannels.numChannels; i++)
16044 {
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053016045 /*Allow DFS channels only if the DFS channel roam flag is enabled */
16046 if(((pMac->roam.configParam.allowDFSChannelRoam) ||
16047 (!CSR_IS_CHANNEL_DFS(*ChannelList))) &&
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016048 *ChannelList && (num_channels < SIR_ROAM_MAX_CHANNELS))
16049 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016050 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016051 }
16052 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016053 }
16054 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16055 /* If the profile changes as to what it was earlier, inform the FW through
16056 * FLUSH as ChannelCacheType in which case, the FW will flush the occupied channels
16057 * for the earlier profile and try to learn them afresh.*/
16058 if (reason == REASON_FLUSH_CHANNEL_LIST)
16059 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
16060 else {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016061 if (csrNeighborRoamIsNewConnectedProfile(pMac))
16062 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
16063 else
16064 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016065 }
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016066 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016067 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016068#ifdef FEATURE_WLAN_ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016069 else
16070 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016071 /* If ESE is enabled, and a neighbor Report is received,then
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016072 * Ignore the INI Channels or the Occupied Channel List. Consider
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016073 * the channels in the neighbor list sent by the ESE AP.*/
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016074 if (currChannelListInfo->numOfChannels != 0)
16075 {
16076 ChannelList = currChannelListInfo->ChannelList;
16077 for (i=0;i<currChannelListInfo->numOfChannels;i++)
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016078 {
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053016079 if(((pMac->roam.configParam.allowDFSChannelRoam) ||
16080 (!CSR_IS_CHANNEL_DFS(*ChannelList))) && *ChannelList)
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016081 {
16082 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
16083 }
16084 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016085 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016086 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16087 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
16088 }
16089 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016090#endif
Kaushik, Sushant5ed8ab62014-03-05 11:21:11 +053016091 for (i = 0, j = 0;j < (sizeof(ChannelCacheStr)/sizeof(ChannelCacheStr[0])) && i < pRequestBuf->ConnectedNetwork.ChannelCount; i++)
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016092 {
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053016093 if (j < sizeof(ChannelCacheStr))
16094 {
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016095 j += snprintf(ChannelCacheStr + j, sizeof(ChannelCacheStr) - j," %d",
16096 pRequestBuf->ConnectedNetwork.ChannelCache[i]);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053016097 }
16098 else
16099 {
16100 break;
16101 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016102 }
16103 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
16104 "ChnlCacheType:%d, No of Chnls:%d,Channels: %s",
16105 pRequestBuf->ChannelCacheType,
16106 pRequestBuf->ConnectedNetwork.ChannelCount,
16107 ChannelCacheStr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016108 num_channels = 0;
16109 ChannelList = NULL;
16110
16111 /* Maintain the Valid Channels List*/
Srinivas Girigowda56076852013-08-20 14:00:50 -070016112 host_channels = sizeof(pMac->roam.validChannelList);
16113 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &host_channels)))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016114 {
Srinivas Girigowda56076852013-08-20 14:00:50 -070016115 ChannelList = pMac->roam.validChannelList;
16116 pMac->roam.numValidChannels = host_channels;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016117 }
Srinivas Girigowda56076852013-08-20 14:00:50 -070016118 else
16119 {
16120 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16121 "%s:Failed to get the valid channel list", __func__);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -070016122 vos_mem_free(pRequestBuf);
Srinivas Girigowda56076852013-08-20 14:00:50 -070016123 return eHAL_STATUS_FAILURE;
16124 }
16125 for(i=0; i<pMac->roam.numValidChannels; i++)
16126 {
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053016127 if(((pMac->roam.configParam.allowDFSChannelRoam) ||
16128 (!CSR_IS_CHANNEL_DFS(*ChannelList))) && *ChannelList)
Srinivas Girigowda56076852013-08-20 14:00:50 -070016129 {
16130 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
16131 }
16132 ChannelList++;
16133 }
16134 pRequestBuf->ValidChannelCount = num_channels;
16135
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016136 pRequestBuf->MDID.mdiePresent =
16137 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent;
16138 pRequestBuf->MDID.mobilityDomain =
16139 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mobilityDomain;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016140 pRequestBuf->nProbes = pMac->roam.configParam.nProbes;
16141
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016142 pRequestBuf->HomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016143 /* Home Away Time should be at least equal to (MaxDwell time + (2*RFS)),
16144 * where RFS is the RF Switching time. It is twice RFS to consider the
16145 * time to go off channel and return to the home channel. */
16146 if (pRequestBuf->HomeAwayTime < (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)))
16147 {
16148 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
16149 "%s: Invalid config, Home away time(%d) is less than (twice RF switching time + channel max time)(%d)"
16150 " Hence enforcing home away time to disable (0)",
16151 __func__, pRequestBuf->HomeAwayTime,
16152 (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)));
16153 pRequestBuf->HomeAwayTime = 0;
16154 }
16155 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,"HomeAwayTime:%d",pRequestBuf->HomeAwayTime);
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070016156
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016157 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
16158 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
16159 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
16160 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_24G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
16161 pRequestBuf->p24GProbeTemplate, &pRequestBuf->us24GProbeTemplateLen);
16162
16163 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_5G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
16164 pRequestBuf->p5GProbeTemplate, &pRequestBuf->us5GProbeTemplateLen);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016165send_roam_scan_offload_cmd:
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016166 msg.type = WDA_ROAM_SCAN_OFFLOAD_REQ;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016167 msg.reserved = 0;
16168 msg.bodyptr = pRequestBuf;
16169 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
16170 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016171 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_ROAM_SCAN_OFFLOAD_REQ message to WDA", __func__);
16172 vos_mem_free(pRequestBuf);
16173 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016174 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016175 else
16176 {
16177 if (ROAM_SCAN_OFFLOAD_START == command)
16178 bRoamScanOffloadStarted = VOS_TRUE;
16179 else if (ROAM_SCAN_OFFLOAD_STOP == command)
16180 bRoamScanOffloadStarted = VOS_FALSE;
16181 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016182
16183 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Roam Scan Offload Command %d, Reason %d", command, reason);
16184 return status;
16185}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016186
16187eHalStatus csrRoamOffloadScanRspHdlr(tpAniSirGlobal pMac, tANI_U8 reason)
16188{
16189 switch(reason)
16190 {
16191 case 0:
16192 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with failure status");
16193 break;
16194 case REASON_OS_REQUESTED_ROAMING_NOW:
16195 csrNeighborRoamProceedWithHandoffReq(pMac);
16196 break;
16197 default:
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -070016198 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 -070016199 }
16200 return eHAL_STATUS_SUCCESS;
16201}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016202#endif
16203
Jeff Johnson295189b2012-06-20 16:38:30 -070016204tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
16205 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
16206{
16207 tANI_BOOLEAN found = FALSE;
16208 eHalStatus status = eHAL_STATUS_SUCCESS;
16209 tCsrPeStatsReqInfo staEntry;
16210 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
16211 tListElem *pStaEntry = NULL;
16212 VOS_STATUS vosStatus;
16213 tPmcPowerState powerState;
16214 *pFound = FALSE;
16215
16216 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
16217 if(pStaEntry)
16218 {
16219 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
16220 if(pTempStaEntry->periodicity)
16221 {
16222 pTempStaEntry->periodicity =
16223 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
16224 }
16225 else
16226 {
16227 pTempStaEntry->periodicity = periodicity;
16228 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016229 pTempStaEntry->numClient++;
16230 found = TRUE;
16231 }
16232 else
16233 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016234 vos_mem_set(&staEntry, sizeof(tCsrPeStatsReqInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016235 staEntry.numClient = 1;
16236 staEntry.periodicity = periodicity;
16237 staEntry.pMac = pMac;
16238 staEntry.rspPending = FALSE;
16239 staEntry.staId = staId;
16240 staEntry.statsMask = statsMask;
16241 staEntry.timerRunning = FALSE;
16242 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
16243 if(!pTempStaEntry)
16244 {
16245 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016246 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070016247 return NULL;
16248 }
16249 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016250 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
16251 if(ePMC_FULL_POWER == powerState)
16252 {
16253 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
16254 {
16255 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
16256 }
16257 }
16258 else
16259 {
16260 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
16261 {
16262 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
16263 }
16264 }
16265 if(!pTempStaEntry->timerRunning)
16266 {
16267 //send down a req in case of one time req, for periodic ones wait for timer to expire
16268 if(!pTempStaEntry->rspPending &&
16269 !pTempStaEntry->periodicity)
16270 {
16271 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
16272 if(!HAL_STATUS_SUCCESS(status))
16273 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016274 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016275 }
16276 else
16277 {
16278 pTempStaEntry->rspPending = TRUE;
16279 }
16280 }
16281 if(pTempStaEntry->periodicity)
16282 {
16283 if(!found)
16284 {
16285
16286 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
16287 csrRoamPeStatsTimerHandler, pTempStaEntry );
16288 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16289 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016290 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016291 return NULL;
16292 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016293 }
16294 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016295 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070016296 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
16297 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16298 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016299 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016300 return NULL;
16301 }
16302 pTempStaEntry->timerRunning = TRUE;
16303 }
16304 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016305 *pFound = found;
16306 return pTempStaEntry;
16307}
16308
Jeff Johnson295189b2012-06-20 16:38:30 -070016309/*
16310 pStaEntry is no longer invalid upon the return of this function.
16311*/
16312static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
16313{
16314 if(pEntry)
16315 {
16316 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
16317 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016318 vos_mem_free(GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070016319 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016320 }
16321 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016322
16323void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
16324{
16325 tListElem *pEntry;
16326 tCsrPeStatsReqInfo *pTempStaEntry;
16327 VOS_STATUS vosStatus;
16328 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016329 if(!pEntry)
16330 {
16331 //list empty
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016332 smsLog(pMac, LOGE, FL(" List empty, no stats req for PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016333 return;
16334 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016335 while( pEntry )
16336 {
16337 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016338 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
16339 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016340 smsLog(pMac, LOGW, FL("Match found"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016341 if(pTempStaEntry->timerRunning)
16342 {
16343 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
16344 /* If we are not able to stop the timer here, just remove
16345 * the entry from the linked list. Destroy the timer object
16346 * and free the memory in the timer CB
16347 */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016348 if ( vosStatus == VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -070016349 {
16350 /* the timer is successfully stopped */
16351 pTempStaEntry->timerRunning = FALSE;
16352
16353 /* Destroy the timer */
16354 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
16355 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16356 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016357 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016358 }
16359 }
16360 else
16361 {
16362 // the timer could not be stopped. Hence destroy and free the
16363 // memory for the PE stat entry in the timer CB.
16364 pTempStaEntry->timerStopFailed = TRUE;
16365 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016366 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016367
16368 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
16369 {
16370 // Only free the memory if we could stop the timer successfully
16371 if(!pTempStaEntry->timerStopFailed)
16372 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016373 vos_mem_free(pTempStaEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070016374 pTempStaEntry = NULL;
16375 }
16376 break;
16377 }
16378
16379 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
16380 }
16381 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016382 return;
16383}
16384
16385
Jeff Johnsone7245742012-09-05 17:12:55 -070016386void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070016387{
16388
Jeff Johnsone7245742012-09-05 17:12:55 -070016389 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
16390 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
16391 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
16392 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
16393 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
16394 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
16395 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070016396 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070016397 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
16398 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
16399 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
16400 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
16401 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
16402 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070016403 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070016404 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
16405 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070016406
16407}
16408
Jeff Johnson295189b2012-06-20 16:38:30 -070016409void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
16410 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
16411{
16412 tANI_U8 stats[500];
16413 tANI_U8 *pStats = NULL;
16414 tANI_U32 tempMask = 0;
16415 tANI_U8 counter = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016416 if(!callback)
16417 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016418 smsLog(pMac, LOGE, FL("Cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016419 return;
16420 }
16421 if(!statsMask)
16422 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016423 smsLog(pMac, LOGE, FL("Cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016424 return;
16425 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016426 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070016427 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070016428 while(tempMask)
16429 {
16430 if(tempMask & 1)
16431 {
16432 //new stats info from PE, fill up the stats strucutres in PMAC
16433 switch(counter)
16434 {
16435 case eCsrSummaryStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016436 smsLog( pMac, LOG2, FL("Summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016437 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
16438 sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016439 pStats += sizeof(tCsrSummaryStatsInfo);
16440 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016441 case eCsrGlobalClassAStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016442 smsLog( pMac, LOG2, FL("ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016443 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
16444 sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016445 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016446 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016447 case eCsrGlobalClassBStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016448 smsLog( pMac, LOG2, FL("ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016449 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
16450 sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016451 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016452 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016453 case eCsrGlobalClassCStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016454 smsLog( pMac, LOG2, FL("ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016455 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
16456 sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016457 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016458 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016459 case eCsrGlobalClassDStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016460 smsLog( pMac, LOG2, FL("ClassD stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016461 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
16462 sizeof(tCsrGlobalClassDStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016463 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016464 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016465 case eCsrPerStaStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016466 smsLog( pMac, LOG2, FL("PerSta stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016467 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
16468 sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016469 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016470 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016471 default:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016472 smsLog( pMac, LOGE, FL("Unknown stats type and counter %d"), counter);
Jeff Johnson295189b2012-06-20 16:38:30 -070016473 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016474 }
16475 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016476 tempMask >>=1;
16477 counter++;
16478 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016479 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070016480}
16481
Jeff Johnson295189b2012-06-20 16:38:30 -070016482eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
16483{
16484 tListElem *pEntry = NULL;
16485 tListElem *pPrevEntry = NULL;
16486 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
16487 eHalStatus status = eHAL_STATUS_SUCCESS;
16488 VOS_STATUS vosStatus;
16489 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016490 if(!pEntry)
16491 {
16492 //list empty
16493 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016494 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070016495 return status;
16496 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016497 while( pEntry )
16498 {
16499 if(pPrevEntry)
16500 {
16501 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16502 //send up the stats report
16503 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16504 pTempStaEntry->staId, pTempStaEntry->pContext);
16505 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16506 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016507 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016508 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
16509 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016510 pTempStaEntry->pPeStaEntry->numClient--;
16511 //check if we need to delete the entry from peStatsReqList too
16512 if(!pTempStaEntry->pPeStaEntry->numClient)
16513 {
16514 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
16515 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016516 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016517 //check if we need to stop the tl stats timer too
16518 pMac->roam.tlStatsReqInfo.numClient--;
16519 if(!pMac->roam.tlStatsReqInfo.numClient)
16520 {
16521 if(pMac->roam.tlStatsReqInfo.timerRunning)
16522 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016523 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
16524 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016525 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016526 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016527 //we will continue
16528 }
16529 }
16530 pMac->roam.tlStatsReqInfo.periodicity = 0;
16531 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
16532 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016533 if (pTempStaEntry->periodicity)
16534 {
16535 //While creating StaEntry in csrGetStatistics,
16536 //Initializing and starting timer only when periodicity is set.
16537 //So Stop and Destroy timer only when periodicity is set.
16538
Jeff Johnsone7245742012-09-05 17:12:55 -070016539 vos_timer_stop( &pTempStaEntry->timer );
16540 // Destroy the vos timer...
16541 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
16542 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16543 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016544 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070016545 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016546 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016547
Jeff Johnson295189b2012-06-20 16:38:30 -070016548
16549 pPrevEntry = pEntry;
16550 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
16551 }
16552 //the last one
16553 if(pPrevEntry)
16554 {
16555 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16556 //send up the stats report
16557 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16558 pTempStaEntry->staId, pTempStaEntry->pContext);
16559 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16560 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016561 return status;
16562
16563}
16564
Jeff Johnson295189b2012-06-20 16:38:30 -070016565eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
16566 tRequestFullPowerReason *pReason,
16567 tANI_BOOLEAN *pfNeedPower )
16568{
16569 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
16570 tRequestFullPowerReason reason = eSME_REASON_OTHER;
16571 tPmcState pmcState;
16572 eHalStatus status = eHAL_STATUS_SUCCESS;
16573 // TODO : Session info unavailable
16574 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016575 if( pfNeedPower )
16576 {
16577 *pfNeedPower = eANI_BOOLEAN_FALSE;
16578 }
16579 //We only handle CSR commands
16580 if( !(eSmeCsrCommandMask & pCommand->command) )
16581 {
16582 return eHAL_STATUS_SUCCESS;
16583 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016584 //Check PMC state first
16585 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070016586 switch( pmcState )
16587 {
16588 case REQUEST_IMPS:
16589 case IMPS:
16590 if( eSmeCommandScan == pCommand->command )
16591 {
16592 switch( pCommand->u.scanCmd.reason )
16593 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016594#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
16595 case eCsrScanGetLfrResult:
16596#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016597 case eCsrScanGetResult:
16598 case eCsrScanBGScanAbort:
16599 case eCsrScanBGScanEnable:
16600 case eCsrScanGetScanChnInfo:
16601 //Internal process, no need for full power
16602 fNeedFullPower = eANI_BOOLEAN_FALSE;
16603 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016604 default:
16605 //Other scans are real scan, ask for power
16606 fNeedFullPower = eANI_BOOLEAN_TRUE;
16607 break;
16608 } //switch
16609 }
16610 else
16611 {
16612 //ask for power for roam and status change
16613 fNeedFullPower = eANI_BOOLEAN_TRUE;
16614 }
16615 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016616 case REQUEST_BMPS:
16617 case BMPS:
16618 case REQUEST_START_UAPSD:
16619 case UAPSD:
16620 //We treat WOWL same as BMPS
16621 case REQUEST_ENTER_WOWL:
16622 case WOWL:
16623 if( eSmeCommandRoam == pCommand->command )
16624 {
16625 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
16626 tCsrScanResult *pScanResult;
16627 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070016628 switch ( pCommand->u.roamCmd.roamReason )
16629 {
16630 case eCsrForcedDisassoc:
16631 case eCsrForcedDisassocMICFailure:
16632 reason = eSME_LINK_DISCONNECTED_BY_HDD;
16633 fNeedFullPower = eANI_BOOLEAN_TRUE;
16634 break;
16635 case eCsrSmeIssuedDisassocForHandoff:
16636 case eCsrForcedDeauth:
16637 case eCsrHddIssuedReassocToSameAP:
16638 case eCsrSmeIssuedReassocToSameAP:
16639 fNeedFullPower = eANI_BOOLEAN_TRUE;
16640 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016641 case eCsrCapsChange:
16642 fNeedFullPower = eANI_BOOLEAN_TRUE;
16643 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016644 default:
16645 //Check whether the profile is already connected. If so, no need for full power
16646 //Note: IBSS is ignored for now because we don't support powersave in IBSS
16647 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
16648 {
16649 //Only need to check the first one
16650 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
16651 if( pEntry )
16652 {
16653 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
16654#if 0
16655 // TODO : Session Specific info pConnectBssDesc
16656 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
16657 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
16658 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
16659 {
16660 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
16661 // with Authenticating first. To force this, stop the current association (Disassociate) and
16662 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
16663 // a new Association.
16664 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
16665 {
16666 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
16667 {
16668 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
16669 //No need for full power
16670 //Set the flag so the code later can avoid to do the above
16671 //check again.
16672 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
16673 break;
16674 }
16675 }
16676 }
16677#endif
16678 }
16679 }
16680 //If we are here, full power is needed
16681 fNeedFullPower = eANI_BOOLEAN_TRUE;
16682 break;
16683 }
16684 }
16685 else if( eSmeCommandWmStatusChange == pCommand->command )
16686 {
16687 //need full power for all
16688 fNeedFullPower = eANI_BOOLEAN_TRUE;
16689 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
16690 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016691#ifdef FEATURE_WLAN_TDLS
16692 else if( eSmeCommandTdlsAddPeer == pCommand->command )
16693 {
16694 //TDLS link is getting established. need full power
16695 fNeedFullPower = eANI_BOOLEAN_TRUE;
16696 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
16697 }
16698#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016699 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016700 case REQUEST_STOP_UAPSD:
16701 case REQUEST_EXIT_WOWL:
16702 if( eSmeCommandRoam == pCommand->command )
16703 {
16704 fNeedFullPower = eANI_BOOLEAN_TRUE;
16705 switch ( pCommand->u.roamCmd.roamReason )
16706 {
16707 case eCsrForcedDisassoc:
16708 case eCsrForcedDisassocMICFailure:
16709 reason = eSME_LINK_DISCONNECTED_BY_HDD;
16710 break;
16711 default:
16712 break;
16713 }
16714 }
16715 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016716 case STOPPED:
16717 case REQUEST_STANDBY:
16718 case STANDBY:
16719 case LOW_POWER:
16720 //We are not supposed to do anything
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016721 smsLog( pMac, LOGE, FL( " cannot process because PMC is in stopped/standby state %d" ), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070016722 status = eHAL_STATUS_FAILURE;
16723 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016724 case FULL_POWER:
16725 case REQUEST_FULL_POWER:
16726 default:
16727 //No need to ask for full power. This has to be FULL_POWER state
16728 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016729 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070016730 if( pReason )
16731 {
16732 *pReason = reason;
16733 }
16734 if( pfNeedPower )
16735 {
16736 *pfNeedPower = fNeedFullPower;
16737 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016738 return ( status );
16739}
16740
Jeff Johnson295189b2012-06-20 16:38:30 -070016741static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
16742{
16743 eHalStatus status = eHAL_STATUS_SUCCESS;
16744 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
16745 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070016746 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070016747 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
16748 {
16749 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
16750 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016751 return ( status );
16752}
16753
Jeff Johnson295189b2012-06-20 16:38:30 -070016754tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
16755{
16756 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070016757 if( pCmd )
16758 {
16759 pMac->roam.sPendingCommands++;
16760 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016761 return ( pCmd );
16762}
16763
Jeff Johnson295189b2012-06-20 16:38:30 -070016764void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
16765{
16766 if (pMac->roam.sPendingCommands > 0)
16767 {
16768 //All command allocated through csrGetCommandBuffer need to
16769 //decrement the pending count when releasing.
16770 pMac->roam.sPendingCommands--;
16771 smeReleaseCommand( pMac, pCommand );
16772 }
16773 else
16774 {
16775 smsLog(pMac, LOGE, FL( "no pending commands"));
16776 VOS_ASSERT(0);
16777 }
16778}
16779
Jeff Johnson295189b2012-06-20 16:38:30 -070016780//Return SUCCESS is the command is queued, failed
16781eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
16782{
16783 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016784 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
16785 {
16786 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
16787 pCommand->u.scanCmd.reason);
16788 return eHAL_STATUS_CSR_WRONG_STATE;
16789 }
16790
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016791 if ((pMac->fScanOffload) && (pCommand->command == eSmeCommandScan))
16792 {
16793 csrLLInsertTail(&pMac->sme.smeScanCmdPendingList,
16794 &pCommand->Link, LL_ACCESS_LOCK);
16795 // process the command queue...
16796 smeProcessPendingQueue(pMac);
16797 status = eHAL_STATUS_SUCCESS;
16798 goto end;
16799 }
16800
Jeff Johnson295189b2012-06-20 16:38:30 -070016801 //We can call request full power first before putting the command into pending Q
16802 //because we are holding SME lock at this point.
16803 status = csrRequestFullPower( pMac, pCommand );
16804 if( HAL_STATUS_SUCCESS( status ) )
16805 {
16806 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070016807 //make sure roamCmdPendingList is not empty first
16808 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
16809 if( fNoCmdPending )
16810 {
16811 smePushCommand( pMac, pCommand, fHighPriority );
16812 }
16813 else
16814 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016815 //Other commands are waiting for PMC callback, queue the new command to the pending Q
Jeff Johnson295189b2012-06-20 16:38:30 -070016816 //no list lock is needed since SME lock is held
16817 if( !fHighPriority )
16818 {
16819 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16820 }
16821 else {
16822 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16823 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016824 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016825 }
16826 else if( eHAL_STATUS_PMC_PENDING == status )
16827 {
16828 //no list lock is needed since SME lock is held
16829 if( !fHighPriority )
16830 {
16831 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16832 }
16833 else {
16834 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16835 }
16836 //Let caller know the command is queue
16837 status = eHAL_STATUS_SUCCESS;
16838 }
16839 else
16840 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016841 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
Jeff Johnson295189b2012-06-20 16:38:30 -070016842 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016843 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070016844 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016845end:
Jeff Johnson295189b2012-06-20 16:38:30 -070016846 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070016847}
Jeff Johnson295189b2012-06-20 16:38:30 -070016848eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
16849{
16850 eHalStatus status = eHAL_STATUS_SUCCESS;
16851 tSirUpdateAPWPSIEsReq *pMsg;
16852 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
16853
16854 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16855 if (NULL == pSession)
16856 {
16857 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
16858 return eHAL_STATUS_FAILURE;
16859 }
16860
Jeff Johnson295189b2012-06-20 16:38:30 -070016861 do
16862 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016863 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
16864 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
16865 vos_mem_set(pMsg, sizeof(tSirUpdateAPWPSIEsReq), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016866 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
16867
16868 pBuf = (tANI_U8 *)&pMsg->transactionId;
lukez3c809222013-05-03 10:23:02 -070016869 VOS_ASSERT(pBuf);
16870
Jeff Johnson295189b2012-06-20 16:38:30 -070016871 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070016872 // transactionId
16873 *pBuf = 0;
16874 *( pBuf + 1 ) = 0;
16875 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070016876 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053016877 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
16878 sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070016879 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070016880 //sessionId
16881 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070016882 // APWPSIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053016883 vos_mem_copy((tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
Jeff Johnson295189b2012-06-20 16:38:30 -070016884 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070016885 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070016886 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016887 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070016888 return ( status );
16889}
Jeff Johnson295189b2012-06-20 16:38:30 -070016890eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
16891{
16892 eHalStatus status = eHAL_STATUS_SUCCESS;
16893 tSirUpdateAPWPARSNIEsReq *pMsg;
16894 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016895 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16896 if (NULL == pSession)
16897 {
16898 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
16899 return eHAL_STATUS_FAILURE;
16900 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016901 do
16902 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016903 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPARSNIEsReq));
16904 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
16905 vos_mem_set(pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016906 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070016907 pBuf = (tANI_U8 *)&pMsg->transactionId;
16908 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070016909 // transactionId
16910 *pBuf = 0;
16911 *( pBuf + 1 ) = 0;
16912 pBuf += sizeof(tANI_U16);
lukez3c809222013-05-03 10:23:02 -070016913 VOS_ASSERT(pBuf);
16914
Jeff Johnson295189b2012-06-20 16:38:30 -070016915 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053016916 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
16917 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070016918 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070016919 // sessionId
16920 *pBuf++ = (tANI_U8)sessionId;
16921
16922 // APWPARSNIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053016923 vos_mem_copy((tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070016924 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070016925 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070016926 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016927 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070016928 return ( status );
16929}
Jeff Johnson295189b2012-06-20 16:38:30 -070016930
16931#ifdef WLAN_FEATURE_VOWIFI_11R
16932//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
16933eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
16934{
16935 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
16936 tpSirFTPreAuthReq pftPreAuthReq;
16937 tANI_U16 auth_req_len = 0;
16938 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070016939 auth_req_len = sizeof(tSirFTPreAuthReq);
16940 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
Kiet Lam64c1b492013-07-12 13:56:44 +053016941 if (NULL == pftPreAuthReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070016942 {
16943 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
16944 return eHAL_STATUS_RESOURCES;
16945 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016946 // Save the SME Session ID here. We need it while processing the preauth response
16947 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070016948 vos_mem_zero(pftPreAuthReq, auth_req_len);
16949
16950 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
16951 sizeof(pBssDescription->length) + pBssDescription->length);
16952
16953 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
16954
16955 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
16956
Kiet Lam64c1b492013-07-12 13:56:44 +053016957 vos_mem_copy((void *)&pftPreAuthReq->currbssId,
16958 (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
16959 vos_mem_copy((void *)&pftPreAuthReq->preAuthbssId,
16960 (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070016961
Jeff Johnson295189b2012-06-20 16:38:30 -070016962#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080016963 if (csrRoamIs11rAssoc(pMac) &&
16964 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070016965 {
16966 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
Kiet Lam64c1b492013-07-12 13:56:44 +053016967 vos_mem_copy(pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
16968 pMac->ft.ftSmeContext.auth_ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -070016969 }
16970 else
16971#endif
16972 {
16973 pftPreAuthReq->ft_ies_length = 0;
16974 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070016975 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
16976 sizeof(pBssDescription->length) + pBssDescription->length);
16977 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070016978 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
16979}
Jeff Johnson295189b2012-06-20 16:38:30 -070016980/*--------------------------------------------------------------------------
16981 * This will receive and process the FT Pre Auth Rsp from the current
16982 * associated ap.
16983 *
16984 * This will invoke the hdd call back. This is so that hdd can now
16985 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
16986 ------------------------------------------------------------------------*/
16987void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
16988{
16989 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
16990 eHalStatus status = eHAL_STATUS_SUCCESS;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016991#if defined(FEATURE_WLAN_LFR) || defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070016992 tCsrRoamInfo roamInfo;
16993#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016994
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070016995#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080016996 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070016997 if (status != eHAL_STATUS_SUCCESS) {
16998 /*
16999 * Bail out if pre-auth was not even processed.
17000 */
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017001 smsLog(pMac, LOGE,FL("Preauth was not processed: %d SessionID: %d"),
17002 status, pFTPreAuthRsp->smeSessionId);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070017003 return;
17004 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017005#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017006 /* The below function calls/timers should be invoked only if the pre-auth is successful */
17007 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
17008 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070017009 // Implies a success
17010 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070017011 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
17012 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
Tushnim Bhattacharyya8436d772013-06-26 23:03:29 -070017013 /* No need to notify qos module if this is a non 11r roam*/
17014 if (csrRoamIs11rAssoc(pMac))
17015 {
17016 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
17017 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017018 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
17019 * actual transition from the current to handoff AP is triggered */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017020 status = vos_timer_start(&pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
17021 60);
Jeff Johnson295189b2012-06-20 16:38:30 -070017022 if (eHAL_STATUS_SUCCESS != status)
17023 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017024 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070017025 return;
17026 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017027 // Save the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053017028 vos_mem_copy((void *)&pMac->ft.ftSmeContext.preAuthbssId,
17029 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070017030 if (csrRoamIs11rAssoc(pMac))
17031 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
17032 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
17033
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017034#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
17035 if (csrRoamIsESEAssoc(pMac))
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017036 {
17037 /* read TSF */
17038 csrRoamReadTSF(pMac, (tANI_U8 *)roamInfo.timestamp);
17039
17040 // Save the bssid from the received response
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080017041 vos_mem_copy((void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017042 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_CCKM_PREAUTH_NOTIFY, 0);
17043 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017044#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017045#ifdef FEATURE_WLAN_LFR
17046 // If Legacy Fast Roaming is enabled, signal the supplicant
17047 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053017048 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017049 {
17050 // Save the bssid from the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053017051 vos_mem_copy((void *)&roamInfo.bssid,
17052 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017053 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
17054 }
17055
17056#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017057
17058 // Done with it, init it.
17059 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
17060}
17061#endif
17062#ifdef FEATURE_WLAN_BTAMP_UT_RF
17063void csrRoamJoinRetryTimerHandler(void *pv)
17064{
17065 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
17066 tpAniSirGlobal pMac = pInfo->pMac;
17067 tANI_U32 sessionId = pInfo->sessionId;
17068 tCsrRoamSession *pSession;
17069
17070 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
17071 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017072 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070017073 pSession = CSR_GET_SESSION( pMac, sessionId );
17074 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
17075 {
17076 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
17077 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017078 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070017079 }
17080 }
17081 }
17082}
Jeff Johnson295189b2012-06-20 16:38:30 -070017083eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
17084{
17085 eHalStatus status = eHAL_STATUS_FAILURE;
17086 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
17087
17088 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
17089 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017090 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070017091 pSession->maxRetryCount--;
17092 pSession->joinRetryTimerInfo.pMac = pMac;
17093 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017094 status = vos_timer_start(&pSession->hTimerJoinRetry, interval/PAL_TIMER_TO_MS_UNIT);
17095 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070017096 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017097 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070017098 }
17099 }
17100 else
17101 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017102 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070017103 pSession->maxRetryCount);
17104 }
17105
17106 return (status);
17107}
Jeff Johnson295189b2012-06-20 16:38:30 -070017108eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
17109{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017110 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070017111 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
17112 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017113 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerJoinRetry));
Jeff Johnson295189b2012-06-20 16:38:30 -070017114 }
17115
17116 return eHAL_STATUS_SUCCESS;
17117}
17118#endif
17119
17120
17121/*
17122 pBuf points to the beginning of the message
17123 LIM packs disassoc rsp as below,
17124 messageType - 2 bytes
17125 messageLength - 2 bytes
17126 sessionId - 1 byte
17127 transactionId - 2 bytes (tANI_U16)
17128 reasonCode - 4 bytes (sizeof(tSirResultCodes))
17129 peerMacAddr - 6 bytes
17130 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
17131*/
17132static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
17133{
17134 if(pBuf && pRsp)
17135 {
17136 pBuf += 4; //skip type and length
17137 pRsp->sessionId = *pBuf++;
17138 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
17139 pBuf += 2;
17140 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
17141 pBuf += 4;
17142 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
17143 }
17144}
17145
Jeff Johnsond13512a2012-07-17 11:42:19 -070017146eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
17147{
17148 static uNvTables nvTables;
17149 eHalStatus status = eHAL_STATUS_SUCCESS;
17150 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
17151
17152 /* read the country code from NV and use it */
17153 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
17154 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017155 vos_mem_copy(pCountry, nvTables.defaultCountryTable.countryCode,
17156 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017157 return status;
17158 }
17159 else
17160 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017161 vos_mem_copy(pCountry, "XXX", WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017162 status = eHAL_STATUS_FAILURE;
17163 return status;
17164 }
17165}
17166
17167eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
17168{
Kiet Lam64c1b492013-07-12 13:56:44 +053017169 vos_mem_copy(pCountry, pMac->scan.countryCode11d, WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017170 return eHAL_STATUS_SUCCESS;
17171}
schang86c22c42013-03-13 18:41:24 -070017172
17173eHalStatus csrSetTxPower(tpAniSirGlobal pMac, v_U8_t sessionId, v_U8_t mW)
17174{
17175 tSirSetTxPowerReq *pMsg = NULL;
17176 eHalStatus status = eHAL_STATUS_SUCCESS;
17177 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17178
17179 if (!pSession)
17180 {
17181 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17182 return eHAL_STATUS_FAILURE;
17183 }
17184
Kiet Lam64c1b492013-07-12 13:56:44 +053017185 pMsg = vos_mem_malloc(sizeof(tSirSetTxPowerReq));
17186 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
17187 vos_mem_set((void *)pMsg, sizeof(tSirSetTxPowerReq), 0);
17188 pMsg->messageType = eWNI_SME_SET_TX_POWER_REQ;
17189 pMsg->length = sizeof(tSirSetTxPowerReq);
17190 pMsg->mwPower = mW;
17191 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
17192 sizeof(tSirMacAddr));
17193 status = palSendMBMessage(pMac->hHdd, pMsg);
17194 if (!HAL_STATUS_SUCCESS(status))
schang86c22c42013-03-13 18:41:24 -070017195 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017196 smsLog(pMac, LOGE, FL(" csr set TX Power Post MSG Fail %d "), status);
17197 //pMsg is freed by palSendMBMessage
schang86c22c42013-03-13 18:41:24 -070017198 }
17199 return status;
17200}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017201
Sandeep Puligilla332ea912014-02-04 00:16:24 +053017202eHalStatus csrHT40StopOBSSScan(tpAniSirGlobal pMac, v_U8_t sessionId)
17203{
17204 tSirSmeHT40OBSSStopScanInd *pMsg = NULL;
17205 eHalStatus status = eHAL_STATUS_SUCCESS;
17206 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17207
17208 if (!pSession)
17209 {
17210 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17211 return eHAL_STATUS_FAILURE;
17212 }
17213 if(IS_HT40_OBSS_SCAN_FEATURE_ENABLE)
17214 {
17215 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSStopScanInd));
17216 vos_mem_zero((void *)pMsg, sizeof(tSirSmeHT40OBSSStopScanInd));
17217 pMsg->messageType = eWNI_SME_HT40_STOP_OBSS_SCAN_IND;
17218 pMsg->length = sizeof(tANI_U8);
17219 pMsg->seesionId = sessionId;
17220 status = palSendMBMessage(pMac->hHdd, pMsg);
17221 if (!HAL_STATUS_SUCCESS(status))
17222 {
17223 smsLog(pMac, LOGE, FL(" csr STOP OBSS SCAN Fail %d "), status);
17224 //pMsg is freed by palSendMBMessage
17225 }
17226 }
17227 else
17228 {
17229 smsLog(pMac, LOGE, FL(" OBSS STOP OBSS SCAN is not supported"));
17230 status = eHAL_STATUS_FAILURE;
17231 }
17232 return status;
17233}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017234/* Returns whether a session is in VOS_STA_MODE...or not */
17235tANI_BOOLEAN csrRoamIsStaMode(tpAniSirGlobal pMac, tANI_U32 sessionId)
17236{
17237 tCsrRoamSession *pSession = NULL;
17238 pSession = CSR_GET_SESSION ( pMac, sessionId );
17239 if(!pSession)
17240 {
17241 smsLog(pMac, LOGE, FL(" %s: session %d not found "), __func__, sessionId);
17242 return eANI_BOOLEAN_FALSE;
17243 }
17244 if ( !CSR_IS_SESSION_VALID ( pMac, sessionId ) )
17245 {
17246 smsLog(pMac, LOGE, FL(" %s: Inactive session"), __func__);
17247 return eANI_BOOLEAN_FALSE;
17248 }
17249 if ( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
17250 {
17251 return eANI_BOOLEAN_FALSE;
17252 }
17253 /* There is a possibility that the above check may fail,because
17254 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
17255 * when it is connected.So,we may sneak through the above check even
17256 * if we are not a STA mode INFRA station. So, if we sneak through
17257 * the above condition, we can use the following check if we are
17258 * really in STA Mode.*/
17259
17260 if ( NULL != pSession->pCurRoamProfile )
17261 {
17262 if ( pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE )
17263 {
17264 return eANI_BOOLEAN_TRUE;
17265 } else {
17266 smsLog(pMac, LOGE, FL(" %s: pCurRoamProfile is NULL\n"), __func__);
17267 return eANI_BOOLEAN_FALSE;
17268 }
17269 }
17270
17271 return eANI_BOOLEAN_FALSE;
17272}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017273
17274#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
17275eHalStatus csrHandoffRequest(tpAniSirGlobal pMac,
17276 tCsrHandoffRequest *pHandoffInfo)
17277{
17278 eHalStatus status = eHAL_STATUS_SUCCESS;
17279 vos_msg_t msg;
17280
17281 tAniHandoffReq *pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053017282 pMsg = vos_mem_malloc(sizeof(tAniHandoffReq));
17283 if ( NULL == pMsg )
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017284 {
17285 smsLog(pMac, LOGE, " csrHandoffRequest: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053017286 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017287 }
17288 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_HANDOFF_REQ);
17289 pMsg->msgLen = (tANI_U16)sizeof(tAniHandoffReq);
17290 pMsg->sessionId = pMac->roam.neighborRoamInfo.csrSessionId;
17291 pMsg->channel = pHandoffInfo->channel;
Kiet Lam64c1b492013-07-12 13:56:44 +053017292 vos_mem_copy(pMsg->bssid,
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017293 pHandoffInfo->bssid,
17294 6);
17295 msg.type = eWNI_SME_HANDOFF_REQ;
17296 msg.bodyptr = pMsg;
17297 msg.reserved = 0;
17298 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
17299 {
17300 smsLog(pMac, LOGE, " csrHandoffRequest failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053017301 vos_mem_free((void *)pMsg);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017302 status = eHAL_STATUS_FAILURE;
17303 }
17304 return status;
17305}
17306#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017307
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017308
17309#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017310/* ---------------------------------------------------------------------------
17311 \fn csrSetCCKMIe
17312 \brief This function stores the CCKM IE passed by the supplicant in a place holder
17313 data structure and this IE will be packed inside reassociation request
17314 \param pMac - pMac global structure
17315 \param sessionId - Current session id
17316 \param pCckmIe - pointer to CCKM IE data
17317 \param ccKmIeLen - length of the CCKM IE
17318 \- return Success or failure
17319 -------------------------------------------------------------------------*/
17320VOS_STATUS csrSetCCKMIe(tpAniSirGlobal pMac, const tANI_U8 sessionId,
17321 const tANI_U8 *pCckmIe,
17322 const tANI_U8 ccKmIeLen)
17323{
17324 eHalStatus status = eHAL_STATUS_SUCCESS;
17325 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17326
17327 if (!pSession)
17328 {
17329 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17330 return eHAL_STATUS_FAILURE;
17331 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053017332 vos_mem_copy(pSession->suppCckmIeInfo.cckmIe, pCckmIe, ccKmIeLen);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017333 pSession->suppCckmIeInfo.cckmIeLen = ccKmIeLen;
17334 return status;
17335}
17336
17337/* ---------------------------------------------------------------------------
17338 \fn csrRoamReadTSF
17339 \brief This function reads the TSF; and also add the time elapsed since last beacon or
17340 probe response reception from the hand off AP to arrive at the latest TSF value.
17341 \param pMac - pMac global structure
17342 \param pTimestamp - output TSF timestamp
17343 \- return Success or failure
17344 -------------------------------------------------------------------------*/
17345VOS_STATUS csrRoamReadTSF(tpAniSirGlobal pMac, tANI_U8 *pTimestamp)
17346{
17347 eHalStatus status = eHAL_STATUS_SUCCESS;
17348 tCsrNeighborRoamBSSInfo handoffNode;
17349 tANI_U32 timer_diff = 0;
17350 tANI_U32 timeStamp[2];
17351 tpSirBssDescription pBssDescription = NULL;
17352
17353 csrNeighborRoamGetHandoffAPInfo(pMac, &handoffNode);
17354 pBssDescription = handoffNode.pBssDescription;
17355
17356 // Get the time diff in milli seconds
17357 timer_diff = vos_timer_get_system_time() - pBssDescription->scanSysTimeMsec;
17358 // Convert msec to micro sec timer
17359 timer_diff = (tANI_U32)(timer_diff * SYSTEM_TIME_MSEC_TO_USEC);
17360
17361 timeStamp[0] = pBssDescription->timeStamp[0];
17362 timeStamp[1] = pBssDescription->timeStamp[1];
17363
17364 UpdateCCKMTSF(&(timeStamp[0]), &(timeStamp[1]), &timer_diff);
17365
Kiet Lamf2f201e2013-11-16 21:24:16 +053017366 vos_mem_copy(pTimestamp, (void *) &timeStamp[0],
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017367 sizeof (tANI_U32) * 2);
17368 return status;
17369}
17370
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017371#endif /*FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017372