blob: 7f8997e194b1144396de523d89472c0a8a3b9aa9 [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);
Agrawal Ashish0b6984f2014-04-05 18:35:45 +0530401 vos_mem_copy(pMac->scan.countryCodeElected, pMac->scan.countryCodeDefault,
402 WNI_CFG_COUNTRY_CODE_LEN);
Mihir Shetee1093ba2014-01-21 20:13:32 +0530403 status = csrInitGetChannels( pMac );
Agrawal Ashish0b6984f2014-04-05 18:35:45 +0530404 csrClearVotesForCountryInfo(pMac);
Mihir Shetee1093ba2014-01-21 20:13:32 +0530405
406 return status;
407}
408
Jeff Johnson295189b2012-06-20 16:38:30 -0700409eHalStatus csrSetRegInfo(tHalHandle hHal, tANI_U8 *apCntryCode)
410{
411 eHalStatus status = eHAL_STATUS_SUCCESS;
412 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
413 v_REGDOMAIN_t regId;
414 v_U8_t cntryCodeLength;
Jeff Johnson295189b2012-06-20 16:38:30 -0700415 if(NULL == apCntryCode)
416 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +0530417 smsLog( pMac, LOGE, FL(" Invalid country Code Pointer") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700418 return eHAL_STATUS_FAILURE;
419 }
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +0530420 smsLog( pMac, LOG1, FL(" country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700421 /* To get correct Regulatory domain from NV table
422 * 2 character Country code should be used
423 * 3rd charater is optional for indoor/outdoor setting */
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700424 cntryCodeLength = WNI_CFG_COUNTRY_CODE_LEN;
425/*
Jeff Johnson295189b2012-06-20 16:38:30 -0700426 cntryCodeLength = strlen(apCntryCode);
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700427
428 if (cntryCodeLength > WNI_CFG_COUNTRY_CODE_LEN)
429 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800430 smsLog( pMac, LOGW, FL(" Invalid Country Code Length") );
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700431 return eHAL_STATUS_FAILURE;
432 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700433*/
Kiet Lam6c583332013-10-14 05:37:09 +0530434 status = csrGetRegulatoryDomainForCountry(pMac, apCntryCode, &regId,
435 COUNTRY_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -0700436 if (status != eHAL_STATUS_SUCCESS)
437 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700438 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700439 return status;
440 }
Abhishek Singha306a442013-11-07 18:39:01 +0530441 status = WDA_SetRegDomain(hHal, regId, eSIR_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700442 if (status != eHAL_STATUS_SUCCESS)
443 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700444 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700445 return status;
446 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700447 pMac->scan.domainIdDefault = regId;
448 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Jeff Johnson295189b2012-06-20 16:38:30 -0700449 /* Clear CC field */
Kiet Lam64c1b492013-07-12 13:56:44 +0530450 vos_mem_set(pMac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN, 0);
451
Jeff Johnson295189b2012-06-20 16:38:30 -0700452 /* Copy 2 or 3 bytes country code */
Kiet Lam64c1b492013-07-12 13:56:44 +0530453 vos_mem_copy(pMac->scan.countryCodeDefault, apCntryCode, cntryCodeLength);
454
Jeff Johnson295189b2012-06-20 16:38:30 -0700455 /* If 2 bytes country code, 3rd byte must be filled with space */
456 if((WNI_CFG_COUNTRY_CODE_LEN - 1) == cntryCodeLength)
457 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530458 vos_mem_set(pMac->scan.countryCodeDefault + 2, 1, 0x20);
Jeff Johnson295189b2012-06-20 16:38:30 -0700459 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530460 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
461 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700462 status = csrInitGetChannels( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -0700463 return status;
464}
Jeff Johnson295189b2012-06-20 16:38:30 -0700465eHalStatus csrSetChannels(tHalHandle hHal, tCsrConfigParam *pParam )
466{
467 eHalStatus status = eHAL_STATUS_SUCCESS;
468 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
469 tANI_U8 index = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +0530470 vos_mem_copy(pParam->Csr11dinfo.countryCode, pMac->scan.countryCodeCurrent,
471 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700472 for ( index = 0; index < pMac->scan.base20MHzChannels.numChannels ; index++)
473 {
474 pParam->Csr11dinfo.Channels.channelList[index] = pMac->scan.base20MHzChannels.channelList[ index ];
475 pParam->Csr11dinfo.ChnPower[index].firstChannel = pMac->scan.base20MHzChannels.channelList[ index ];
476 pParam->Csr11dinfo.ChnPower[index].numChannels = 1;
477 pParam->Csr11dinfo.ChnPower[index].maxtxPower = pMac->scan.defaultPowerTable[index].pwr;
478 }
479 pParam->Csr11dinfo.Channels.numChannels = pMac->scan.base20MHzChannels.numChannels;
480
481 return status;
482}
Jeff Johnson295189b2012-06-20 16:38:30 -0700483eHalStatus csrClose(tpAniSirGlobal pMac)
484{
485 eHalStatus status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800486
Jeff Johnson295189b2012-06-20 16:38:30 -0700487 csrRoamClose(pMac);
488 csrScanClose(pMac);
489 csrLLClose(&pMac->roam.statsClientReqList);
490 csrLLClose(&pMac->roam.peStatsReqList);
491 csrLLClose(&pMac->roam.roamCmdPendingList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700492 /* DeInit Globals */
493 csrRoamDeInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700494 return (status);
495}
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530496
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800497eHalStatus csrUpdateChannelList(tpAniSirGlobal pMac)
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530498{
499 tSirUpdateChanList *pChanList;
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800500 tCsrScanStruct *pScan = &pMac->scan;
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530501 tANI_U8 numChan = pScan->base20MHzChannels.numChannels;
502 tANI_U32 bufLen = sizeof(tSirUpdateChanList) +
503 (sizeof(tSirUpdateChanParam) * (numChan - 1));
504 vos_msg_t msg;
505 tANI_U8 i;
506
507 pChanList = (tSirUpdateChanList *) vos_mem_malloc(bufLen);
508 if (!pChanList)
509 {
510 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
511 "Failed to allocate memory for tSirUpdateChanList");
512 return eHAL_STATUS_FAILED_ALLOC;
513 }
514
515 msg.type = WDA_UPDATE_CHAN_LIST_REQ;
516 msg.reserved = 0;
517 msg.bodyptr = pChanList;
518 pChanList->numChan = numChan;
519 for (i = 0; i < pChanList->numChan; i++)
520 {
521 pChanList->chanParam[i].chanId = pScan->defaultPowerTable[i].chanId;
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800522 pChanList->chanParam[i].pwr = cfgGetRegulatoryMaxTransmitPower(pMac,
523 pScan->defaultPowerTable[i].chanId);
524 if (vos_nv_getChannelEnabledState(pChanList->chanParam[i].chanId) ==
525 NV_CHANNEL_DFS)
526 pChanList->chanParam[i].dfsSet = VOS_TRUE;
527 else
528 pChanList->chanParam[i].dfsSet = VOS_FALSE;
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530529 }
530
531 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
532 {
533 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
534 "%s: Failed to post msg to WDA", __func__);
535 vos_mem_free(pChanList);
536 return eHAL_STATUS_FAILURE;
537 }
538
539 return eHAL_STATUS_SUCCESS;
540}
541
Jeff Johnson295189b2012-06-20 16:38:30 -0700542eHalStatus csrStart(tpAniSirGlobal pMac)
543{
544 eHalStatus status = eHAL_STATUS_SUCCESS;
545 tANI_U32 i;
546
547 do
548 {
549 //save the global vos context
550 pMac->roam.gVosContext = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
551 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
552 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, i );
553
554 status = csrRoamStart(pMac);
555 if(!HAL_STATUS_SUCCESS(status)) break;
556 pMac->scan.f11dInfoApplied = eANI_BOOLEAN_FALSE;
557 status = pmcRegisterPowerSaveCheck(pMac, csrCheckPSReady, pMac);
558 if(!HAL_STATUS_SUCCESS(status)) break;
559 pMac->roam.sPendingCommands = 0;
560 csrScanEnable(pMac);
561#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
562 status = csrNeighborRoamInit(pMac);
563#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
564 pMac->roam.tlStatsReqInfo.numClient = 0;
565 pMac->roam.tlStatsReqInfo.periodicity = 0;
566 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
567 //init the link quality indication also
568 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_MIN_IND;
569 if(!HAL_STATUS_SUCCESS(status))
570 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800571 smsLog(pMac, LOGW, " csrStart: Couldn't Init HO control blk ");
Jeff Johnson295189b2012-06-20 16:38:30 -0700572 break;
573 }
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800574#ifdef QCA_WIFI_2_0
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530575 if (pMac->fScanOffload)
576 {
577 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
578 "Scan offload is enabled, update default chan list");
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800579 status = csrUpdateChannelList(pMac);
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530580 }
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800581#else
582 status = csrUpdateChannelList(pMac);
583#endif
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530584
Jeff Johnson295189b2012-06-20 16:38:30 -0700585 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700586#if defined(ANI_LOGDUMP)
587 csrDumpInit(pMac);
588#endif //#if defined(ANI_LOGDUMP)
Jeff Johnson295189b2012-06-20 16:38:30 -0700589 return (status);
590}
591
Kiet Lama72a2322013-11-15 11:18:11 +0530592eHalStatus csrStop(tpAniSirGlobal pMac, tHalStopType stopType)
Jeff Johnson295189b2012-06-20 16:38:30 -0700593{
594 tANI_U32 sessionId;
595 tANI_U32 i;
596
597 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
598 {
599 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
600 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700601 csrScanDisable(pMac);
602 pMac->scan.fCancelIdleScan = eANI_BOOLEAN_FALSE;
603 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700604 csrLLPurge( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_TRUE );
605
606#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
607 csrNeighborRoamClose(pMac);
608#endif
609 csrScanFlushResult(pMac); //Do we want to do this?
Jeff Johnson295189b2012-06-20 16:38:30 -0700610 // deregister from PMC since we register during csrStart()
611 // (ignore status since there is nothing we can do if it fails)
612 (void) pmcDeregisterPowerSaveCheck(pMac, csrCheckPSReady);
Jeff Johnson295189b2012-06-20 16:38:30 -0700613 //Reset the domain back to the deault
614 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800615 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700616
617 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
618 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530619 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i );
Jeff Johnson295189b2012-06-20 16:38:30 -0700620 pMac->roam.curSubState[i] = eCSR_ROAM_SUBSTATE_NONE;
621 }
622
Kiet Lama72a2322013-11-15 11:18:11 +0530623#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
624 /* When HAL resets all the context information
625 * in HAL is lost, so we might need to send the
626 * scan offload request again when it comes
627 * out of reset for scan offload to be functional
628 */
629 if (HAL_STOP_TYPE_SYS_RESET == stopType)
630 {
631 bRoamScanOffloadStarted = VOS_FALSE;
632 }
633#endif
634
Jeff Johnson295189b2012-06-20 16:38:30 -0700635 return (eHAL_STATUS_SUCCESS);
636}
637
Jeff Johnson295189b2012-06-20 16:38:30 -0700638eHalStatus csrReady(tpAniSirGlobal pMac)
639{
640 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700641 csrScanGetSupportedChannels( pMac );
642 //WNI_CFG_VALID_CHANNEL_LIST should be set by this time
643 //use it to init the background scan list
644 csrInitBGScanChannelList(pMac);
645 /* HDD issues the init scan */
646 csrScanStartResultAgingTimer(pMac);
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -0800647 /* If the gScanAgingTime is set to '0' then scan results aging timeout
648 based on timer feature is not enabled*/
649 if(0 != pMac->scan.scanResultCfgAgingTime )
650 {
651 csrScanStartResultCfgAgingTimer(pMac);
652 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700653 //Store the AC weights in TL for later use
654 WLANTL_GetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
Jeff Johnson295189b2012-06-20 16:38:30 -0700655 status = csrInitChannelList( pMac );
656 if ( ! HAL_STATUS_SUCCESS( status ) )
657 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800658 smsLog( pMac, LOGE, "csrInitChannelList failed during csrReady with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700659 status );
660 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700661 return (status);
662}
Jeff Johnson295189b2012-06-20 16:38:30 -0700663void csrSetDefaultDot11Mode( tpAniSirGlobal pMac )
664{
665 v_U32_t wniDot11mode = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700666 wniDot11mode = csrTranslateToWNICfgDot11Mode(pMac,pMac->roam.configParam.uCfgDot11Mode);
667 ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, wniDot11mode, NULL, eANI_BOOLEAN_FALSE);
668}
Jeff Johnson295189b2012-06-20 16:38:30 -0700669void csrSetGlobalCfgs( tpAniSirGlobal pMac )
670{
Jeff Johnsone7245742012-09-05 17:12:55 -0700671
Jeff Johnson295189b2012-06-20 16:38:30 -0700672 ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
673 ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
674 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
675 ((pMac->roam.configParam.Is11hSupportEnabled) ? pMac->roam.configParam.Is11dSupportEnabled : pMac->roam.configParam.Is11dSupportEnabled),
676 NULL, eANI_BOOLEAN_FALSE);
677 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnsone7245742012-09-05 17:12:55 -0700678 /* 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
679 * Once session is established we will use the session related params stored in PE session for CB mode
680 */
681 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, !!(pMac->roam.configParam.channelBondingMode5GHz), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700682 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, pMac->roam.configParam.HeartbeatThresh24, NULL, eANI_BOOLEAN_FALSE);
683
684 //Update the operating mode to configured value during initialization,
685 //So that client can advertise full capabilities in Probe request frame.
686 csrSetDefaultDot11Mode( pMac );
687}
688
Jeff Johnson295189b2012-06-20 16:38:30 -0700689eHalStatus csrRoamOpen(tpAniSirGlobal pMac)
690{
691 eHalStatus status = eHAL_STATUS_SUCCESS;
692 tANI_U32 i;
693 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700694 do
695 {
696 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
697 {
698 pSession = CSR_GET_SESSION( pMac, i );
699 pSession->roamingTimerInfo.pMac = pMac;
700 pSession->roamingTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
701 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700702 pMac->roam.WaitForKeyTimerInfo.pMac = pMac;
703 pMac->roam.WaitForKeyTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530704 status = vos_timer_init(&pMac->roam.hTimerWaitForKey, VOS_TIMER_TYPE_SW,
705 csrRoamWaitForKeyTimeOutHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -0700706 &pMac->roam.WaitForKeyTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530707 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700708 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800709 smsLog(pMac, LOGE, FL("cannot allocate memory for WaitForKey time out timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700710 break;
711 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530712 status = vos_timer_init(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
713 VOS_TIMER_TYPE_SW, csrRoamTlStatsTimerHandler, pMac);
714 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700715 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800716 smsLog(pMac, LOGE, FL("cannot allocate memory for summary Statistics timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700717 return eHAL_STATUS_FAILURE;
718 }
719 }while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700720 return (status);
721}
722
Jeff Johnson295189b2012-06-20 16:38:30 -0700723eHalStatus csrRoamClose(tpAniSirGlobal pMac)
724{
725 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700726 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
727 {
728 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
729 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530730 vos_timer_stop(&pMac->roam.hTimerWaitForKey);
731 vos_timer_destroy(&pMac->roam.hTimerWaitForKey);
732 vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
733 vos_timer_destroy(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -0700734 return (eHAL_STATUS_SUCCESS);
735}
736
Jeff Johnson295189b2012-06-20 16:38:30 -0700737eHalStatus csrRoamStart(tpAniSirGlobal pMac)
738{
739 (void)pMac;
Jeff Johnson295189b2012-06-20 16:38:30 -0700740 return (eHAL_STATUS_SUCCESS);
741}
742
Jeff Johnson295189b2012-06-20 16:38:30 -0700743void csrRoamStop(tpAniSirGlobal pMac, tANI_U32 sessionId)
744{
745 csrRoamStopRoamingTimer(pMac, sessionId);
746 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
747 csrRoamDeregStatisticsReq(pMac);
748}
Jeff Johnson295189b2012-06-20 16:38:30 -0700749eHalStatus csrRoamGetConnectState(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrConnectState *pState)
750{
751 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Srinivas Girigowdac84c57c2013-02-19 17:41:56 -0800752 if ( CSR_IS_SESSION_VALID(pMac, sessionId) && (NULL != pState) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700753 {
754 status = eHAL_STATUS_SUCCESS;
755 *pState = pMac->roam.roamSession[sessionId].connectState;
756 }
757 return (status);
758}
759
Jeff Johnson295189b2012-06-20 16:38:30 -0700760eHalStatus csrRoamCopyConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
761{
762 eHalStatus status = eHAL_STATUS_FAILURE;
763 tANI_U32 size = 0;
764 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -0700765
766 if(!pSession)
767 {
768 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
769 return eHAL_STATUS_FAILURE;
770 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700771
772 if(pProfile)
773 {
774 if(pSession->pConnectBssDesc)
775 {
776 do
777 {
778 size = pSession->pConnectBssDesc->length + sizeof(pSession->pConnectBssDesc->length);
779 if(size)
780 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530781 pProfile->pBssDesc = vos_mem_malloc(size);
782 if ( NULL != pProfile->pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -0700783 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530784 vos_mem_copy(pProfile->pBssDesc,
785 pSession->pConnectBssDesc, size);
786 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700787 }
788 else
789 break;
790 }
791 else
792 {
793 pProfile->pBssDesc = NULL;
794 }
795 pProfile->AuthType = pSession->connectedProfile.AuthType;
796 pProfile->EncryptionType = pSession->connectedProfile.EncryptionType;
797 pProfile->mcEncryptionType = pSession->connectedProfile.mcEncryptionType;
798 pProfile->BSSType = pSession->connectedProfile.BSSType;
799 pProfile->operationChannel = pSession->connectedProfile.operationChannel;
800 pProfile->CBMode = pSession->connectedProfile.CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +0530801 vos_mem_copy(&pProfile->bssid, &pSession->connectedProfile.bssid,
802 sizeof(tCsrBssid));
803 vos_mem_copy(&pProfile->SSID, &pSession->connectedProfile.SSID,
804 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -0700805#ifdef WLAN_FEATURE_VOWIFI_11R
806 if (pSession->connectedProfile.MDID.mdiePresent)
807 {
808 pProfile->MDID.mdiePresent = 1;
809 pProfile->MDID.mobilityDomain = pSession->connectedProfile.MDID.mobilityDomain;
810 }
811 else
812 {
813 pProfile->MDID.mdiePresent = 0;
814 pProfile->MDID.mobilityDomain = 0;
815 }
816#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800817#ifdef FEATURE_WLAN_ESE
818 pProfile->isESEAssoc = pSession->connectedProfile.isESEAssoc;
819 if (csrIsAuthTypeESE(pSession->connectedProfile.AuthType))
Jeff Johnson295189b2012-06-20 16:38:30 -0700820 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800821 vos_mem_copy (pProfile->eseCckmInfo.krk,
822 pSession->connectedProfile.eseCckmInfo.krk,
Kiet Lam64c1b492013-07-12 13:56:44 +0530823 CSR_KRK_KEY_LEN);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800824 pProfile->eseCckmInfo.reassoc_req_num=
825 pSession->connectedProfile.eseCckmInfo.reassoc_req_num;
826 pProfile->eseCckmInfo.krk_plumbed =
827 pSession->connectedProfile.eseCckmInfo.krk_plumbed;
Jeff Johnson295189b2012-06-20 16:38:30 -0700828 }
829#endif
830 }while(0);
831 }
832 }
833
834 return (status);
835}
836
Jeff Johnson295189b2012-06-20 16:38:30 -0700837eHalStatus csrRoamGetConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
838{
839 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700840
841 if((csrIsConnStateConnected(pMac, sessionId)) ||
842 (csrIsConnStateIbss(pMac, sessionId)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700843 {
844 if(pProfile)
845 {
846 status = csrRoamCopyConnectProfile(pMac, sessionId, pProfile);
847 }
848 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700849 return (status);
850}
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700851
Jeff Johnson295189b2012-06-20 16:38:30 -0700852eHalStatus csrRoamFreeConnectProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile)
853{
854 eHalStatus status = eHAL_STATUS_SUCCESS;
855
Kiet Lam64c1b492013-07-12 13:56:44 +0530856 if (pProfile->pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -0700857 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530858 vos_mem_free(pProfile->pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700859 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530860 if (pProfile->pAddIEAssoc)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700861 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530862 vos_mem_free(pProfile->pAddIEAssoc);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700863 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530864 vos_mem_set(pProfile, sizeof(tCsrRoamConnectedProfile), 0);
865
Jeff Johnson295189b2012-06-20 16:38:30 -0700866 pProfile->AuthType = eCSR_AUTH_TYPE_UNKNOWN;
867 return (status);
868}
869
Jeff Johnson295189b2012-06-20 16:38:30 -0700870static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo )
871{
872 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700873 if( pConnectedInfo->pbFrames )
874 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530875 vos_mem_free(pConnectedInfo->pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -0700876 pConnectedInfo->pbFrames = NULL;
877 }
878 pConnectedInfo->nBeaconLength = 0;
879 pConnectedInfo->nAssocReqLength = 0;
880 pConnectedInfo->nAssocRspLength = 0;
881 pConnectedInfo->staId = 0;
882#ifdef WLAN_FEATURE_VOWIFI_11R
883 pConnectedInfo->nRICRspLength = 0;
884#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800885#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700886 pConnectedInfo->nTspecIeLength = 0;
887#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700888 return ( status );
889}
890
Jeff Johnson295189b2012-06-20 16:38:30 -0700891
892
Jeff Johnsone7245742012-09-05 17:12:55 -0700893
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700894void csrReleaseCommandPreauth(tpAniSirGlobal pMac, tSmeCmd *pCommand)
895{
896 csrReinitPreauthCmd(pMac, pCommand);
897 csrReleaseCommand( pMac, pCommand );
898}
899
Jeff Johnson295189b2012-06-20 16:38:30 -0700900void csrReleaseCommandRoam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
901{
902 csrReinitRoamCmd(pMac, pCommand);
903 csrReleaseCommand( pMac, pCommand );
904}
905
Jeff Johnson295189b2012-06-20 16:38:30 -0700906void csrReleaseCommandScan(tpAniSirGlobal pMac, tSmeCmd *pCommand)
907{
908 csrReinitScanCmd(pMac, pCommand);
909 csrReleaseCommand( pMac, pCommand );
910}
911
Jeff Johnson295189b2012-06-20 16:38:30 -0700912void csrReleaseCommandWmStatusChange(tpAniSirGlobal pMac, tSmeCmd *pCommand)
913{
914 csrReinitWmStatusChangeCmd(pMac, pCommand);
915 csrReleaseCommand( pMac, pCommand );
916}
917
Jeff Johnson295189b2012-06-20 16:38:30 -0700918void csrReinitSetKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
919{
Kiet Lam64c1b492013-07-12 13:56:44 +0530920 vos_mem_set(&pCommand->u.setKeyCmd, sizeof(tSetKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700921}
922
Jeff Johnson295189b2012-06-20 16:38:30 -0700923void csrReinitRemoveKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
924{
Kiet Lam64c1b492013-07-12 13:56:44 +0530925 vos_mem_set(&pCommand->u.removeKeyCmd, sizeof(tRemoveKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700926}
927
Jeff Johnson295189b2012-06-20 16:38:30 -0700928void csrReleaseCommandSetKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
929{
930 csrReinitSetKeyCmd(pMac, pCommand);
931 csrReleaseCommand( pMac, pCommand );
932}
Jeff Johnson295189b2012-06-20 16:38:30 -0700933void csrReleaseCommandRemoveKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
934{
935 csrReinitRemoveKeyCmd(pMac, pCommand);
936 csrReleaseCommand( pMac, pCommand );
937}
Jeff Johnson295189b2012-06-20 16:38:30 -0700938void csrAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping )
939{
940
941 if( eSmeCsrCommandMask & pCommand->command )
942 {
943 switch (pCommand->command)
944 {
945 case eSmeCommandScan:
Jeff Johnson1250df42012-12-10 14:31:52 -0800946 // We need to inform the requester before dropping the scan command
Jeff Johnsonc7c54b12013-11-17 11:49:03 -0800947 smsLog( pMac, LOGW, "%s: Drop scan reason %d callback %p",
948 __func__, pCommand->u.scanCmd.reason,
949 pCommand->u.scanCmd.callback);
Jeff Johnson295189b2012-06-20 16:38:30 -0700950 if (NULL != pCommand->u.scanCmd.callback)
951 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800952 smsLog( pMac, LOGW, "%s callback scan requester", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700953 csrScanCallCallback(pMac, pCommand, eCSR_SCAN_ABORT);
954 }
955 csrReleaseCommandScan( pMac, pCommand );
956 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700957 case eSmeCommandRoam:
958 csrReleaseCommandRoam( pMac, pCommand );
959 break;
960
961 case eSmeCommandWmStatusChange:
962 csrReleaseCommandWmStatusChange( pMac, pCommand );
963 break;
964
965 case eSmeCommandSetKey:
966 csrReleaseCommandSetKey( pMac, pCommand );
967 break;
968
969 case eSmeCommandRemoveKey:
970 csrReleaseCommandRemoveKey( pMac, pCommand );
971 break;
972
973 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800974 smsLog( pMac, LOGW, " CSR abort standard command %d", pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -0700975 csrReleaseCommand( pMac, pCommand );
976 break;
977 }
978 }
979}
980
Jeff Johnson295189b2012-06-20 16:38:30 -0700981void csrRoamSubstateChange( tpAniSirGlobal pMac, eCsrRoamSubState NewSubstate, tANI_U32 sessionId)
982{
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +0530983 smsLog(pMac, LOG1, FL("CSR RoamSubstate: [ %s <== %s ]"),
984 macTraceGetcsrRoamSubState(NewSubstate),
985 macTraceGetcsrRoamSubState(pMac->roam.curSubState[sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -0700986
Jeff Johnson295189b2012-06-20 16:38:30 -0700987 if(pMac->roam.curSubState[sessionId] == NewSubstate)
988 {
989 return;
Jeff Johnsone7245742012-09-05 17:12:55 -0700990 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700991 pMac->roam.curSubState[sessionId] = NewSubstate;
992}
993
Jeff Johnson295189b2012-06-20 16:38:30 -0700994eCsrRoamState csrRoamStateChange( tpAniSirGlobal pMac, eCsrRoamState NewRoamState, tANI_U8 sessionId)
995{
996 eCsrRoamState PreviousState;
997
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +0530998 smsLog(pMac, LOG1, FL("CSR RoamState[%hu]: [ %s <== %s ]"), sessionId,
999 macTraceGetcsrRoamState(NewRoamState),
1000 macTraceGetcsrRoamState(pMac->roam.curState[sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07001001
1002 PreviousState = pMac->roam.curState[sessionId];
1003
1004 if ( NewRoamState != pMac->roam.curState[sessionId] )
1005 {
1006 // Whenever we transition OUT of the Roaming state, clear the Roaming substate...
1007 if ( CSR_IS_ROAM_JOINING(pMac, sessionId) )
1008 {
1009 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
1010 }
1011
1012 pMac->roam.curState[sessionId] = NewRoamState;
1013 }
1014 return( PreviousState );
1015}
1016
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001017void csrAssignRssiForCategory(tpAniSirGlobal pMac, tANI_S8 bestApRssi, tANI_U8 catOffset)
Jeff Johnson295189b2012-06-20 16:38:30 -07001018{
1019 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001020 if(catOffset)
1021 {
1022 pMac->roam.configParam.bCatRssiOffset = catOffset;
1023 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
1024 {
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001025 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 -07001026 }
1027 }
1028}
1029
Jeff Johnson295189b2012-06-20 16:38:30 -07001030static void initConfigParam(tpAniSirGlobal pMac)
1031{
1032 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001033 pMac->roam.configParam.agingCount = CSR_AGING_COUNT;
Sandeep Puligilla60342762014-01-30 21:05:37 +05301034 pMac->roam.configParam.channelBondingMode24GHz =
1035 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
1036 pMac->roam.configParam.channelBondingMode5GHz =
1037 WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001038 pMac->roam.configParam.phyMode = eCSR_DOT11_MODE_TAURUS;
1039 pMac->roam.configParam.eBand = eCSR_BAND_ALL;
1040 pMac->roam.configParam.uCfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
1041 pMac->roam.configParam.FragmentationThreshold = eCSR_DOT11_FRAG_THRESH_DEFAULT;
1042 pMac->roam.configParam.HeartbeatThresh24 = 40;
1043 pMac->roam.configParam.HeartbeatThresh50 = 40;
1044 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
1045 pMac->roam.configParam.Is11dSupportEnabledOriginal = eANI_BOOLEAN_FALSE;
1046 pMac->roam.configParam.Is11eSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001047 pMac->roam.configParam.Is11hSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001048 pMac->roam.configParam.RTSThreshold = 2346;
1049 pMac->roam.configParam.shortSlotTime = eANI_BOOLEAN_TRUE;
1050 pMac->roam.configParam.WMMSupportMode = eCsrRoamWmmAuto;
1051 pMac->roam.configParam.ProprietaryRatesEnabled = eANI_BOOLEAN_TRUE;
1052 pMac->roam.configParam.TxRate = eCSR_TX_RATE_AUTO;
1053 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1054 pMac->roam.configParam.scanAgeTimeNCNPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_NO_PS;
1055 pMac->roam.configParam.scanAgeTimeNCPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_W_PS;
1056 pMac->roam.configParam.scanAgeTimeCNPS = CSR_SCAN_AGING_TIME_CONNECT_NO_PS;
1057 pMac->roam.configParam.scanAgeTimeCPS = CSR_SCAN_AGING_TIME_CONNECT_W_PS;
1058 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
1059 {
1060 pMac->roam.configParam.BssPreferValue[i] = i;
1061 }
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001062 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, CSR_DEFAULT_RSSI_DB_GAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07001063 pMac->roam.configParam.nRoamingTime = CSR_DEFAULT_ROAMING_TIME;
1064 pMac->roam.configParam.fEnforce11dChannels = eANI_BOOLEAN_FALSE;
1065 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001066 pMac->roam.configParam.fEnforceCountryCodeMatch = eANI_BOOLEAN_FALSE;
1067 pMac->roam.configParam.fEnforceDefaultDomain = eANI_BOOLEAN_FALSE;
1068 pMac->roam.configParam.nActiveMaxChnTime = CSR_ACTIVE_MAX_CHANNEL_TIME;
1069 pMac->roam.configParam.nActiveMinChnTime = CSR_ACTIVE_MIN_CHANNEL_TIME;
1070 pMac->roam.configParam.nPassiveMaxChnTime = CSR_PASSIVE_MAX_CHANNEL_TIME;
1071 pMac->roam.configParam.nPassiveMinChnTime = CSR_PASSIVE_MIN_CHANNEL_TIME;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001072 pMac->roam.configParam.nActiveMaxChnTimeBtc = CSR_ACTIVE_MAX_CHANNEL_TIME_BTC;
1073 pMac->roam.configParam.nActiveMinChnTimeBtc = CSR_ACTIVE_MIN_CHANNEL_TIME_BTC;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001074 pMac->roam.configParam.disableAggWithBtc = eANI_BOOLEAN_TRUE;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001075#ifdef WLAN_AP_STA_CONCURRENCY
1076 pMac->roam.configParam.nActiveMaxChnTimeConc = CSR_ACTIVE_MAX_CHANNEL_TIME_CONC;
1077 pMac->roam.configParam.nActiveMinChnTimeConc = CSR_ACTIVE_MIN_CHANNEL_TIME_CONC;
1078 pMac->roam.configParam.nPassiveMaxChnTimeConc = CSR_PASSIVE_MAX_CHANNEL_TIME_CONC;
1079 pMac->roam.configParam.nPassiveMinChnTimeConc = CSR_PASSIVE_MIN_CHANNEL_TIME_CONC;
1080 pMac->roam.configParam.nRestTimeConc = CSR_REST_TIME_CONC;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001081 pMac->roam.configParam.nNumStaChanCombinedConc = CSR_NUM_STA_CHAN_COMBINED_CONC;
1082 pMac->roam.configParam.nNumP2PChanCombinedConc = CSR_NUM_P2P_CHAN_COMBINED_CONC;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001083#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001084 pMac->roam.configParam.IsIdleScanEnabled = TRUE; //enable the idle scan by default
1085 pMac->roam.configParam.nTxPowerCap = CSR_MAX_TX_POWER;
1086 pMac->roam.configParam.statsReqPeriodicity = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD;
1087 pMac->roam.configParam.statsReqPeriodicityInPS = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001088#ifdef WLAN_FEATURE_VOWIFI_11R
1089 pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported = 0;
1090#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001091#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1092 pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries = 3;
1093 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold = 120;
1094 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold = 125;
1095 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = 20;
1096 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = 40;
1097 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod = 200;
1098 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels = 3;
1099 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[0] = 1;
1100 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[1] = 6;
1101 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[2] = 11;
1102 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod = 20000; //20 seconds
Srinivas Girigowdade697412013-02-14 16:31:48 -08001103 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001104#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001105#ifdef WLAN_FEATURE_11AC
1106 pMac->roam.configParam.nVhtChannelWidth = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ + 1;
1107#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001108
1109 pMac->roam.configParam.addTSWhenACMIsOff = 0;
1110 pMac->roam.configParam.fScanTwice = eANI_BOOLEAN_FALSE;
Mohit Khanna349bc392012-09-11 17:24:52 -07001111
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001112 //Remove this code once SLM_Sessionization is supported
1113 //BMPS_WORKAROUND_NOT_NEEDED
Jeff Johnsone7245742012-09-05 17:12:55 -07001114 pMac->roam.configParam.doBMPSWorkaround = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001115
Jeff Johnsone7245742012-09-05 17:12:55 -07001116}
Jeff Johnson295189b2012-06-20 16:38:30 -07001117eCsrBand csrGetCurrentBand(tHalHandle hHal)
1118{
1119 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1120 return pMac->roam.configParam.bandCapability;
1121}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001122
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001123
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001124#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001125/*
1126 This function flushes the roam scan cache
1127*/
1128eHalStatus csrFlushRoamScanRoamChannelList(tpAniSirGlobal pMac)
1129{
1130 eHalStatus status = eHAL_STATUS_SUCCESS;
1131 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1132
1133 /* Free up the memory first (if required) */
1134 if (NULL != pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
1135 {
1136 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1137 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
1138 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
1139 }
1140 return status;
1141}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001142#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001143
1144
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001145#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001146/*
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001147 This function flushes the roam scan cache
Srinivas Girigowdade697412013-02-14 16:31:48 -08001148*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001149eHalStatus csrFlushCfgBgScanRoamChannelList(tpAniSirGlobal pMac)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001150{
1151 eHalStatus status = eHAL_STATUS_SUCCESS;
1152 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1153
1154 /* Free up the memory first (if required) */
1155 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1156 {
1157 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
1158 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001159 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001160 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001161 return status;
1162}
1163
1164
1165
1166/*
1167 This function flushes the roam scan cache and creates fresh cache
1168 based on the input channel list
1169*/
1170eHalStatus csrCreateBgScanRoamChannelList(tpAniSirGlobal pMac,
1171 const tANI_U8 *pChannelList,
1172 const tANI_U8 numChannels)
1173{
1174 eHalStatus status = eHAL_STATUS_SUCCESS;
1175 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1176
Srinivas Girigowdade697412013-02-14 16:31:48 -08001177 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = numChannels;
1178
1179 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
1180 vos_mem_malloc(pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1181
1182 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1183 {
1184 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
1185 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
1186 return eHAL_STATUS_RESOURCES;
1187 }
1188
1189 /* Update the roam global structure */
Kiet Lam64c1b492013-07-12 13:56:44 +05301190 vos_mem_copy(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
1191 pChannelList,
1192 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001193 return status;
1194}
1195
1196/* This function modifies the bgscan channel list set via config ini or
1197 runtime, whenever the band changes.
1198 if the band is auto, then no operation is performed on the channel list
1199 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1200 if the band is 5G, then make sure channel list contains only 5G valid channels
1201*/
1202eHalStatus csrUpdateBgScanConfigIniChannelList(tpAniSirGlobal pMac,
1203 eCsrBand eBand)
1204{
1205 eHalStatus status = eHAL_STATUS_SUCCESS;
1206 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1207 tANI_U8 outNumChannels = 0;
1208 tANI_U8 inNumChannels = 0;
1209 tANI_U8 *inPtr = NULL;
1210 tANI_U8 i = 0;
1211 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1212
1213 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1214
1215 {
1216 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1217 "No update required for channel list "
1218 "either cfg.ini channel list is not set up or "
1219 "auto band (Band %d)", eBand);
1220 return status;
1221 }
1222
1223 inNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
1224 inPtr = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
1225 if (eCSR_BAND_24 == eBand)
1226 {
1227 for (i = 0; i < inNumChannels; i++)
1228 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001229 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
Srinivas Girigowdade697412013-02-14 16:31:48 -08001230 {
1231 ChannelList[outNumChannels++] = inPtr[i];
1232 }
1233 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001234 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001235 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001236 }
1237 else if (eCSR_BAND_5G == eBand)
1238 {
1239 for (i = 0; i < inNumChannels; i++)
1240 {
1241 /* Add 5G Non-DFS channel */
1242 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
Srinivas Girigowda56076852013-08-20 14:00:50 -07001243 csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001244 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1245 {
1246 ChannelList[outNumChannels++] = inPtr[i];
1247 }
1248 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001249 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001250 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001251 }
1252 else if (eCSR_BAND_ALL == eBand)
1253 {
1254 for (i = 0; i < inNumChannels; i++)
1255 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001256 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001257 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1258 {
1259 ChannelList[outNumChannels++] = inPtr[i];
1260 }
1261 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001262 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001263 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001264 }
1265 else
1266 {
1267 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1268 "Invalid band, No operation carried out (Band %d)", eBand);
1269 status = eHAL_STATUS_INVALID_PARAMETER;
1270 }
1271
1272 return status;
1273}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001274#endif
1275
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001276#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001277/* This function modifies the roam scan channel list as per AP neighbor
1278 report; AP neighbor report may be empty or may include only other AP
1279 channels; in any case, we merge the channel list with the learned occupied
1280 channels list.
1281 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1282 if the band is 5G, then make sure channel list contains only 5G valid channels
1283*/
1284eHalStatus csrCreateRoamScanChannelList(tpAniSirGlobal pMac,
1285 tANI_U8 *pChannelList,
1286 tANI_U8 numChannels,
1287 const eCsrBand eBand)
1288{
1289 eHalStatus status = eHAL_STATUS_SUCCESS;
1290 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1291 tANI_U8 outNumChannels = 0;
1292 tANI_U8 inNumChannels = numChannels;
1293 tANI_U8 *inPtr = pChannelList;
1294 tANI_U8 i = 0;
1295 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1296 tANI_U8 tmpChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1297 tANI_U8 mergedOutputNumOfChannels = 0;
1298 tpCsrChannelInfo currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
1299
1300 /* Create a Union of occupied channel list learnt by the DUT along with the Neighbor
1301 * report Channels. This increases the chances of the DUT to get a candidate AP while
1302 * roaming even if the Neighbor Report is not able to provide sufficient information. */
1303 if (pMac->scan.occupiedChannels.numChannels)
1304 {
1305 csrNeighborRoamMergeChannelLists(pMac,
1306 &pMac->scan.occupiedChannels.channelList[0],
1307 pMac->scan.occupiedChannels.numChannels,
1308 inPtr,
1309 inNumChannels,
1310 &mergedOutputNumOfChannels);
1311 inNumChannels = mergedOutputNumOfChannels;
1312 }
1313
1314 if (eCSR_BAND_24 == eBand)
1315 {
1316 for (i = 0; i < inNumChannels; i++)
1317 {
1318 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
1319 {
1320 ChannelList[outNumChannels++] = inPtr[i];
1321 }
1322 }
1323 }
1324 else if (eCSR_BAND_5G == eBand)
1325 {
1326 for (i = 0; i < inNumChannels; i++)
1327 {
1328 /* Add 5G Non-DFS channel */
1329 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
1330 csrRoamIsChannelValid(pMac, inPtr[i]) &&
1331 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1332 {
1333 ChannelList[outNumChannels++] = inPtr[i];
1334 }
1335 }
1336 }
1337 else if (eCSR_BAND_ALL == eBand)
1338 {
1339 for (i = 0; i < inNumChannels; i++)
1340 {
1341 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
1342 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1343 {
1344 ChannelList[outNumChannels++] = inPtr[i];
1345 }
1346 }
1347 }
1348 else
1349 {
1350 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1351 "Invalid band, No operation carried out (Band %d)", eBand);
1352 return eHAL_STATUS_INVALID_PARAMETER;
1353 }
1354
1355 /* if roaming within band is enabled, then select only the
1356 in band channels .
1357 This is required only if the band capability is set to ALL,
1358 E.g., if band capability is only 2.4G then all the channels in the
1359 list are already filtered for 2.4G channels, hence ignore this check*/
1360
1361 if ((eCSR_BAND_ALL == eBand) && CSR_IS_ROAM_INTRA_BAND_ENABLED(pMac))
1362 {
1363 csrNeighborRoamChannelsFilterByCurrentBand(
1364 pMac,
1365 ChannelList,
1366 outNumChannels,
1367 tmpChannelList,
1368 &outNumChannels);
Kiet Lamf2f201e2013-11-16 21:24:16 +05301369 vos_mem_copy(ChannelList,
1370 tmpChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001371 }
1372
1373 /* Prepare final roam scan channel list */
1374 if(outNumChannels)
1375 {
1376 /* Clear the channel list first */
1377 if (NULL != currChannelListInfo->ChannelList)
1378 {
1379 vos_mem_free(currChannelListInfo->ChannelList);
1380 currChannelListInfo->ChannelList = NULL;
1381 currChannelListInfo->numOfChannels = 0;
1382 }
1383
1384 currChannelListInfo->ChannelList = vos_mem_malloc(outNumChannels * sizeof(tANI_U8));
1385 if (NULL == currChannelListInfo->ChannelList)
1386 {
1387 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
1388 "Failed to allocate memory for roam scan channel list");
1389 currChannelListInfo->numOfChannels = 0;
1390 return VOS_STATUS_E_RESOURCES;
1391 }
Kiet Lamf2f201e2013-11-16 21:24:16 +05301392 vos_mem_copy(currChannelListInfo->ChannelList,
1393 ChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001394 }
1395 return status;
1396}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001397#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001398
Jeff Johnson295189b2012-06-20 16:38:30 -07001399eHalStatus csrSetBand(tHalHandle hHal, eCsrBand eBand)
1400{
1401 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1402 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001403 if (CSR_IS_PHY_MODE_A_ONLY(pMac) &&
1404 (eBand == eCSR_BAND_24))
1405 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001406 /* DOT11 mode configured to 11a only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001407 request to change the band to 2.4 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001408 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001409 "failed to set band cfg80211 = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001410 pMac->roam.configParam.uCfgDot11Mode, eBand);
1411 return eHAL_STATUS_INVALID_PARAMETER;
1412 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001413 if ((CSR_IS_PHY_MODE_B_ONLY(pMac) ||
1414 CSR_IS_PHY_MODE_G_ONLY(pMac)) &&
1415 (eBand == eCSR_BAND_5G))
1416 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001417 /* DOT11 mode configured to 11b/11g only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001418 request to change the band to 5 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001419 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001420 "failed to set band dot11mode = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001421 pMac->roam.configParam.uCfgDot11Mode, eBand);
1422 return eHAL_STATUS_INVALID_PARAMETER;
1423 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001424 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001425 "Band changed to %u (0 - ALL, 1 - 2.4 GHZ, 2 - 5GHZ)", eBand);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001426 pMac->roam.configParam.eBand = eBand;
1427 pMac->roam.configParam.bandCapability = eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001428 csrScanGetSupportedChannels( pMac );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001429#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -08001430 if (!csrRoamIsRoamOffloadScanEnabled(pMac))
1431 csrUpdateBgScanConfigIniChannelList( pMac, eBand );
Srinivas Girigowdade697412013-02-14 16:31:48 -08001432#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001433 status = csrInitGetChannels( pMac );
1434 if (eHAL_STATUS_SUCCESS == status)
1435 csrInitChannelList( hHal );
1436 return status;
1437}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001438
1439
Jeff Johnsone7245742012-09-05 17:12:55 -07001440/* The funcns csrConvertCBIniValueToPhyCBState and csrConvertPhyCBStateToIniValue have been
1441 * introduced to convert the ini value to the ENUM used in csr and MAC for CB state
1442 * Ideally we should have kept the ini value and enum value same and representing the same
1443 * cb values as in 11n standard i.e.
1444 * Set to 1 (SCA) if the secondary channel is above the primary channel
1445 * Set to 3 (SCB) if the secondary channel is below the primary channel
1446 * Set to 0 (SCN) if no secondary channel is present
1447 * However, since our driver is already distributed we will keep the ini definition as it is which is:
1448 * 0 - secondary none
1449 * 1 - secondary LOW
1450 * 2 - secondary HIGH
1451 * and convert to enum value used within the driver in csrChangeDefaultConfigParam using this funcn
1452 * The enum values are as follows:
1453 * PHY_SINGLE_CHANNEL_CENTERED = 0
1454 * PHY_DOUBLE_CHANNEL_LOW_PRIMARY = 1
1455 * PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
1456 */
1457ePhyChanBondState csrConvertCBIniValueToPhyCBState(v_U32_t cbIniValue)
1458{
1459
1460 ePhyChanBondState phyCbState;
1461 switch (cbIniValue) {
1462 // secondary none
1463 case 0:
1464 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1465 break;
1466 // secondary LOW
1467 case 1:
1468 phyCbState = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1469 break;
1470 // secondary HIGH
1471 case 2:
1472 phyCbState = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1473 break;
1474#ifdef WLAN_FEATURE_11AC
1475 case 3:
1476 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
1477 break;
1478 case 4:
1479 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1480 break;
1481 case 5:
1482 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1483 break;
1484 case 6:
1485 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
1486 break;
1487 case 7:
1488 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
1489 break;
1490 case 8:
1491 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
1492 break;
1493 case 9:
1494 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
1495 break;
1496#endif
1497 default:
1498 // If an invalid value is passed, disable CHANNEL BONDING
1499 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1500 break;
1501 }
1502 return phyCbState;
1503}
1504
1505v_U32_t csrConvertPhyCBStateToIniValue(ePhyChanBondState phyCbState)
1506{
1507
1508 v_U32_t cbIniValue;
1509 switch (phyCbState) {
1510 // secondary none
1511 case PHY_SINGLE_CHANNEL_CENTERED:
1512 cbIniValue = 0;
1513 break;
1514 // secondary LOW
1515 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
1516 cbIniValue = 1;
1517 break;
1518 // secondary HIGH
1519 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
1520 cbIniValue = 2;
1521 break;
1522#ifdef WLAN_FEATURE_11AC
1523 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1524 cbIniValue = 3;
1525 break;
1526 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
1527 cbIniValue = 4;
1528 break;
1529 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1530 cbIniValue = 5;
1531 break;
1532 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
1533 cbIniValue = 6;
1534 break;
1535 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
1536 cbIniValue = 7;
1537 break;
1538 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
1539 cbIniValue = 8;
1540 break;
1541 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
1542 cbIniValue = 9;
1543 break;
1544#endif
1545 default:
1546 // return some invalid value
1547 cbIniValue = 10;
1548 break;
1549 }
1550 return cbIniValue;
1551}
Jeff Johnson295189b2012-06-20 16:38:30 -07001552
1553eHalStatus csrChangeDefaultConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1554{
1555 eHalStatus status = eHAL_STATUS_SUCCESS;
1556
1557 if(pParam)
1558 {
1559 pMac->roam.configParam.WMMSupportMode = pParam->WMMSupportMode;
1560 pMac->roam.configParam.Is11eSupportEnabled = pParam->Is11eSupportEnabled;
1561 pMac->roam.configParam.FragmentationThreshold = pParam->FragmentationThreshold;
1562 pMac->roam.configParam.Is11dSupportEnabled = pParam->Is11dSupportEnabled;
1563 pMac->roam.configParam.Is11dSupportEnabledOriginal = pParam->Is11dSupportEnabled;
1564 pMac->roam.configParam.Is11hSupportEnabled = pParam->Is11hSupportEnabled;
1565
1566 pMac->roam.configParam.fenableMCCMode = pParam->fEnableMCCMode;
Mohit Khanna7ed53f02012-09-11 17:52:10 -07001567 pMac->roam.configParam.fAllowMCCGODiffBI = pParam->fAllowMCCGODiffBI;
1568
Jeff Johnsone7245742012-09-05 17:12:55 -07001569 /* channelBondingMode5GHz plays a dual role right now
1570 * 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
1571 * This is how channelBondingMode5GHz works now and this is kept intact to avoid any cfg.ini change
1572 */
1573 if (pParam->channelBondingMode24GHz > MAX_CB_VALUE_IN_INI)
1574 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001575 smsLog( pMac, LOGW, "Invalid CB value from ini in 2.4GHz band %d, CB DISABLED", pParam->channelBondingMode24GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001576 }
1577 pMac->roam.configParam.channelBondingMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode24GHz);
1578 if (pParam->channelBondingMode5GHz > MAX_CB_VALUE_IN_INI)
1579 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001580 smsLog( pMac, LOGW, "Invalid CB value from ini in 5GHz band %d, CB DISABLED", pParam->channelBondingMode5GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001581 }
1582 pMac->roam.configParam.channelBondingMode5GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001583 pMac->roam.configParam.RTSThreshold = pParam->RTSThreshold;
1584 pMac->roam.configParam.phyMode = pParam->phyMode;
1585 pMac->roam.configParam.shortSlotTime = pParam->shortSlotTime;
1586 pMac->roam.configParam.HeartbeatThresh24 = pParam->HeartbeatThresh24;
1587 pMac->roam.configParam.HeartbeatThresh50 = pParam->HeartbeatThresh50;
1588 pMac->roam.configParam.ProprietaryRatesEnabled = pParam->ProprietaryRatesEnabled;
1589 pMac->roam.configParam.TxRate = pParam->TxRate;
1590 pMac->roam.configParam.AdHocChannel24 = pParam->AdHocChannel24;
1591 pMac->roam.configParam.AdHocChannel5G = pParam->AdHocChannel5G;
1592 pMac->roam.configParam.bandCapability = pParam->bandCapability;
1593 pMac->roam.configParam.cbChoice = pParam->cbChoice;
1594 pMac->roam.configParam.bgScanInterval = pParam->bgScanInterval;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001595 pMac->roam.configParam.disableAggWithBtc = pParam->disableAggWithBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001596 //if HDD passed down non zero values then only update,
1597 //otherwise keep using the defaults
c_hpothu059edb02014-03-12 21:44:28 +05301598 if (pParam->nInitialDwellTime)
1599 {
1600 pMac->roam.configParam.nInitialDwellTime =
1601 pParam->nInitialDwellTime;
1602 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001603 if (pParam->nActiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001604 {
1605 pMac->roam.configParam.nActiveMaxChnTime = pParam->nActiveMaxChnTime;
1606 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001607 if (pParam->nActiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001608 {
1609 pMac->roam.configParam.nActiveMinChnTime = pParam->nActiveMinChnTime;
1610 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001611 if (pParam->nPassiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001612 {
1613 pMac->roam.configParam.nPassiveMaxChnTime = pParam->nPassiveMaxChnTime;
1614 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001615 if (pParam->nPassiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001616 {
1617 pMac->roam.configParam.nPassiveMinChnTime = pParam->nPassiveMinChnTime;
1618 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001619 if (pParam->nActiveMaxChnTimeBtc)
1620 {
1621 pMac->roam.configParam.nActiveMaxChnTimeBtc = pParam->nActiveMaxChnTimeBtc;
1622 }
1623 if (pParam->nActiveMinChnTimeBtc)
1624 {
1625 pMac->roam.configParam.nActiveMinChnTimeBtc = pParam->nActiveMinChnTimeBtc;
1626 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001627#ifdef WLAN_AP_STA_CONCURRENCY
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001628 if (pParam->nActiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001629 {
1630 pMac->roam.configParam.nActiveMaxChnTimeConc = pParam->nActiveMaxChnTimeConc;
1631 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001632 if (pParam->nActiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001633 {
1634 pMac->roam.configParam.nActiveMinChnTimeConc = pParam->nActiveMinChnTimeConc;
1635 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001636 if (pParam->nPassiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001637 {
1638 pMac->roam.configParam.nPassiveMaxChnTimeConc = pParam->nPassiveMaxChnTimeConc;
1639 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001640 if (pParam->nPassiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001641 {
1642 pMac->roam.configParam.nPassiveMinChnTimeConc = pParam->nPassiveMinChnTimeConc;
1643 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001644 if (pParam->nRestTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001645 {
1646 pMac->roam.configParam.nRestTimeConc = pParam->nRestTimeConc;
1647 }
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001648 if (pParam->nNumStaChanCombinedConc)
Vinay Malekal05fdc812012-12-17 13:04:30 -08001649 {
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001650 pMac->roam.configParam.nNumStaChanCombinedConc = pParam->nNumStaChanCombinedConc;
1651 }
1652 if (pParam->nNumP2PChanCombinedConc)
1653 {
1654 pMac->roam.configParam.nNumP2PChanCombinedConc = pParam->nNumP2PChanCombinedConc;
Vinay Malekal05fdc812012-12-17 13:04:30 -08001655 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001656#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001657 //if upper layer wants to disable idle scan altogether set it to 0
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001658 if (pParam->impsSleepTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001659 {
1660 //Change the unit from second to microsecond
1661 tANI_U32 impsSleepTime = pParam->impsSleepTime * PAL_TIMER_TO_SEC_UNIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07001662 if(CSR_IDLE_SCAN_NO_PS_INTERVAL_MIN <= impsSleepTime)
1663 {
1664 pMac->roam.configParam.impsSleepTime = impsSleepTime;
1665 }
1666 else
1667 {
1668 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1669 }
1670 }
1671 else
1672 {
1673 pMac->roam.configParam.impsSleepTime = 0;
1674 }
1675 pMac->roam.configParam.eBand = pParam->eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001676 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(NULL, pMac->roam.configParam.phyMode,
1677 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07001678 //if HDD passed down non zero values for age params, then only update,
1679 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001680 if (pParam->nScanResultAgeCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07001681 {
1682 pMac->roam.configParam.agingCount = pParam->nScanResultAgeCount;
1683 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001684 if(pParam->scanAgeTimeNCNPS)
1685 {
1686 pMac->roam.configParam.scanAgeTimeNCNPS = pParam->scanAgeTimeNCNPS;
1687 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001688 if(pParam->scanAgeTimeNCPS)
1689 {
1690 pMac->roam.configParam.scanAgeTimeNCPS = pParam->scanAgeTimeNCPS;
1691 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001692 if(pParam->scanAgeTimeCNPS)
1693 {
1694 pMac->roam.configParam.scanAgeTimeCNPS = pParam->scanAgeTimeCNPS;
1695 }
1696 if(pParam->scanAgeTimeCPS)
1697 {
1698 pMac->roam.configParam.scanAgeTimeCPS = pParam->scanAgeTimeCPS;
1699 }
c_hpothu0d5a7352014-03-22 12:30:25 +05301700 if (pParam->initialScanSkipDFSCh)
1701 {
1702 pMac->roam.configParam.initialScanSkipDFSCh =
1703 pParam->initialScanSkipDFSCh;
1704 }
1705
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001706 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, pParam->bCatRssiOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07001707 pMac->roam.configParam.nRoamingTime = pParam->nRoamingTime;
1708 pMac->roam.configParam.fEnforce11dChannels = pParam->fEnforce11dChannels;
1709 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = pParam->fSupplicantCountryCodeHasPriority;
1710 pMac->roam.configParam.fEnforceCountryCodeMatch = pParam->fEnforceCountryCodeMatch;
1711 pMac->roam.configParam.fEnforceDefaultDomain = pParam->fEnforceDefaultDomain;
Jeff Johnson295189b2012-06-20 16:38:30 -07001712 pMac->roam.configParam.vccRssiThreshold = pParam->vccRssiThreshold;
1713 pMac->roam.configParam.vccUlMacLossThreshold = pParam->vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001714 pMac->roam.configParam.IsIdleScanEnabled = pParam->IsIdleScanEnabled;
1715 pMac->roam.configParam.statsReqPeriodicity = pParam->statsReqPeriodicity;
1716 pMac->roam.configParam.statsReqPeriodicityInPS = pParam->statsReqPeriodicityInPS;
1717 //Assign this before calling CsrInit11dInfo
1718 pMac->roam.configParam.nTxPowerCap = pParam->nTxPowerCap;
Jeff Johnson295189b2012-06-20 16:38:30 -07001719 if( csrIs11dSupported( pMac ) )
1720 {
1721 status = CsrInit11dInfo(pMac, &pParam->Csr11dinfo);
1722 }
1723 else
1724 {
1725 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
1726 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001727
1728 /* Initialize the power + channel information if 11h is enabled.
1729 If 11d is enabled this information has already been initialized */
1730 if( csrIs11hSupported( pMac ) && !csrIs11dSupported( pMac ) )
1731 {
1732 csrInitChannelPowerList(pMac, &pParam->Csr11dinfo);
1733 }
1734
1735
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05301736#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05301737 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
1738 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001739 smsLog( pMac, LOG1, "IsFTResourceReqSupp = %d", pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07001740#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001741#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001742 pMac->roam.configParam.isFastTransitionEnabled = pParam->isFastTransitionEnabled;
Jeff Johnson43971f52012-07-17 12:26:56 -07001743 pMac->roam.configParam.RoamRssiDiff = pParam->RoamRssiDiff;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001744 pMac->roam.configParam.nImmediateRoamRssiDiff = pParam->nImmediateRoamRssiDiff;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001745 smsLog( pMac, LOG1, "nImmediateRoamRssiDiff = %d",
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001746 pMac->roam.configParam.nImmediateRoamRssiDiff );
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08001747 pMac->roam.configParam.nRoamPrefer5GHz = pParam->nRoamPrefer5GHz;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07001748 pMac->roam.configParam.nRoamIntraBand = pParam->nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07001749 pMac->roam.configParam.isWESModeEnabled = pParam->isWESModeEnabled;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001750 pMac->roam.configParam.nProbes = pParam->nProbes;
1751 pMac->roam.configParam.nRoamScanHomeAwayTime = pParam->nRoamScanHomeAwayTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001752#endif
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001753#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1754 pMac->roam.configParam.isRoamOffloadScanEnabled = pParam->isRoamOffloadScanEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001755 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled = pParam->bFastRoamInConIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001756#endif
1757#ifdef FEATURE_WLAN_LFR
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001758 pMac->roam.configParam.isFastRoamIniFeatureEnabled = pParam->isFastRoamIniFeatureEnabled;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -08001759 pMac->roam.configParam.MAWCEnabled = pParam->MAWCEnabled;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001760#endif
1761
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001762#ifdef FEATURE_WLAN_ESE
1763 pMac->roam.configParam.isEseIniFeatureEnabled = pParam->isEseIniFeatureEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001764#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001765#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301766 vos_mem_copy(&pMac->roam.configParam.neighborRoamConfig,
1767 &pParam->neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001768 smsLog( pMac, LOG1, "nNeighborScanTimerPerioid = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod);
1769 smsLog( pMac, LOG1, "nNeighborReassocRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold);
1770 smsLog( pMac, LOG1, "nNeighborLookupRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold);
1771 smsLog( pMac, LOG1, "nNeighborScanMinChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime);
1772 smsLog( pMac, LOG1, "nNeighborScanMaxChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime);
1773 smsLog( pMac, LOG1, "nMaxNeighborRetries = %d", pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries);
1774 smsLog( pMac, LOG1, "nNeighborResultsRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod);
1775 smsLog( pMac, LOG1, "nEmptyScanRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07001776 {
1777 int i;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001778 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 -07001779 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1780 {
1781 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1782 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001783 }
1784#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001785 pMac->roam.configParam.addTSWhenACMIsOff = pParam->addTSWhenACMIsOff;
1786 pMac->scan.fValidateList = pParam->fValidateList;
1787 pMac->scan.fEnableBypass11d = pParam->fEnableBypass11d;
1788 pMac->scan.fEnableDFSChnlScan = pParam->fEnableDFSChnlScan;
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08001789 pMac->scan.scanResultCfgAgingTime = pParam->scanCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001790 pMac->roam.configParam.fScanTwice = pParam->fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001791 pMac->scan.fFirstScanOnly2GChnl = pParam->fFirstScanOnly2GChnl;
1792 /* This parameter is not available in cfg and not passed from upper layers. Instead it is initialized here
1793 * This paramtere is used in concurrency to determine if there are concurrent active sessions.
1794 * Is used as a temporary fix to disconnect all active sessions when BMPS enabled so the active session if Infra STA
1795 * will automatically connect back and resume BMPS since resume BMPS is not working when moving from concurrent to
1796 * single session
1797 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001798 //Remove this code once SLM_Sessionization is supported
1799 //BMPS_WORKAROUND_NOT_NEEDED
Mohit Khanna349bc392012-09-11 17:24:52 -07001800 pMac->roam.configParam.doBMPSWorkaround = 0;
1801
Jeff Johnsone7245742012-09-05 17:12:55 -07001802#ifdef WLAN_FEATURE_11AC
1803 pMac->roam.configParam.nVhtChannelWidth = pParam->nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001804 pMac->roam.configParam.txBFEnable= pParam->enableTxBF;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001805 pMac->roam.configParam.txBFCsnValue = pParam->txBFCsnValue;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07001806 pMac->roam.configParam.enableVhtFor24GHz = pParam->enableVhtFor24GHz;
Jeff Johnsone7245742012-09-05 17:12:55 -07001807#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08001808 pMac->roam.configParam.txLdpcEnable = pParam->enableTxLdpc;
krunal soni5afa96c2013-09-06 22:19:02 -07001809
1810 pMac->roam.configParam.isAmsduSupportInAMPDU = pParam->isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001811 pMac->roam.configParam.nSelect5GHzMargin = pParam->nSelect5GHzMargin;
krunal sonie9002db2013-11-25 14:24:17 -08001812 pMac->roam.configParam.isCoalesingInIBSSAllowed =
1813 pParam->isCoalesingInIBSSAllowed;
Sandeep Puligillac80f26e2014-03-11 18:36:10 +05301814 pMac->roam.configParam.allowDFSChannelRoam = pParam->allowDFSChannelRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -07001815 }
1816
1817 return status;
1818}
1819
Jeff Johnson295189b2012-06-20 16:38:30 -07001820eHalStatus csrGetConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1821{
1822 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07001823 if(pParam)
1824 {
1825 pParam->WMMSupportMode = pMac->roam.configParam.WMMSupportMode;
1826 pParam->Is11eSupportEnabled = pMac->roam.configParam.Is11eSupportEnabled;
1827 pParam->FragmentationThreshold = pMac->roam.configParam.FragmentationThreshold;
1828 pParam->Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabled;
1829 pParam->Is11dSupportEnabledOriginal = pMac->roam.configParam.Is11dSupportEnabledOriginal;
1830 pParam->Is11hSupportEnabled = pMac->roam.configParam.Is11hSupportEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07001831 pParam->channelBondingMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode24GHz);
1832 pParam->channelBondingMode5GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001833 pParam->RTSThreshold = pMac->roam.configParam.RTSThreshold;
1834 pParam->phyMode = pMac->roam.configParam.phyMode;
1835 pParam->shortSlotTime = pMac->roam.configParam.shortSlotTime;
1836 pParam->HeartbeatThresh24 = pMac->roam.configParam.HeartbeatThresh24;
1837 pParam->HeartbeatThresh50 = pMac->roam.configParam.HeartbeatThresh50;
1838 pParam->ProprietaryRatesEnabled = pMac->roam.configParam.ProprietaryRatesEnabled;
1839 pParam->TxRate = pMac->roam.configParam.TxRate;
1840 pParam->AdHocChannel24 = pMac->roam.configParam.AdHocChannel24;
1841 pParam->AdHocChannel5G = pMac->roam.configParam.AdHocChannel5G;
1842 pParam->bandCapability = pMac->roam.configParam.bandCapability;
1843 pParam->cbChoice = pMac->roam.configParam.cbChoice;
1844 pParam->bgScanInterval = pMac->roam.configParam.bgScanInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07001845 pParam->nActiveMaxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
1846 pParam->nActiveMinChnTime = pMac->roam.configParam.nActiveMinChnTime;
1847 pParam->nPassiveMaxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
1848 pParam->nPassiveMinChnTime = pMac->roam.configParam.nPassiveMinChnTime;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001849 pParam->nActiveMaxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
1850 pParam->nActiveMinChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
1851 pParam->disableAggWithBtc = pMac->roam.configParam.disableAggWithBtc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001852#ifdef WLAN_AP_STA_CONCURRENCY
1853 pParam->nActiveMaxChnTimeConc = pMac->roam.configParam.nActiveMaxChnTimeConc;
1854 pParam->nActiveMinChnTimeConc = pMac->roam.configParam.nActiveMinChnTimeConc;
1855 pParam->nPassiveMaxChnTimeConc = pMac->roam.configParam.nPassiveMaxChnTimeConc;
1856 pParam->nPassiveMinChnTimeConc = pMac->roam.configParam.nPassiveMinChnTimeConc;
1857 pParam->nRestTimeConc = pMac->roam.configParam.nRestTimeConc;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001858 pParam->nNumStaChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc;
1859 pParam->nNumP2PChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001860#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001861 //Change the unit from microsecond to second
1862 pParam->impsSleepTime = pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_SEC_UNIT;
1863 pParam->eBand = pMac->roam.configParam.eBand;
1864 pParam->nScanResultAgeCount = pMac->roam.configParam.agingCount;
1865 pParam->scanAgeTimeNCNPS = pMac->roam.configParam.scanAgeTimeNCNPS;
1866 pParam->scanAgeTimeNCPS = pMac->roam.configParam.scanAgeTimeNCPS;
1867 pParam->scanAgeTimeCNPS = pMac->roam.configParam.scanAgeTimeCNPS;
1868 pParam->scanAgeTimeCPS = pMac->roam.configParam.scanAgeTimeCPS;
1869 pParam->bCatRssiOffset = pMac->roam.configParam.bCatRssiOffset;
1870 pParam->nRoamingTime = pMac->roam.configParam.nRoamingTime;
1871 pParam->fEnforce11dChannels = pMac->roam.configParam.fEnforce11dChannels;
1872 pParam->fSupplicantCountryCodeHasPriority = pMac->roam.configParam.fSupplicantCountryCodeHasPriority;
1873 pParam->fEnforceCountryCodeMatch = pMac->roam.configParam.fEnforceCountryCodeMatch;
1874 pParam->fEnforceDefaultDomain = pMac->roam.configParam.fEnforceDefaultDomain;
1875 pParam->vccRssiThreshold = pMac->roam.configParam.vccRssiThreshold;
1876 pParam->vccUlMacLossThreshold = pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001877 pParam->IsIdleScanEnabled = pMac->roam.configParam.IsIdleScanEnabled;
1878 pParam->nTxPowerCap = pMac->roam.configParam.nTxPowerCap;
1879 pParam->statsReqPeriodicity = pMac->roam.configParam.statsReqPeriodicity;
1880 pParam->statsReqPeriodicityInPS = pMac->roam.configParam.statsReqPeriodicityInPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001881 pParam->addTSWhenACMIsOff = pMac->roam.configParam.addTSWhenACMIsOff;
1882 pParam->fValidateList = pMac->roam.configParam.fValidateList;
1883 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
1884 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
1885 pParam->fScanTwice = pMac->roam.configParam.fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001886 pParam->fFirstScanOnly2GChnl = pMac->scan.fFirstScanOnly2GChnl;
Madan Mohan Koyyalamudied419512012-11-29 15:53:46 -08001887 pParam->fEnableMCCMode = pMac->roam.configParam.fenableMCCMode;
Madan Mohan Koyyalamudi057bd802012-11-29 16:02:39 -08001888 pParam->fAllowMCCGODiffBI = pMac->roam.configParam.fAllowMCCGODiffBI;
Sunil Ravi39b2e532013-01-20 23:45:53 -08001889 pParam->scanCfgAgingTime = pMac->scan.scanResultCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001890
1891#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301892 vos_mem_copy(&pParam->neighborRoamConfig,
1893 &pMac->roam.configParam.neighborRoamConfig,
1894 sizeof(tCsrNeighborRoamConfigParams));
Jeff Johnson295189b2012-06-20 16:38:30 -07001895#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001896#ifdef WLAN_FEATURE_11AC
1897 pParam->nVhtChannelWidth = pMac->roam.configParam.nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001898 pParam->enableTxBF = pMac->roam.configParam.txBFEnable;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001899 pParam->txBFCsnValue = pMac->roam.configParam.txBFCsnValue;
Ravi Joshiacc81822013-10-10 15:30:41 -07001900 pParam->enableVhtFor24GHz = pMac->roam.configParam.enableVhtFor24GHz;
Jeff Johnsone7245742012-09-05 17:12:55 -07001901#endif
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001902#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05301903 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
1904 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001905#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001906#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001907 pParam->isFastTransitionEnabled = pMac->roam.configParam.isFastTransitionEnabled;
1908 pParam->RoamRssiDiff = pMac->roam.configParam.RoamRssiDiff;
1909 pParam->nImmediateRoamRssiDiff = pMac->roam.configParam.nImmediateRoamRssiDiff;
1910 pParam->nRoamPrefer5GHz = pMac->roam.configParam.nRoamPrefer5GHz;
1911 pParam->nRoamIntraBand = pMac->roam.configParam.nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07001912 pParam->isWESModeEnabled = pMac->roam.configParam.isWESModeEnabled;
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -07001913 pParam->nProbes = pMac->roam.configParam.nProbes;
1914 pParam->nRoamScanHomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001915#endif
1916#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1917 pParam->isRoamOffloadScanEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
1918 pParam->bFastRoamInConIniFeatureEnabled = pMac->roam.configParam.bFastRoamInConIniFeatureEnabled;
1919#endif
1920#ifdef FEATURE_WLAN_LFR
1921 pParam->isFastRoamIniFeatureEnabled = pMac->roam.configParam.isFastRoamIniFeatureEnabled;
1922#endif
1923
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001924#ifdef FEATURE_WLAN_ESE
1925 pParam->isEseIniFeatureEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001926#endif
1927#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301928 vos_mem_copy(&pParam->neighborRoamConfig,
1929 &pMac->roam.configParam.neighborRoamConfig,
1930 sizeof(tCsrNeighborRoamConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001931 {
1932 int i;
1933 smsLog( pMac, LOG1, FL("Num of Channels in CFG Channel List: %d"), pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
1934 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1935 {
1936 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1937 }
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001938 }
1939#endif
1940
Venkata Prathyusha Kuntupallif2695c12013-04-17 15:41:23 -07001941 pParam->enableTxLdpc = pMac->roam.configParam.txLdpcEnable;
krunal soni4f087d22013-07-29 16:32:26 -07001942
krunal soni5afa96c2013-09-06 22:19:02 -07001943 pParam->isAmsduSupportInAMPDU = pMac->roam.configParam.isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001944 pParam->nSelect5GHzMargin = pMac->roam.configParam.nSelect5GHzMargin;
krunal soni5afa96c2013-09-06 22:19:02 -07001945
krunal sonie9002db2013-11-25 14:24:17 -08001946 pParam->isCoalesingInIBSSAllowed =
1947 pMac->roam.configParam.isCoalesingInIBSSAllowed;
Sandeep Puligillac80f26e2014-03-11 18:36:10 +05301948 pParam->allowDFSChannelRoam =
1949 pMac->roam.configParam.allowDFSChannelRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -07001950 csrSetChannels(pMac, pParam);
1951
1952 status = eHAL_STATUS_SUCCESS;
1953 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001954 return (status);
1955}
1956
Jeff Johnson295189b2012-06-20 16:38:30 -07001957eHalStatus csrSetPhyMode(tHalHandle hHal, tANI_U32 phyMode, eCsrBand eBand, tANI_BOOLEAN *pfRestartNeeded)
1958{
1959 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
1960 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1961 tANI_BOOLEAN fRestartNeeded = eANI_BOOLEAN_FALSE;
1962 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001963 do
1964 {
1965 if(eCSR_BAND_24 == eBand)
1966 {
1967 if(CSR_IS_RADIO_A_ONLY(pMac)) break;
1968 if((eCSR_DOT11_MODE_11a & phyMode) || (eCSR_DOT11_MODE_11a_ONLY & phyMode)) break;
1969 }
1970 if(eCSR_BAND_5G == eBand)
1971 {
1972 if(CSR_IS_RADIO_BG_ONLY(pMac)) break;
1973 if((eCSR_DOT11_MODE_11b & phyMode) || (eCSR_DOT11_MODE_11b_ONLY & phyMode) ||
1974 (eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11g_ONLY & phyMode)
1975 )
1976 {
1977 break;
1978 }
1979 }
1980 if((0 == phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
1981 {
1982 newPhyMode = eCSR_DOT11_MODE_TAURUS;
1983 }
1984 else if(eCSR_DOT11_MODE_AUTO & phyMode)
1985 {
1986 newPhyMode = eCSR_DOT11_MODE_AUTO;
1987 }
1988 else
1989 {
1990 //Check for dual band and higher capability first
1991 if(eCSR_DOT11_MODE_11n_ONLY & phyMode)
1992 {
1993 if(eCSR_DOT11_MODE_11n_ONLY != phyMode) break;
1994 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
1995 }
1996 else if(eCSR_DOT11_MODE_11a_ONLY & phyMode)
1997 {
1998 if(eCSR_DOT11_MODE_11a_ONLY != phyMode) break;
1999 if(eCSR_BAND_24 == eBand) break;
2000 newPhyMode = eCSR_DOT11_MODE_11a_ONLY;
2001 eBand = eCSR_BAND_5G;
2002 }
2003 else if(eCSR_DOT11_MODE_11g_ONLY & phyMode)
2004 {
2005 if(eCSR_DOT11_MODE_11g_ONLY != phyMode) break;
2006 if(eCSR_BAND_5G == eBand) break;
2007 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
2008 eBand = eCSR_BAND_24;
2009 }
2010 else if(eCSR_DOT11_MODE_11b_ONLY & phyMode)
2011 {
2012 if(eCSR_DOT11_MODE_11b_ONLY != phyMode) break;
2013 if(eCSR_BAND_5G == eBand) break;
2014 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
2015 eBand = eCSR_BAND_24;
2016 }
2017 else if(eCSR_DOT11_MODE_11n & phyMode)
2018 {
2019 newPhyMode = eCSR_DOT11_MODE_11n;
2020 }
2021 else if(eCSR_DOT11_MODE_abg & phyMode)
2022 {
2023 newPhyMode = eCSR_DOT11_MODE_abg;
2024 }
2025 else if(eCSR_DOT11_MODE_11a & phyMode)
2026 {
2027 if((eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11b & phyMode))
2028 {
2029 if(eCSR_BAND_ALL == eBand)
2030 {
2031 newPhyMode = eCSR_DOT11_MODE_abg;
2032 }
2033 else
2034 {
2035 //bad setting
2036 break;
2037 }
2038 }
2039 else
2040 {
2041 newPhyMode = eCSR_DOT11_MODE_11a;
2042 eBand = eCSR_BAND_5G;
2043 }
2044 }
2045 else if(eCSR_DOT11_MODE_11g & phyMode)
2046 {
2047 newPhyMode = eCSR_DOT11_MODE_11g;
2048 eBand = eCSR_BAND_24;
2049 }
2050 else if(eCSR_DOT11_MODE_11b & phyMode)
2051 {
2052 newPhyMode = eCSR_DOT11_MODE_11b;
2053 eBand = eCSR_BAND_24;
2054 }
2055 else
2056 {
2057 //We will never be here
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002058 smsLog( pMac, LOGE, FL(" cannot recognize the phy mode 0x%08X"), phyMode );
Jeff Johnson295189b2012-06-20 16:38:30 -07002059 newPhyMode = eCSR_DOT11_MODE_AUTO;
2060 }
2061 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002062 //Done validating
2063 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002064 //Now we need to check whether a restart is needed.
2065 if(eBand != pMac->roam.configParam.eBand)
2066 {
2067 fRestartNeeded = eANI_BOOLEAN_TRUE;
2068 break;
2069 }
2070 if(newPhyMode != pMac->roam.configParam.phyMode)
2071 {
2072 fRestartNeeded = eANI_BOOLEAN_TRUE;
2073 break;
2074 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002075 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002076 if(HAL_STATUS_SUCCESS(status))
2077 {
2078 pMac->roam.configParam.eBand = eBand;
2079 pMac->roam.configParam.phyMode = newPhyMode;
2080 if(pfRestartNeeded)
2081 {
2082 *pfRestartNeeded = fRestartNeeded;
2083 }
2084 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002085 return (status);
2086}
2087
Jeff Johnson295189b2012-06-20 16:38:30 -07002088void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList )
2089{
2090 tANI_U8 Index;
2091 tANI_U8 cChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07002092 // for dual band NICs, don't need to trim the channel list....
2093 if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) )
2094 {
2095 // 2.4 GHz band operation requires the channel list to be trimmed to
2096 // the 2.4 GHz channels only...
2097 if ( CSR_IS_24_BAND_ONLY( pMac ) )
2098 {
2099 for( Index = 0, cChannels = 0; Index < pChannelList->numChannels;
2100 Index++ )
2101 {
2102 if ( CSR_IS_CHANNEL_24GHZ(pChannelList->channelList[ Index ]) )
2103 {
2104 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2105 cChannels++;
2106 }
2107 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002108 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2109 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2110 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2111 // only if we need to.
2112 //
2113 // The amount of memory to clear is the number of channesl that we trimmed
2114 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2115
2116 if ( pChannelList->numChannels > cChannels )
2117 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302118 vos_mem_set(&pChannelList->channelList[ cChannels ],
2119 sizeof( pChannelList->channelList[ 0 ] ) *
2120 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002121 }
2122
2123 pChannelList->numChannels = cChannels;
2124 }
2125 else if ( CSR_IS_5G_BAND_ONLY( pMac ) )
2126 {
2127 for ( Index = 0, cChannels = 0; Index < pChannelList->numChannels; Index++ )
2128 {
2129 if ( CSR_IS_CHANNEL_5GHZ(pChannelList->channelList[ Index ]) )
2130 {
2131 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2132 cChannels++;
2133 }
2134 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002135 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2136 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2137 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2138 // only if we need to.
2139 //
2140 // The amount of memory to clear is the number of channesl that we trimmed
2141 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2142 if ( pChannelList->numChannels > cChannels )
2143 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302144 vos_mem_set(&pChannelList->channelList[ cChannels ],
2145 sizeof( pChannelList->channelList[ 0 ] ) *
2146 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002147 }
2148
2149 pChannelList->numChannels = cChannels;
2150 }
2151 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002152}
Jeff Johnson295189b2012-06-20 16:38:30 -07002153#define INFRA_AP_DEFAULT_CHANNEL 6
2154eHalStatus csrIsValidChannel(tpAniSirGlobal pMac, tANI_U8 chnNum)
2155{
2156 tANI_U8 index= 0;
2157 eHalStatus status = eHAL_STATUS_FAILURE;
2158 for (index=0; index < pMac->scan.base20MHzChannels.numChannels ;index++)
2159 {
2160 if(pMac->scan.base20MHzChannels.channelList[ index ] == chnNum){
2161 status = eHAL_STATUS_SUCCESS;
2162 break;
2163 }
2164 }
2165 return status;
2166}
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002167
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002168
Jeff Johnson295189b2012-06-20 16:38:30 -07002169eHalStatus csrInitGetChannels(tpAniSirGlobal pMac)
2170{
2171 eHalStatus status = eHAL_STATUS_SUCCESS;
2172 tANI_U8 num20MHzChannelsFound = 0;
2173 VOS_STATUS vosStatus;
2174 tANI_U8 Index = 0;
2175 tANI_U8 num40MHzChannelsFound = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002176
Jeff Johnson295189b2012-06-20 16:38:30 -07002177
2178 //TODO: this interface changed to include the 40MHz channel list
2179 // this needs to be tied into the adapter structure somehow and referenced appropriately for CB operation
2180 // Read the scan channel list (including the power limit) from EEPROM
2181 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
2182 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
2183 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
2184 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002185 smsLog( pMac, LOGE, FL("failed to get channels "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002186 status = eHAL_STATUS_FAILURE;
2187 }
2188 else
2189 {
2190 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
2191 {
2192 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2193 }
2194 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
2195 // Move the channel list to the global data
2196 // structure -- this will be used as the scan list
2197 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
2198 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002199 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[ Index ].chanId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002200 }
2201 pMac->scan.base20MHzChannels.numChannels = num20MHzChannelsFound;
2202 if(num40MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN)
2203 {
2204 num40MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2205 }
2206 for ( Index = 0; Index < num40MHzChannelsFound; Index++)
2207 {
2208 pMac->scan.base40MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable40MHz[ Index ].chanId;
2209 }
2210 pMac->scan.base40MHzChannels.numChannels = num40MHzChannelsFound;
2211 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002212 return (status);
2213}
2214
Jeff Johnson295189b2012-06-20 16:38:30 -07002215eHalStatus csrInitChannelList( tHalHandle hHal )
2216{
2217 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2218 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002219 csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels);
2220 csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels);
Kiran4a17ebe2013-01-31 10:43:43 -08002221 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE);
2222 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002223 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002224 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnson295189b2012-06-20 16:38:30 -07002225
2226 return (status);
2227}
Jeff Johnson295189b2012-06-20 16:38:30 -07002228eHalStatus csrChangeConfigParams(tpAniSirGlobal pMac,
2229 tCsrUpdateConfigParam *pUpdateConfigParam)
2230{
2231 eHalStatus status = eHAL_STATUS_FAILURE;
2232 tCsr11dinfo *ps11dinfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002233 ps11dinfo = &pUpdateConfigParam->Csr11dinfo;
2234 status = CsrInit11dInfo(pMac, ps11dinfo);
2235 return status;
2236}
2237
Jeff Johnson295189b2012-06-20 16:38:30 -07002238static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2239{
2240 eHalStatus status = eHAL_STATUS_FAILURE;
2241 tANI_U8 index;
2242 tANI_U32 count=0;
2243 tSirMacChanInfo *pChanInfo;
2244 tSirMacChanInfo *pChanInfoStart;
2245 tANI_BOOLEAN applyConfig = TRUE;
2246
Mihir Shetebc866f62014-02-13 16:08:53 +05302247 pMac->scan.currentCountryRSSI = -128;
2248
Jeff Johnson295189b2012-06-20 16:38:30 -07002249 if(!ps11dinfo)
2250 {
2251 return (status);
2252 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002253 if ( ps11dinfo->Channels.numChannels && ( WNI_CFG_VALID_CHANNEL_LIST_LEN >= ps11dinfo->Channels.numChannels ) )
2254 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302255 pMac->scan.base20MHzChannels.numChannels = ps11dinfo->Channels.numChannels;
2256 vos_mem_copy(pMac->scan.base20MHzChannels.channelList,
2257 ps11dinfo->Channels.channelList,
2258 ps11dinfo->Channels.numChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07002259 }
2260 else
2261 {
2262 //No change
2263 return (eHAL_STATUS_SUCCESS);
2264 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002265 //legacy maintenance
Kiet Lam64c1b492013-07-12 13:56:44 +05302266
2267 vos_mem_copy(pMac->scan.countryCodeDefault, ps11dinfo->countryCode,
2268 WNI_CFG_COUNTRY_CODE_LEN);
2269
2270
Jeff Johnson295189b2012-06-20 16:38:30 -07002271 //Tush: at csropen get this initialized with default, during csr reset if this
2272 // already set with some value no need initilaize with default again
2273 if(0 == pMac->scan.countryCodeCurrent[0])
2274 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302275 vos_mem_copy(pMac->scan.countryCodeCurrent, ps11dinfo->countryCode,
2276 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002277 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002278 // need to add the max power channel list
Kiet Lam64c1b492013-07-12 13:56:44 +05302279 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2280 if (pChanInfo != NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002281 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302282 vos_mem_set(pChanInfo,
2283 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN ,
2284 0);
2285
Jeff Johnson295189b2012-06-20 16:38:30 -07002286 pChanInfoStart = pChanInfo;
Jeff Johnsone7245742012-09-05 17:12:55 -07002287 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2288 {
2289 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2290 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2291 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2292 pChanInfo++;
2293 count++;
2294 }
2295 if(count)
2296 {
2297 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2298 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302299 vos_mem_free(pChanInfoStart);
Jeff Johnsone7245742012-09-05 17:12:55 -07002300 }
2301 //Only apply them to CFG when not in STOP state. Otherwise they will be applied later
2302 if( HAL_STATUS_SUCCESS(status) )
2303 {
2304 for( index = 0; index < CSR_ROAM_SESSION_MAX; index++ )
2305 {
2306 if((CSR_IS_SESSION_VALID(pMac, index)) && CSR_IS_ROAM_STOP(pMac, index))
2307 {
2308 applyConfig = FALSE;
2309 }
2310 }
2311
2312 if(TRUE == applyConfig)
2313 {
2314 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002315 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnsone7245742012-09-05 17:12:55 -07002316 }
2317
2318 }
2319 return (status);
2320}
2321/* Initialize the Channel + Power List in the local cache and in the CFG */
2322eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2323{
2324 tANI_U8 index;
2325 tANI_U32 count=0;
2326 tSirMacChanInfo *pChanInfo;
2327 tSirMacChanInfo *pChanInfoStart;
2328
2329 if(!ps11dinfo || !pMac)
2330 {
2331 return eHAL_STATUS_FAILURE;
2332 }
2333
Kiet Lam64c1b492013-07-12 13:56:44 +05302334 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2335 if (pChanInfo != NULL)
Jeff Johnsone7245742012-09-05 17:12:55 -07002336 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302337 vos_mem_set(pChanInfo,
2338 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN,
2339 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07002340 pChanInfoStart = pChanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002341
2342 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2343 {
2344 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2345 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2346 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2347 pChanInfo++;
2348 count++;
2349 }
2350 if(count)
2351 {
2352 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2353 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302354 vos_mem_free(pChanInfoStart);
Jeff Johnson295189b2012-06-20 16:38:30 -07002355 }
2356
Jeff Johnsone7245742012-09-05 17:12:55 -07002357 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002358}
2359
2360//pCommand may be NULL
2361//Pass in sessionId in case pCommand is NULL. sessionId is not used in case pCommand is not NULL.
2362void csrRoamRemoveDuplicateCommand(tpAniSirGlobal pMac, tANI_U32 sessionId, tSmeCmd *pCommand, eCsrRoamReason eRoamReason)
2363{
2364 tListElem *pEntry, *pNextEntry;
2365 tSmeCmd *pDupCommand;
2366 tDblLinkList localList;
2367
2368 vos_mem_zero(&localList, sizeof(tDblLinkList));
2369 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
2370 {
2371 smsLog(pMac, LOGE, FL(" failed to open list"));
2372 return;
2373 }
2374 csrLLLock( &pMac->sme.smeCmdPendingList );
2375 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK );
2376 while( pEntry )
2377 {
2378 pNextEntry = csrLLNext( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
2379 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07002380 // Remove the previous command if..
2381 // - the new roam command is for the same RoamReason...
2382 // - the new roam command is a NewProfileList.
2383 // - the new roam command is a Forced Dissoc
2384 // - the new roam command is from an 802.11 OID (OID_SSID or OID_BSSID).
2385 if (
2386 (pCommand && ( pCommand->sessionId == pDupCommand->sessionId ) &&
2387 ((pCommand->command == pDupCommand->command) &&
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08002388 /* This peermac check is requried for Softap/GO scenarios
2389 * For STA scenario below OR check will suffice as pCommand will
2390 * always be NULL for STA scenarios
2391 */
2392 (vos_mem_compare(pDupCommand->u.roamCmd.peerMac, pCommand->u.roamCmd.peerMac, sizeof(v_MACADDR_t))) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002393 (pCommand->u.roamCmd.roamReason == pDupCommand->u.roamCmd.roamReason ||
2394 eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason ||
2395 eCsrHddIssued == pCommand->u.roamCmd.roamReason)))
2396 ||
2397 //below the pCommand is NULL
Jeff Johnson43971f52012-07-17 12:26:56 -07002398 ( (sessionId == pDupCommand->sessionId) &&
2399 (eSmeCommandRoam == pDupCommand->command) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002400 ((eCsrForcedDisassoc == eRoamReason) ||
2401 (eCsrHddIssued == eRoamReason))
2402 )
2403 )
2404 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002405 smsLog(pMac, LOGW, FL(" roamReason = %d"), pDupCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07002406 // Remove the 'stale' roam command from the pending list...
2407 if(csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK ))
2408 {
2409 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
2410 }
2411 }
2412 pEntry = pNextEntry;
2413 }
2414 csrLLUnlock( &pMac->sme.smeCmdPendingList );
2415
2416 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
2417 {
2418 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
2419 //Tell caller that the command is cancelled
2420 csrRoamCallCallback(pMac, pDupCommand->sessionId, NULL, pDupCommand->u.roamCmd.roamId,
2421 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
2422 csrReleaseCommandRoam(pMac, pDupCommand);
2423 }
2424 csrLLClose(&localList);
2425}
Jeff Johnson295189b2012-06-20 16:38:30 -07002426eHalStatus csrRoamCallCallback(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo,
2427 tANI_U32 roamId, eRoamCmdStatus u1, eCsrRoamResult u2)
2428{
2429 eHalStatus status = eHAL_STATUS_SUCCESS;
2430#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2431 WLAN_VOS_DIAG_EVENT_DEF(connectionStatus, vos_event_wlan_status_payload_type);
2432#endif
2433 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07002434 if( CSR_IS_SESSION_VALID( pMac, sessionId) )
2435 {
2436 pSession = CSR_GET_SESSION( pMac, sessionId );
2437 }
2438 else
2439 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002440 smsLog(pMac, LOGE, "Session ID:%d is not valid", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002441 VOS_ASSERT(0);
2442 return eHAL_STATUS_FAILURE;
2443 }
krunal soni587bf012014-02-04 12:35:11 -08002444
2445 if (eANI_BOOLEAN_FALSE == pSession->sessionActive)
2446 {
2447 smsLog(pMac, LOG1, "%s Session is not Active", __func__);
2448 return eHAL_STATUS_FAILURE;
2449 }
krunal soni7f7d2c92014-02-06 15:08:43 -08002450
krunal soni587bf012014-02-04 12:35:11 -08002451 smsLog(pMac, LOG4, "Recieved RoamCmdStatus %d with Roam Result %d", u1, u2);
2452
krunal soni7f7d2c92014-02-06 15:08:43 -08002453 if(eCSR_ROAM_ASSOCIATION_COMPLETION == u1 && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002454 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002455 smsLog(pMac, LOGW, " Assoc complete result = %d statusCode = %d reasonCode = %d", u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002456 }
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07002457 if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED) && (pSession->bRefAssocStartCnt)) {
2458 /*
2459 * Decrement bRefAssocStartCnt for FT reassoc failure.
2460 * Reason: For FT reassoc failures, we first call
2461 * csrRoamCallCallback before notifying a failed roam
2462 * completion through csrRoamComplete. The latter in
2463 * turn calls csrRoamProcessResults which tries to
2464 * once again call csrRoamCallCallback if bRefAssocStartCnt
2465 * is non-zero. Since this is redundant for FT reassoc
2466 * failure, decrement bRefAssocStartCnt.
2467 */
2468 pSession->bRefAssocStartCnt--;
2469 }
2470
Jeff Johnson295189b2012-06-20 16:38:30 -07002471 if(NULL != pSession->callback)
2472 {
2473 if( pRoamInfo )
2474 {
2475 pRoamInfo->sessionId = (tANI_U8)sessionId;
2476 }
2477
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302478 /* avoid holding the global lock when making the roaming callback, original change came
2479 from a raised CR (CR304874). Since this callback is in HDD a potential deadlock
2480 is possible on other OS ports where the callback may need to take locks to protect
2481 HDD state
Jeff Johnson295189b2012-06-20 16:38:30 -07002482 UPDATE : revert this change but keep the comments here. Need to revisit as there are callbacks
2483 that may actually depend on the lock being held */
2484 // TODO: revisit: sme_ReleaseGlobalLock( &pMac->sme );
2485 status = pSession->callback(pSession->pContext, pRoamInfo, roamId, u1, u2);
2486 // TODO: revisit: sme_AcquireGlobalLock( &pMac->sme );
2487 }
2488 //EVENT_WLAN_STATUS: eCSR_ROAM_ASSOCIATION_COMPLETION,
2489 // eCSR_ROAM_LOSTLINK, eCSR_ROAM_DISASSOCIATED,
2490#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiet Lam64c1b492013-07-12 13:56:44 +05302491 vos_mem_set(&connectionStatus,
2492 sizeof(vos_event_wlan_status_payload_type), 0);
2493
krunal soni7f7d2c92014-02-06 15:08:43 -08002494 if((eCSR_ROAM_ASSOCIATION_COMPLETION == u1) && (eCSR_ROAM_RESULT_ASSOCIATED == u2) && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002495 {
2496 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
2497 connectionStatus.bssType = pRoamInfo->u.pConnectedProfile->BSSType;
2498 if(NULL != pRoamInfo->pBssDesc)
2499 {
2500 connectionStatus.rssi = pRoamInfo->pBssDesc->rssi * (-1);
2501 connectionStatus.channel = pRoamInfo->pBssDesc->channelId;
2502 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002503 connectionStatus.qosCapability = pRoamInfo->u.pConnectedProfile->qosConnection;
2504 connectionStatus.authType = (v_U8_t)diagAuthTypeFromCSRType(pRoamInfo->u.pConnectedProfile->AuthType);
2505 connectionStatus.encryptionType = (v_U8_t)diagEncTypeFromCSRType(pRoamInfo->u.pConnectedProfile->EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05302506 vos_mem_copy(connectionStatus.ssid,
2507 pRoamInfo->u.pConnectedProfile->SSID.ssId, 6);
2508
Jeff Johnson295189b2012-06-20 16:38:30 -07002509 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
2510 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2511 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002512 if((eCSR_ROAM_MIC_ERROR_IND == u1) || (eCSR_ROAM_RESULT_MIC_FAILURE == u2))
2513 {
2514 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2515 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
2516 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2517 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002518 if(eCSR_ROAM_RESULT_FORCED == u2)
2519 {
2520 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2521 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
2522 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2523 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002524 if(eCSR_ROAM_RESULT_DISASSOC_IND == u2)
2525 {
2526 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2527 connectionStatus.reason = eCSR_REASON_DISASSOC;
2528 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2529 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002530 if(eCSR_ROAM_RESULT_DEAUTH_IND == u2)
2531 {
2532 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2533 connectionStatus.reason = eCSR_REASON_DEAUTH;
2534 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2535 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002536#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
2537
2538 return (status);
2539}
Jeff Johnson295189b2012-06-20 16:38:30 -07002540// Returns whether handoff is currently in progress or not
2541tANI_BOOLEAN csrRoamIsHandoffInProgress(tpAniSirGlobal pMac)
2542{
2543#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2544 return csrNeighborRoamIsHandoffInProgress(pMac);
2545#else
2546 return eANI_BOOLEAN_FALSE;
2547#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002548}
Jeff Johnson295189b2012-06-20 16:38:30 -07002549eHalStatus csrRoamIssueDisassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
2550 eCsrRoamSubState NewSubstate, tANI_BOOLEAN fMICFailure )
2551{
2552 eHalStatus status = eHAL_STATUS_SUCCESS;
2553 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2554 tANI_U16 reasonCode;
2555 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002556
2557 if(!pSession)
2558 {
2559 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2560 return eHAL_STATUS_FAILURE;
2561 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002562
2563 //Restore AC weight in case we change it
2564 if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
2565 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07002566 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 -07002567 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
2568 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
2569 }
2570
2571 if ( fMICFailure )
2572 {
2573 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
2574 }
2575 else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)
2576 {
2577 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002578 }
2579 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002580 {
2581 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
2582 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002583#ifdef WLAN_FEATURE_VOWIFI_11R
2584 if ( (csrRoamIsHandoffInProgress(pMac)) &&
2585 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF))
2586 {
2587 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05302588 vos_mem_copy(&bssId,
2589 pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid,
2590 sizeof(tSirMacAddr));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002591 }
2592 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002593#endif
2594 if(pSession->pConnectBssDesc)
2595 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302596 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002597 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002598
Jeff Johnson295189b2012-06-20 16:38:30 -07002599
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05302600 smsLog(pMac, LOG2, FL("CSR Attempting to Disassociate Bssid="MAC_ADDRESS_STR
2601 " subState = %s reason=%d"),
2602 MAC_ADDR_ARRAY(bssId), macTraceGetcsrRoamSubState(NewSubstate),
2603 reasonCode);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08002604
Jeff Johnson295189b2012-06-20 16:38:30 -07002605 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2606
2607 status = csrSendMBDisassocReqMsg( pMac, sessionId, bssId, reasonCode );
2608
2609 if(HAL_STATUS_SUCCESS(status))
2610 {
2611 csrRoamLinkDown(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002612#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2613 //no need to tell QoS that we are disassociating, it will be taken care off in assoc req for HO
2614 if(eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate)
2615 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002616 //notify QoS module that disassoc happening
Jeff Johnson295189b2012-06-20 16:38:30 -07002617 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
2618 }
2619#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002620 }
2621 else
2622 {
2623 smsLog(pMac, LOGW, FL("csrSendMBDisassocReqMsg failed with status %d"), status);
2624 }
2625
Jeff Johnson295189b2012-06-20 16:38:30 -07002626 return (status);
2627}
Jeff Johnson295189b2012-06-20 16:38:30 -07002628
Jeff Johnson295189b2012-06-20 16:38:30 -07002629/* ---------------------------------------------------------------------------
2630 \fn csrRoamIssueDisassociateStaCmd
2631 \brief csr function that HDD calls to disassociate a associated station
2632 \param sessionId - session Id for Soft AP
2633 \param pPeerMacAddr - MAC of associated station to delete
2634 \param reason - reason code, be one of the tSirMacReasonCodes
2635 \return eHalStatus
2636 ---------------------------------------------------------------------------*/
2637eHalStatus csrRoamIssueDisassociateStaCmd( tpAniSirGlobal pMac,
2638 tANI_U32 sessionId,
2639 tANI_U8 *pPeerMacAddr,
2640 tANI_U32 reason)
2641{
2642 eHalStatus status = eHAL_STATUS_SUCCESS;
2643 tSmeCmd *pCommand;
2644
2645 do
2646 {
2647 pCommand = csrGetCommandBuffer( pMac );
2648 if ( !pCommand )
2649 {
2650 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2651 status = eHAL_STATUS_RESOURCES;
2652 break;
2653 }
2654 pCommand->command = eSmeCommandRoam;
2655 pCommand->sessionId = (tANI_U8)sessionId;
2656 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
2657 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2658 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2659 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2660 if( !HAL_STATUS_SUCCESS( status ) )
2661 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002662 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002663 csrReleaseCommandRoam( pMac, pCommand );
2664 }
2665 }while(0);
2666
2667 return status;
2668}
2669
2670
Jeff Johnson295189b2012-06-20 16:38:30 -07002671/* ---------------------------------------------------------------------------
2672 \fn csrRoamIssueDeauthSta
2673 \brief csr function that HDD calls to delete a associated station
2674 \param sessionId - session Id for Soft AP
2675 \param pPeerMacAddr - MAC of associated station to delete
2676 \param reason - reason code, be one of the tSirMacReasonCodes
2677 \return eHalStatus
2678 ---------------------------------------------------------------------------*/
2679eHalStatus csrRoamIssueDeauthStaCmd( tpAniSirGlobal pMac,
2680 tANI_U32 sessionId,
2681 tANI_U8 *pPeerMacAddr,
2682 tANI_U32 reason)
2683{
2684 eHalStatus status = eHAL_STATUS_SUCCESS;
2685 tSmeCmd *pCommand;
2686
2687 do
2688 {
2689 pCommand = csrGetCommandBuffer( pMac );
2690 if ( !pCommand )
2691 {
2692 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2693 status = eHAL_STATUS_RESOURCES;
2694 break;
2695 }
2696 pCommand->command = eSmeCommandRoam;
2697 pCommand->sessionId = (tANI_U8)sessionId;
2698 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
2699 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2700 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2701 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2702 if( !HAL_STATUS_SUCCESS( status ) )
2703 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002704 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002705 csrReleaseCommandRoam( pMac, pCommand );
2706 }
2707 }while(0);
2708
2709 return status;
2710}
Jeff Johnson295189b2012-06-20 16:38:30 -07002711eHalStatus
2712csrRoamIssueTkipCounterMeasures( tpAniSirGlobal pMac, tANI_U32 sessionId,
2713 tANI_BOOLEAN bEnable )
2714{
2715 eHalStatus status = eHAL_STATUS_FAILURE;
2716 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2717 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002718 if (!pSession)
2719 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002720 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002721 return (status);
2722 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002723 if (pSession->pConnectBssDesc)
2724 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302725 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002726 }
2727 else
2728 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002729 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002730 return (status);
2731 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002732 smsLog( pMac, LOG2, "CSR issuing tkip counter measures for Bssid = "MAC_ADDRESS_STR", Enable = %d",
2733 MAC_ADDR_ARRAY(bssId), bEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002734 status = csrSendMBTkipCounterMeasuresReqMsg( pMac, sessionId, bEnable, bssId );
2735 return (status);
2736}
Jeff Johnson295189b2012-06-20 16:38:30 -07002737eHalStatus
2738csrRoamGetAssociatedStas( tpAniSirGlobal pMac, tANI_U32 sessionId,
2739 VOS_MODULE_ID modId, void *pUsrContext,
2740 void *pfnSapEventCallback, v_U8_t *pAssocStasBuf )
2741{
2742 eHalStatus status = eHAL_STATUS_SUCCESS;
2743 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2744 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002745 if (!pSession)
2746 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002747 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002748 return (status);
2749 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002750 if(pSession->pConnectBssDesc)
2751 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302752 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002753 }
2754 else
2755 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002756 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002757 return (status);
2758 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002759 smsLog( pMac, LOG2, "CSR getting associated stations for Bssid = "MAC_ADDRESS_STR,
2760 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002761 status = csrSendMBGetAssociatedStasReqMsg( pMac, sessionId, modId, bssId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
2762 return (status);
2763}
Jeff Johnson295189b2012-06-20 16:38:30 -07002764eHalStatus
2765csrRoamGetWpsSessionOverlap( tpAniSirGlobal pMac, tANI_U32 sessionId,
2766 void *pUsrContext, void *pfnSapEventCallback, v_MACADDR_t pRemoveMac )
2767{
2768 eHalStatus status = eHAL_STATUS_SUCCESS;
2769 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2770 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2771
2772 if (!pSession)
2773 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002774 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002775 return (status);
2776 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002777 if(pSession->pConnectBssDesc)
2778 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302779 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002780 }
2781 else
2782 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002783 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002784 return (status);
2785 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002786 smsLog( pMac, LOG2, "CSR getting WPS Session Overlap for Bssid = "MAC_ADDRESS_STR,
2787 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002788
2789 status = csrSendMBGetWPSPBCSessions( pMac, sessionId, bssId, pUsrContext, pfnSapEventCallback, pRemoveMac);
2790
2791 return (status);
2792}
Jeff Johnson295189b2012-06-20 16:38:30 -07002793eHalStatus csrRoamIssueDeauth( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
2794{
2795 eHalStatus status = eHAL_STATUS_SUCCESS;
2796 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2797 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002798
2799 if (!pSession)
2800 {
2801 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2802 return eHAL_STATUS_FAILURE;
2803 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002804
2805 if(pSession->pConnectBssDesc)
2806 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302807 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002808 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002809 smsLog( pMac, LOG2, "CSR Attempting to Deauth Bssid= "MAC_ADDRESS_STR,
2810 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002811 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2812
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05302813 status = csrSendMBDeauthReqMsg( pMac, sessionId, bssId, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002814 if(!HAL_STATUS_SUCCESS(status))
2815 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05302816 smsLog(pMac, LOGE, FL("csrSendMBDeauthReqMsg failed with status %d Session ID: %d"
2817 MAC_ADDRESS_STR ), status, sessionId, MAC_ADDR_ARRAY(bssId));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002818 }
2819
Jeff Johnson295189b2012-06-20 16:38:30 -07002820 return (status);
2821}
2822
Jeff Johnson295189b2012-06-20 16:38:30 -07002823eHalStatus csrRoamSaveConnectedBssDesc( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDesc )
2824{
2825 eHalStatus status = eHAL_STATUS_SUCCESS;
2826 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2827 tANI_U32 size;
Jeff Johnson32d95a32012-09-10 13:15:23 -07002828
2829 if(!pSession)
2830 {
2831 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2832 return eHAL_STATUS_FAILURE;
2833 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002834
2835 // If no BSS description was found in this connection (happens with start IBSS), then
2836 // nix the BSS description that we keep around for the connected BSS) and get out...
2837 if(NULL == pBssDesc)
2838 {
2839 csrFreeConnectBssDesc(pMac, sessionId);
2840 }
2841 else
2842 {
2843 size = pBssDesc->length + sizeof( pBssDesc->length );
2844 if(NULL != pSession->pConnectBssDesc)
2845 {
2846 if(((pSession->pConnectBssDesc->length) + sizeof(pSession->pConnectBssDesc->length)) < size)
2847 {
2848 //not enough room for the new BSS, pMac->roam.pConnectBssDesc is freed inside
2849 csrFreeConnectBssDesc(pMac, sessionId);
2850 }
2851 }
2852 if(NULL == pSession->pConnectBssDesc)
2853 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302854 pSession->pConnectBssDesc = vos_mem_malloc(size);
Jeff Johnson295189b2012-06-20 16:38:30 -07002855 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302856 if (NULL == pSession->pConnectBssDesc)
2857 status = eHAL_STATUS_FAILURE;
2858 else
2859 vos_mem_copy(pSession->pConnectBssDesc, pBssDesc, size);
2860 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002861 return (status);
2862}
2863
Jeff Johnson295189b2012-06-20 16:38:30 -07002864eHalStatus csrRoamPrepareBssConfig(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2865 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
2866 tDot11fBeaconIEs *pIes)
2867{
2868 eHalStatus status = eHAL_STATUS_SUCCESS;
2869 eCsrCfgDot11Mode cfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002870 VOS_ASSERT( pIes != NULL );
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +05302871 if (pIes == NULL)
2872 return eHAL_STATUS_FAILURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002873
Jeff Johnson295189b2012-06-20 16:38:30 -07002874 do
2875 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302876 vos_mem_copy(&pBssConfig->BssCap, &pBssDesc->capabilityInfo,
2877 sizeof(tSirMacCapabilityInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07002878 //get qos
2879 pBssConfig->qosType = csrGetQoSFromBssDesc(pMac, pBssDesc, pIes);
2880 //get SSID
2881 if(pIes->SSID.present)
2882 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302883 vos_mem_copy(&pBssConfig->SSID.ssId, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07002884 pBssConfig->SSID.length = pIes->SSID.num_ssid;
2885 }
2886 else
2887 pBssConfig->SSID.length = 0;
2888 if(csrIsNULLSSID(pBssConfig->SSID.ssId, pBssConfig->SSID.length))
2889 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002890 smsLog(pMac, LOGW, " BSS desc SSID is a wildcard");
Jeff Johnson295189b2012-06-20 16:38:30 -07002891 //Return failed if profile doesn't have an SSID either.
2892 if(pProfile->SSIDs.numOfSSIDs == 0)
2893 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002894 smsLog(pMac, LOGW, " Both BSS desc and profile doesn't have SSID");
Jeff Johnson295189b2012-06-20 16:38:30 -07002895 status = eHAL_STATUS_FAILURE;
2896 break;
2897 }
2898 }
2899 if(CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
2900 {
2901 pBssConfig->eBand = eCSR_BAND_5G;
2902 }
2903 else
2904 {
2905 pBssConfig->eBand = eCSR_BAND_24;
2906 }
2907 //phymode
2908 if(csrIsPhyModeMatch( pMac, pProfile->phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes ))
2909 {
2910 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
2911 }
2912 else
2913 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002914 smsLog(pMac, LOGW, " Can not find match phy mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07002915 //force it
2916 if(eCSR_BAND_24 == pBssConfig->eBand)
2917 {
2918 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2919 }
2920 else
2921 {
2922 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2923 }
2924 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002925 //Qos
2926 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
2927 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos))
2928 {
2929 //Joining BSS is not 11n capable and WMM is disabled on client.
2930 //Disable QoS and WMM
2931 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2932 }
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302933
2934 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
Pratik Bhalgat8d461642012-11-22 16:55:42 +05302935 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC)) &&
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302936 ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP) ||
2937 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF) ||
2938 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF) ))
2939 {
2940 //Joining BSS is 11n capable and WMM is disabled on AP.
2941 //Assume all HT AP's are QOS AP's and enable WMM
2942 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2943 }
2944
Jeff Johnson295189b2012-06-20 16:38:30 -07002945 //auth type
2946 switch( pProfile->negotiatedAuthType )
2947 {
2948 default:
2949 case eCSR_AUTH_TYPE_WPA:
2950 case eCSR_AUTH_TYPE_WPA_PSK:
2951 case eCSR_AUTH_TYPE_WPA_NONE:
2952 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2953 pBssConfig->authType = eSIR_OPEN_SYSTEM;
2954 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002955 case eCSR_AUTH_TYPE_SHARED_KEY:
2956 pBssConfig->authType = eSIR_SHARED_KEY;
2957 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002958 case eCSR_AUTH_TYPE_AUTOSWITCH:
2959 pBssConfig->authType = eSIR_AUTO_SWITCH;
2960 break;
2961 }
2962 //short slot time
2963 if( eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode )
2964 {
2965 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
2966 }
2967 else
2968 {
2969 pBssConfig->uShortSlotTime = 0;
2970 }
2971 if(pBssConfig->BssCap.ibss)
2972 {
2973 //We don't support 11h on IBSS
2974 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
2975 }
2976 else
2977 {
2978 pBssConfig->f11hSupport = pMac->roam.configParam.Is11hSupportEnabled;
2979 }
2980 //power constraint
2981 pBssConfig->uPowerLimit = csrGet11hPowerConstraint(pMac, &pIes->PowerConstraints);
2982 //heartbeat
2983 if ( CSR_IS_11A_BSS( pBssDesc ) )
2984 {
2985 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
2986 }
2987 else
2988 {
2989 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
2990 }
2991 //Join timeout
2992 // if we find a BeaconInterval in the BssDescription, then set the Join Timeout to
Jeff Johnsone7245742012-09-05 17:12:55 -07002993 // be 10 x the BeaconInterval.
Jeff Johnson295189b2012-06-20 16:38:30 -07002994 if ( pBssDesc->beaconInterval )
2995 {
2996 //Make sure it is bigger than the minimal
Jeff Johnsone7245742012-09-05 17:12:55 -07002997 pBssConfig->uJoinTimeOut = CSR_ROAM_MAX(10 * pBssDesc->beaconInterval, CSR_JOIN_FAILURE_TIMEOUT_MIN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002998 }
2999 else
3000 {
3001 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
3002 }
3003 //validate CB
3004 pBssConfig->cbMode = csrGetCBModeFromIes(pMac, pBssDesc->channelId, pIes);
Sandeep Puligilla60342762014-01-30 21:05:37 +05303005
Jeff Johnson295189b2012-06-20 16:38:30 -07003006 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003007 return (status);
3008}
3009
Jeff Johnson295189b2012-06-20 16:38:30 -07003010static eHalStatus csrRoamPrepareBssConfigFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
3011 tBssConfigParam *pBssConfig, tSirBssDescription *pBssDesc)
3012{
3013 eHalStatus status = eHAL_STATUS_SUCCESS;
3014 tANI_U8 operationChannel = 0;
3015 tANI_U8 qAPisEnabled = FALSE;
3016 //SSID
3017 pBssConfig->SSID.length = 0;
3018 if(pProfile->SSIDs.numOfSSIDs)
3019 {
3020 //only use the first one
Kiet Lam64c1b492013-07-12 13:56:44 +05303021 vos_mem_copy(&pBssConfig->SSID, &pProfile->SSIDs.SSIDList[0].SSID,
3022 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003023 }
3024 else
3025 {
3026 //SSID must present
3027 return eHAL_STATUS_FAILURE;
3028 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003029 //Settomg up the capabilities
3030 if( csrIsBssTypeIBSS(pProfile->BSSType) )
3031 {
3032 pBssConfig->BssCap.ibss = 1;
3033 }
3034 else
3035 {
3036 pBssConfig->BssCap.ess = 1;
3037 }
3038 if( eCSR_ENCRYPT_TYPE_NONE != pProfile->EncryptionType.encryptionType[0] )
3039 {
3040 pBssConfig->BssCap.privacy = 1;
3041 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003042 pBssConfig->eBand = pMac->roam.configParam.eBand;
3043 //phymode
3044 if(pProfile->ChannelInfo.ChannelList)
3045 {
3046 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3047 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003048 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, operationChannel,
3049 &pBssConfig->eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07003050 //QOS
3051 //Is this correct to always set to this //***
Jeff Johnson295189b2012-06-20 16:38:30 -07003052 if ( pBssConfig->BssCap.ess == 1 )
3053 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003054 /*For Softap case enable WMM*/
3055 if(CSR_IS_INFRA_AP(pProfile) && (eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode )){
3056 qAPisEnabled = TRUE;
3057 }
3058 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003059 if (csrRoamGetQosInfoFromBss(pMac, pBssDesc) == eHAL_STATUS_SUCCESS) {
3060 qAPisEnabled = TRUE;
3061 } else {
3062 qAPisEnabled = FALSE;
3063 }
3064 } else {
3065 qAPisEnabled = TRUE;
3066 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003067 if (( eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode && qAPisEnabled) ||
3068 (( eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode && qAPisEnabled) ||
3069 ( eCSR_CFG_DOT11_MODE_TAURUS == pBssConfig->uCfgDot11Mode ) ) //For 11n, need QoS
3070 )
3071 {
3072 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3073 } else {
3074 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3075 }
3076
3077 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08003078 switch( pProfile->AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07003079 {
3080 default:
3081 case eCSR_AUTH_TYPE_WPA:
3082 case eCSR_AUTH_TYPE_WPA_PSK:
3083 case eCSR_AUTH_TYPE_WPA_NONE:
3084 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3085 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3086 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003087 case eCSR_AUTH_TYPE_SHARED_KEY:
3088 pBssConfig->authType = eSIR_SHARED_KEY;
3089 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003090 case eCSR_AUTH_TYPE_AUTOSWITCH:
3091 pBssConfig->authType = eSIR_AUTO_SWITCH;
3092 break;
3093 }
3094 //short slot time
3095 if( WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode )
3096 {
3097 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3098 }
3099 else
3100 {
3101 pBssConfig->uShortSlotTime = 0;
3102 }
3103 //power constraint. We don't support 11h on IBSS
3104 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3105 pBssConfig->uPowerLimit = 0;
3106 //heartbeat
3107 if ( eCSR_BAND_5G == pBssConfig->eBand )
3108 {
3109 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3110 }
3111 else
3112 {
3113 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3114 }
3115 //Join timeout
3116 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07003117
Jeff Johnson295189b2012-06-20 16:38:30 -07003118 return (status);
3119}
Jeff Johnson295189b2012-06-20 16:38:30 -07003120static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc)
3121{
3122 eHalStatus status = eHAL_STATUS_FAILURE;
3123 tDot11fBeaconIEs *pIes = NULL;
3124
3125 do
3126 {
3127 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
3128 {
3129 //err msg
3130 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003131 "csrRoamGetQosInfoFromBss() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07003132 break;
3133 }
3134 //check if the AP is QAP & it supports APSD
3135 if( CSR_IS_QOS_BSS(pIes) )
3136 {
Kiet Lamb537cfb2013-11-07 12:56:49 +05303137 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07003138 }
3139 } while (0);
Kiet Lamb537cfb2013-11-07 12:56:49 +05303140
3141 if (NULL != pIes)
3142 {
3143 vos_mem_free(pIes);
3144 }
3145
Jeff Johnson295189b2012-06-20 16:38:30 -07003146 return status;
3147}
3148
Jeff Johnson295189b2012-06-20 16:38:30 -07003149void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
3150{
Jeff Johnson295189b2012-06-20 16:38:30 -07003151 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
3152 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
3153 // See !!Note: below in this function...
3154 tANI_U32 PrivacyEnabled = 0;
3155 tANI_U32 RsnEnabled = 0;
3156 tANI_U32 WepDefaultKeyId = 0;
3157 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
3158 tANI_U32 Key0Length = 0;
3159 tANI_U32 Key1Length = 0;
3160 tANI_U32 Key2Length = 0;
3161 tANI_U32 Key3Length = 0;
3162
3163 // Reserve for the biggest key
3164 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
3165 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
3166 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
3167 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
3168
3169 switch ( pProfile->negotiatedUCEncryptionType )
3170 {
3171 case eCSR_ENCRYPT_TYPE_NONE:
3172
3173 // for NO encryption, turn off Privacy and Rsn.
3174 PrivacyEnabled = 0;
3175 RsnEnabled = 0;
3176
3177 // WEP key length and Wep Default Key ID don't matter in this case....
3178
3179 // clear out the WEP keys that may be hanging around.
3180 Key0Length = 0;
3181 Key1Length = 0;
3182 Key2Length = 0;
3183 Key3Length = 0;
3184
3185 break;
3186
3187 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303188 case eCSR_ENCRYPT_TYPE_WEP40:
Jeff Johnson295189b2012-06-20 16:38:30 -07003189
3190 // Privacy is ON. NO RSN for Wep40 static key.
3191 PrivacyEnabled = 1;
3192 RsnEnabled = 0;
3193
3194 // Set the Wep default key ID.
3195 WepDefaultKeyId = pProfile->Keys.defaultIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07003196 // Wep key size if 5 bytes (40 bits).
3197 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
3198
3199 // set encryption keys in the CFG database or clear those that are not present in this profile.
3200 if ( pProfile->Keys.KeyLength[0] )
3201 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303202 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[0],
3203 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003204 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
3205 }
3206 else
3207 {
3208 Key0Length = 0;
3209 }
3210
3211 if ( pProfile->Keys.KeyLength[1] )
3212 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303213 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[1],
3214 WNI_CFG_WEP_KEY_LENGTH_5);
3215 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
Jeff Johnson295189b2012-06-20 16:38:30 -07003216 }
3217 else
3218 {
3219 Key1Length = 0;
3220 }
3221
3222 if ( pProfile->Keys.KeyLength[2] )
3223 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303224 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[2],
3225 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003226 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
3227 }
3228 else
3229 {
3230 Key2Length = 0;
3231 }
3232
3233 if ( pProfile->Keys.KeyLength[3] )
3234 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303235 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[3],
3236 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003237 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
3238 }
3239 else
3240 {
3241 Key3Length = 0;
3242 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003243 break;
3244
3245 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303246 case eCSR_ENCRYPT_TYPE_WEP104:
Jeff Johnson295189b2012-06-20 16:38:30 -07003247
3248 // Privacy is ON. NO RSN for Wep40 static key.
3249 PrivacyEnabled = 1;
3250 RsnEnabled = 0;
3251
3252 // Set the Wep default key ID.
3253 WepDefaultKeyId = pProfile->Keys.defaultIndex;
3254
3255 // Wep key size if 13 bytes (104 bits).
3256 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
3257
3258 // set encryption keys in the CFG database or clear those that are not present in this profile.
3259 if ( pProfile->Keys.KeyLength[0] )
3260 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303261 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[ 0 ],
3262 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003263 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
3264 }
3265 else
3266 {
3267 Key0Length = 0;
3268 }
3269
3270 if ( pProfile->Keys.KeyLength[1] )
3271 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303272 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[ 1 ],
3273 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003274 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
3275 }
3276 else
3277 {
3278 Key1Length = 0;
3279 }
3280
3281 if ( pProfile->Keys.KeyLength[2] )
3282 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303283 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[ 2 ],
3284 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003285 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
3286 }
3287 else
3288 {
3289 Key2Length = 0;
3290 }
3291
3292 if ( pProfile->Keys.KeyLength[3] )
3293 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303294 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[ 3 ],
3295 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003296 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
3297 }
3298 else
3299 {
3300 Key3Length = 0;
3301 }
3302
3303 break;
3304
Jeff Johnson295189b2012-06-20 16:38:30 -07003305 case eCSR_ENCRYPT_TYPE_TKIP:
3306 case eCSR_ENCRYPT_TYPE_AES:
3307#ifdef FEATURE_WLAN_WAPI
3308 case eCSR_ENCRYPT_TYPE_WPI:
3309#endif /* FEATURE_WLAN_WAPI */
3310 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
3311 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
3312 PrivacyEnabled = (0 != fPrivacy);
3313
3314 // turn on RSN enabled for WPA associations
3315 RsnEnabled = 1;
3316
3317 // WEP key length and Wep Default Key ID don't matter in this case....
3318
3319 // clear out the static WEP keys that may be hanging around.
3320 Key0Length = 0;
3321 Key1Length = 0;
3322 Key2Length = 0;
3323 Key3Length = 0;
3324
3325 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003326 default:
3327 PrivacyEnabled = 0;
3328 RsnEnabled = 0;
3329 break;
3330 }
3331
3332 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
3333 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
3334 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
3335 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
3336 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
3337 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
3338 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
3339 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
3340}
3341
Jeff Johnson295189b2012-06-20 16:38:30 -07003342static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
3343{
3344 tANI_U32 len = 0;
3345 if(pSSID->length <= WNI_CFG_SSID_LEN)
3346 {
3347 len = pSSID->length;
3348 }
3349 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
3350}
3351
Jeff Johnson295189b2012-06-20 16:38:30 -07003352eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
3353{
3354 eHalStatus status = eHAL_STATUS_SUCCESS;
3355 tANI_U32 QoSEnabled;
3356 tANI_U32 WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003357 // set the CFG enable/disable variables based on the qosType being configured...
3358 switch( qosType )
3359 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003360 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
3361 QoSEnabled = FALSE;
3362 WmeEnabled = TRUE;
3363 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003364 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
3365 QoSEnabled = FALSE;
3366 WmeEnabled = TRUE;
3367 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003368 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
3369 QoSEnabled = FALSE;
3370 WmeEnabled = TRUE;
3371 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003372 case eCSR_MEDIUM_ACCESS_11e_eDCF:
3373 QoSEnabled = TRUE;
3374 WmeEnabled = FALSE;
3375 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003376 case eCSR_MEDIUM_ACCESS_11e_HCF:
3377 QoSEnabled = TRUE;
3378 WmeEnabled = FALSE;
3379 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003380 default:
3381 case eCSR_MEDIUM_ACCESS_DCF:
3382 QoSEnabled = FALSE;
3383 WmeEnabled = FALSE;
3384 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003385 }
3386 //save the WMM setting for later use
3387 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
Sandeep Puligillaaea98a22013-12-04 13:36:32 +05303388 pMac->roam.roamSession[sessionId].fQOSConnection = (tANI_BOOLEAN)QoSEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003389 return (status);
3390}
Jeff Johnson295189b2012-06-20 16:38:30 -07003391static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
3392 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet)
3393{
3394 eHalStatus status = eHAL_STATUS_FAILURE;
3395 int i;
3396 eCsrCfgDot11Mode cfgDot11Mode;
3397 tANI_U8 *pDstRate;
Kiet Lam64c1b492013-07-12 13:56:44 +05303398 vos_mem_set(pOpRateSet, sizeof(tSirMacRateSet), 0);
3399 vos_mem_set(pExRateSet, sizeof(tSirMacRateSet), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003400 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003401
3402 if( NULL != pIes )
3403 {
3404 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003405 // Originally, we thought that for 11a networks, the 11a rates are always
3406 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3407 // appear in the Operational Rate set. Consequently, in either case, we
3408 // would blindly put the rates we support into our Operational Rate set
3409 // (including the basic rates, which we have already verified are
3410 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003411 // However, it turns out that this is not always the case. Some AP's
3412 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3413 // too. Now, we're a little more careful:
3414 pDstRate = pOpRateSet->rate;
3415 if(pIes->SuppRates.present)
3416 {
3417 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3418 {
3419 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
3420 {
3421 *pDstRate++ = pIes->SuppRates.rates[ i ];
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003422 pOpRateSet->numRates++;
Jeff Johnson295189b2012-06-20 16:38:30 -07003423 }
3424 }
3425 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003426 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3427 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3428 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3429 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3430 {
3431 // If there are Extended Rates in the beacon, we will reflect those
3432 // extended rates that we support in out Extended Operational Rate
3433 // set:
3434 pDstRate = pExRateSet->rate;
3435 if(pIes->ExtSuppRates.present)
3436 {
3437 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3438 {
3439 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) )
3440 {
3441 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3442 pExRateSet->numRates++;
3443 }
3444 }
3445 }
3446 }
3447 }//Parsing BSSDesc
3448 else
3449 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003450 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003451 }
3452 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
3453 return status;
3454}
3455
3456static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
3457 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3458{
3459 int i;
3460 tANI_U8 *pDstRate;
3461 eCsrCfgDot11Mode cfgDot11Mode;
3462 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3463 tANI_U32 OperationalRatesLength = 0;
3464 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3465 tANI_U32 ExtendedOperationalRatesLength = 0;
3466 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3467 tANI_U32 ProprietaryOperationalRatesLength = 0;
3468 tANI_U32 PropRatesEnable = 0;
3469 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
3470 tANI_U32 MCSRateLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003471 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003472 if( NULL != pIes )
3473 {
3474 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003475 // Originally, we thought that for 11a networks, the 11a rates are always
3476 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3477 // appear in the Operational Rate set. Consequently, in either case, we
3478 // would blindly put the rates we support into our Operational Rate set
3479 // (including the basic rates, which we have already verified are
3480 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003481 // However, it turns out that this is not always the case. Some AP's
3482 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3483 // too. Now, we're a little more careful:
3484 pDstRate = OperationalRates;
3485 if(pIes->SuppRates.present)
3486 {
3487 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3488 {
3489 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
3490 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
3491 {
3492 *pDstRate++ = pIes->SuppRates.rates[ i ];
3493 OperationalRatesLength++;
3494 }
3495 }
3496 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003497 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3498 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3499 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3500 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3501 {
3502 // If there are Extended Rates in the beacon, we will reflect those
3503 // extended rates that we support in out Extended Operational Rate
3504 // set:
3505 pDstRate = ExtendedOperationalRates;
3506 if(pIes->ExtSuppRates.present)
3507 {
3508 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3509 {
3510 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
3511 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
3512 {
3513 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3514 ExtendedOperationalRatesLength++;
3515 }
3516 }
3517 }
3518 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003519 // Enable proprietary MAC features if peer node is Airgo node and STA
3520 // user wants to use them
3521 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
3522 {
3523 PropRatesEnable = 1;
3524 }
3525 else
3526 {
3527 PropRatesEnable = 0;
3528 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003529 // For ANI network companions, we need to populate the proprietary rate
3530 // set with any proprietary rates we found in the beacon, only if user
3531 // allows them...
3532 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
3533 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
3534 {
3535 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
3536 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
3537 {
3538 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
3539 }
Kiet Lam64c1b492013-07-12 13:56:44 +05303540 vos_mem_copy(ProprietaryOperationalRates,
3541 pIes->Airgo.PropSuppRates.rates,
3542 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003543 }
3544 else {
3545 // No proprietary modes...
3546 ProprietaryOperationalRatesLength = 0;
3547 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003548 /* Get MCS Rate */
3549 pDstRate = MCSRateIdxSet;
3550 if ( pIes->HTCaps.present )
3551 {
3552 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
3553 {
3554 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
3555 {
3556 MCSRateLength++;
3557 *pDstRate++ = i;
3558 }
3559 }
3560 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003561 // Set the operational rate set CFG variables...
3562 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3563 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3564 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3565 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3566 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3567 ProprietaryOperationalRates,
3568 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3569 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
3570 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
3571 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
3572 }//Parsing BSSDesc
3573 else
3574 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003575 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003576 }
3577}
3578
Jeff Johnson295189b2012-06-20 16:38:30 -07003579static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
3580 tCsrRoamProfile *pProfile )
3581{
3582 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
3583 { 8,
3584 { SIR_MAC_RATE_6,
3585 SIR_MAC_RATE_9,
3586 SIR_MAC_RATE_12,
3587 SIR_MAC_RATE_18,
3588 SIR_MAC_RATE_24,
3589 SIR_MAC_RATE_36,
3590 SIR_MAC_RATE_48,
3591 SIR_MAC_RATE_54 } } };
Jeff Johnson295189b2012-06-20 16:38:30 -07003592 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
3593 { 4,
3594 { SIR_MAC_RATE_1,
3595 SIR_MAC_RATE_2,
3596 SIR_MAC_RATE_5_5,
3597 SIR_MAC_RATE_11 } } };
3598
3599
3600 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
3601 { SIR_MAC_RATE_72,
3602 SIR_MAC_RATE_96,
3603 SIR_MAC_RATE_108 } };
3604 eCsrCfgDot11Mode cfgDot11Mode;
3605 eCsrBand eBand;
3606 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3607 tANI_U32 OperationalRatesLength = 0;
3608 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3609 tANI_U32 ExtendedOperationalRatesLength = 0;
3610 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3611 tANI_U32 ProprietaryOperationalRatesLength = 0;
3612 tANI_U32 PropRatesEnable = 0;
3613 tANI_U8 operationChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003614 if(pProfile->ChannelInfo.ChannelList)
3615 {
3616 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3617 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003618 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -07003619 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
3620 // networks, the 11b rates appear in the Operational Rate set. In either case,
3621 // we can blindly put the rates we support into our Operational Rate set
3622 // (including the basic rates, which we have already verified are supported
3623 // earlier in the roaming decision).
3624 if ( eCSR_BAND_5G == eBand )
3625 {
3626 // 11a rates into the Operational Rate Set.
3627 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3628 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303629 vos_mem_copy(OperationalRates,
3630 DefaultSupportedRates11a.supportedRateSet.rate,
3631 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003632
3633 // Nothing in the Extended rate set.
3634 ExtendedOperationalRatesLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003635 // populate proprietary rates if user allows them
3636 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3637 {
3638 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3639 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303640 vos_mem_copy(ProprietaryOperationalRates,
3641 DefaultSupportedPropRates.propRate,
3642 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003643 }
3644 else
3645 {
3646 // No proprietary modes
3647 ProprietaryOperationalRatesLength = 0;
3648 }
3649 }
3650 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
3651 {
3652 // 11b rates into the Operational Rate Set.
3653 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3654 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303655 vos_mem_copy(OperationalRates,
3656 DefaultSupportedRates11b.supportedRateSet.rate,
3657 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003658 // Nothing in the Extended rate set.
3659 ExtendedOperationalRatesLength = 0;
3660 // No proprietary modes
3661 ProprietaryOperationalRatesLength = 0;
3662 }
3663 else
3664 {
3665 // 11G
3666
3667 // 11b rates into the Operational Rate Set.
3668 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3669 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303670 vos_mem_copy(OperationalRates,
3671 DefaultSupportedRates11b.supportedRateSet.rate,
3672 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003673
3674 // 11a rates go in the Extended rate set.
3675 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3676 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303677 vos_mem_copy(ExtendedOperationalRates,
3678 DefaultSupportedRates11a.supportedRateSet.rate,
3679 ExtendedOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003680
3681 // populate proprietary rates if user allows them
3682 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3683 {
3684 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3685 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303686 vos_mem_copy(ProprietaryOperationalRates,
3687 DefaultSupportedPropRates.propRate,
3688 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003689 }
3690 else
3691 {
3692 // No proprietary modes
3693 ProprietaryOperationalRatesLength = 0;
3694 }
3695 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003696 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
3697 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
3698 {
3699 PropRatesEnable = 1;
3700 }
3701 else
3702 {
3703 PropRatesEnable = 0;
3704 }
3705
3706 // Set the operational rate set CFG variables...
3707 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3708 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3709 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3710 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3711 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3712 ProprietaryOperationalRates,
3713 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3714 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003715}
Jeff Johnson295189b2012-06-20 16:38:30 -07003716void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
3717{
3718 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07003719
Jeff Johnson295189b2012-06-20 16:38:30 -07003720 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
3721 tANI_U32 sessionId;
3722 tSmeCmd *pCommand = NULL;
3723
3724 if(NULL == pEntry)
3725 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003726 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07003727 return;
3728 }
3729 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
3730 sessionId = pCommand->sessionId;
3731
3732 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
3733 {
3734 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
3735 }
3736}
3737
Jeff Johnson295189b2012-06-20 16:38:30 -07003738//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
3739tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
3740{
3741 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
3742 {
3743 return (WNI_CFG_PHY_MODE_11B);
3744 }
3745 else
3746 {
3747 if(eCSR_BAND_24 == band)
3748 return (WNI_CFG_PHY_MODE_11G);
3749 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003750 return (WNI_CFG_PHY_MODE_11A);
3751}
Jeff Johnson295189b2012-06-20 16:38:30 -07003752
Jeff Johnsone7245742012-09-05 17:12:55 -07003753
3754#ifdef WLAN_FEATURE_11AC
3755ePhyChanBondState csrGetHTCBStateFromVHTCBState(ePhyChanBondState aniCBMode)
3756{
3757 switch ( aniCBMode )
3758 {
3759 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
3760 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
3761 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
3762 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3763 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
3764 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
3765 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
3766 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3767 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003768 default :
Jeff Johnsone7245742012-09-05 17:12:55 -07003769 return PHY_SINGLE_CHANNEL_CENTERED;
3770 }
3771}
3772#endif
3773
Jeff Johnson295189b2012-06-20 16:38:30 -07003774//pIes may be NULL
3775eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3776 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303777 tDot11fBeaconIEs *pIes, tANI_BOOLEAN resetCountry)
Jeff Johnson295189b2012-06-20 16:38:30 -07003778{
3779 eHalStatus status = eHAL_STATUS_SUCCESS;
3780 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3781 tANI_U8 channel = 0;
3782 //Make sure we have the domain info for the BSS we try to connect to.
3783 //Do we need to worry about sequence for OSs that are not Windows??
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303784 if (pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -07003785 {
Agrawal Ashish0b6984f2014-04-05 18:35:45 +05303786 if (csrLearnCountryInformation(pMac, eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07003787 {
3788 //Make sure the 11d info from this BSSDesc can be applied
3789 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303790 if (VOS_TRUE == resetCountry)
3791 {
3792 csrApplyCountryInformation(pMac, FALSE);
3793 }
3794 else
3795 {
3796 csrApplyCountryInformation(pMac, TRUE);
3797 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003798 }
Kiran4a17ebe2013-01-31 10:43:43 -08003799 if ((csrIs11dSupported (pMac)) && pIes)
3800 {
3801 if (!pIes->Country.present)
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003802 {
Kiran4a17ebe2013-01-31 10:43:43 -08003803 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE );
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003804 }
3805 else
3806 {
3807 //Let's also update the below to make sure we don't update CC while
3808 //connected to an AP which is advertising some CC
Kiet Lamf2f201e2013-11-16 21:24:16 +05303809 vos_mem_copy(pMac->scan.currentCountryBssid,
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003810 pBssDesc->bssId, sizeof(tSirMacAddr));
3811 }
Kiran4a17ebe2013-01-31 10:43:43 -08003812 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003813 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003814 //Qos
3815 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
3816 //SSID
3817 csrSetCfgSsid(pMac, &pBssConfig->SSID );
3818 //fragment threshold
3819 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3820 //RTS threshold
3821 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3822
3823 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003824 //Auth type
3825 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
3826 //encryption type
3827 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
3828 //short slot time
3829 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003830 //11d
3831 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
3832 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
3833 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003834 /*//11h
3835 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
3836 */
3837 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
3838 //CB
Jeff Johnsone7245742012-09-05 17:12:55 -07003839
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003840 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile) || CSR_IS_IBSS(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07003841 {
3842 channel = pProfile->operationChannel;
3843 }
3844 else
3845 {
3846 if(pBssDesc)
3847 {
3848 channel = pBssDesc->channelId;
3849 }
3850 }
3851 if(0 != channel)
3852 {
Sandeep Puligilla60342762014-01-30 21:05:37 +05303853 if(CSR_IS_CHANNEL_24GHZ(channel) &&
3854 !pMac->roam.configParam.channelBondingMode24GHz &&
3855 !WDA_getFwWlanFeatCaps(HT40_OBSS_SCAN))
3856 {//On 2.4 Ghz, CB will be disabled if it is not configured through .ini
Jeff Johnson295189b2012-06-20 16:38:30 -07003857 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Sandeep Puligilla60342762014-01-30 21:05:37 +05303858 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
3859 " cbMode disabled cfgCb = %d channelBondingMode24GHz %d",
3860 __func__, cfgCb, pMac->roam.configParam.channelBondingMode24GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07003861 }
3862 else
3863 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003864 cfgCb = pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003865 }
3866 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003867#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudia0d88932012-11-13 10:51:26 -08003868 // cbMode = 1 in cfg.ini is mapped to PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
3869 // in function csrConvertCBIniValueToPhyCBState()
3870 // So, max value for cbMode in 40MHz mode is 3 (MAC\src\include\sirParams.h)
3871 if(cfgCb > PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
Jeff Johnsone7245742012-09-05 17:12:55 -07003872 {
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003873 if(!WDA_getFwWlanFeatCaps(DOT11AC)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07003874 cfgCb = csrGetHTCBStateFromVHTCBState(cfgCb);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003875 }
Sandeep Puligilla60342762014-01-30 21:05:37 +05303876 else
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003877 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003878 ccmCfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, pMac->roam.configParam.nVhtChannelWidth, NULL, eANI_BOOLEAN_FALSE);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003879 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003880 }
3881 else
3882#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003883 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
3884 //Rate
3885 //Fixed Rate
3886 if(pBssDesc)
3887 {
3888 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
3889 }
3890 else
3891 {
3892 csrSetCfgRateSetFromProfile(pMac, pProfile);
3893 }
3894 //Make this the last CFG to set. The callback will trigger a join_req
3895 //Join time out
3896 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
3897
3898 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003899 return (status);
3900}
3901
Jeff Johnson295189b2012-06-20 16:38:30 -07003902eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3903 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3904{
3905 eHalStatus status;
3906 tBssConfigParam *pBssConfig;
3907 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003908
3909 if(!pSession)
3910 {
3911 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3912 return eHAL_STATUS_FAILURE;
3913 }
3914
Kiet Lam64c1b492013-07-12 13:56:44 +05303915 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
3916 if ( NULL == pBssConfig )
3917 status = eHAL_STATUS_FAILURE;
3918 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003919 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303920 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003921 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
3922 if(HAL_STATUS_SUCCESS(status))
3923 {
3924 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003925 /* This will allow to pass cbMode during join req */
3926 pSession->bssParams.cbMode= pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003927 //For IBSS, we need to prepare some more information
3928 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003929 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003930 )
3931 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003932 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07003933 }
3934 // If we are in an IBSS, then stop the IBSS...
3935 ////Not worry about WDS connection for now
3936 if ( csrIsConnStateIbss( pMac, sessionId ) )
3937 {
3938 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
3939 }
3940 else
3941 {
3942 // if we are in an Infrastructure association....
3943 if ( csrIsConnStateInfra( pMac, sessionId ) )
3944 {
3945 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
3946 // across SSIDs (roaming to a new SSID)... //
3947 //Not worry about WDS connection for now
3948 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303949 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003950 {
3951 // then we need to disassociate from the Infrastructure network...
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303952 status = csrRoamIssueDisassociate( pMac, sessionId,
3953 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07003954 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303955 else
3956 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003957 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
3958 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303959 if ( pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -07003960 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303961 // Set parameters for this Bss.
3962 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
3963 pBssDesc, pBssConfig,
3964 pIes, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003965 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303966 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003967 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303968 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003969 {
3970 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
3971 // Nothing to stop.
3972 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003973 || CSR_IS_INFRA_AP(pProfile)
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303974 )
3975 {
3976 tANI_BOOLEAN is11rRoamingFlag = eANI_BOOLEAN_FALSE;
3977 is11rRoamingFlag = csrRoamIs11rAssoc(pMac);
3978 // Set parameters for this Bss.
3979 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
3980 pBssDesc, pBssConfig,
3981 pIes, is11rRoamingFlag);
3982 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003983 }
3984 }
3985 }//Success getting BSS config info
Kiet Lam64c1b492013-07-12 13:56:44 +05303986 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -07003987 }//Allocate memory
Jeff Johnson295189b2012-06-20 16:38:30 -07003988 return (status);
3989}
3990
Jeff Johnson295189b2012-06-20 16:38:30 -07003991eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
3992 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
3993{
3994 eCsrJoinState eRoamState = eCsrContinueRoaming;
3995 eHalStatus status;
3996 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
3997 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
3998 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003999
4000 if(!pSession)
4001 {
4002 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4003 return (eCsrStopRoaming);
4004 }
4005
Jeff Johnson295189b2012-06-20 16:38:30 -07004006 if( CSR_IS_WDS_STA( pProfile ) )
4007 {
4008 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
4009 if( !HAL_STATUS_SUCCESS( status ) )
4010 {
4011 eRoamState = eCsrStopRoaming;
4012 }
4013 }
4014 else
4015 {
4016 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
4017 {
4018 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
4019 return (eCsrStopRoaming);
4020 }
4021 if ( csrIsInfraBssDesc( pBssDesc ) )
4022 {
4023 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
4024 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
4025 // have changed and handle the changes (without disturbing the current association).
4026
4027 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
4028 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
4029 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
4030 )
4031 {
4032 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
4033 // with Authenticating first. To force this, stop the current association (Disassociate) and
4034 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
4035 // a new Association.
4036 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4037 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07004038 smsLog(pMac, LOGW, FL(" detect same profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004039 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
4040 {
4041 eRoamState = eCsrReassocToSelfNoCapChange;
4042 }
4043 else
4044 {
4045 tBssConfigParam bssConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004046 //The key changes
Kiet Lam64c1b492013-07-12 13:56:44 +05304047 vos_mem_set(&bssConfig, sizeof(bssConfig), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004048 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
4049 if(HAL_STATUS_SUCCESS(status))
4050 {
4051 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07004052 pSession->bssParams.cbMode = bssConfig.cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004053 //Reapply the config including Keys so reassoc is happening.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304054 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4055 pBssDesc, &bssConfig,
4056 pIesLocal, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004057 if(!HAL_STATUS_SUCCESS(status))
4058 {
4059 eRoamState = eCsrStopRoaming;
4060 }
4061 }
4062 else
4063 {
4064 eRoamState = eCsrStopRoaming;
4065 }
4066 }//same profile
4067 }
4068 else
4069 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304070 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004071 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
4072 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05304073 smsLog(pMac, LOGE, FL(" fail to issue disassociate with Session ID %d"),
4074 sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004075 eRoamState = eCsrStopRoaming;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304076 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004077 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304078 }
4079 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004080 {
4081 // 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 +05304082 // we had a lot of join timeouts when testing at Samsung. removing this step helped associations
Jeff Johnson295189b2012-06-20 16:38:30 -07004083 // work much better.
4084 //
4085 //
4086 // stop the existing network before attempting to join the new network...
4087 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4088 {
4089 eRoamState = eCsrStopRoaming;
4090 }
4091 }
4092 }//Infra
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304093 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004094 {
4095 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4096 {
4097 eRoamState = eCsrStopRoaming;
4098 }
4099 }
4100 if( pIesLocal && !pScanResult->pvIes )
4101 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304102 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004103 }
4104 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004105 return( eRoamState );
4106}
4107
Jeff Johnson295189b2012-06-20 16:38:30 -07004108eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
4109 tSirBssDescription *pBssDesc, tANI_U32 roamId)
4110{
4111 eHalStatus status = eHAL_STATUS_SUCCESS;
4112 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05304113 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004114 roamInfo.pBssDesc = pBssDesc;
4115 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
4116 return (status);
4117}
Jeff Johnson295189b2012-06-20 16:38:30 -07004118//In case no matching BSS is found, use whatever default we can find
4119static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4120{
4121 //Need to get all negotiated types in place first
4122 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08004123 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07004124 {
4125 default:
4126 case eCSR_AUTH_TYPE_WPA:
4127 case eCSR_AUTH_TYPE_WPA_PSK:
4128 case eCSR_AUTH_TYPE_WPA_NONE:
4129 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4130 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4131 break;
4132
4133 case eCSR_AUTH_TYPE_SHARED_KEY:
4134 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
4135 break;
4136
4137 case eCSR_AUTH_TYPE_AUTOSWITCH:
4138 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
4139 break;
4140 }
4141 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4142 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4143 //In this case, the multicast encryption needs to follow the uncast ones.
4144 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4145 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4146}
4147
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004148
4149static void csrSetAbortRoamingCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4150{
4151 switch(pCommand->u.roamCmd.roamReason)
4152 {
4153 case eCsrLostLink1:
4154 pCommand->u.roamCmd.roamReason = eCsrLostLink1Abort;
4155 break;
4156 case eCsrLostLink2:
4157 pCommand->u.roamCmd.roamReason = eCsrLostLink2Abort;
4158 break;
4159 case eCsrLostLink3:
4160 pCommand->u.roamCmd.roamReason = eCsrLostLink3Abort;
4161 break;
4162 default:
4163 smsLog(pMac, LOGE, FL(" aborting roaming reason %d not recognized"),
4164 pCommand->u.roamCmd.roamReason);
4165 break;
4166 }
4167}
4168
Jeff Johnson295189b2012-06-20 16:38:30 -07004169static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
4170{
4171 eHalStatus status;
4172 tCsrScanResult *pScanResult = NULL;
4173 eCsrJoinState eRoamState = eCsrStopRoaming;
4174 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
4175 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
4176 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
4177#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4178 v_U8_t acm_mask = 0;
4179#endif
4180 tANI_U32 sessionId = pCommand->sessionId;
4181 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4182 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4183 tANI_U8 concurrentChannel = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004184
4185 if(!pSession)
4186 {
4187 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4188 return (eCsrStopRoaming);
4189 }
4190
Jeff Johnson295189b2012-06-20 16:38:30 -07004191 do
4192 {
4193 // Check for Cardbus eject condition, before trying to Roam to any BSS
4194 //***if( !balIsCardPresent(pAdapter) ) break;
4195
Kiet Lam64c1b492013-07-12 13:56:44 +05304196 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004197 memcpy (&roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004198 if(NULL != pBSSList)
4199 {
4200 // When handling AP's capability change, continue to associate to
4201 // same BSS and make sure pRoamBssEntry is not Null.
4202 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
4203 {
4204 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
4205 {
4206 //Try the first BSS
4207 pCommand->u.roamCmd.pLastRoamBss = NULL;
4208 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
4209 }
4210 else
4211 {
4212 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4213 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4214 {
4215 //Done with all the BSSs
4216 //In this case, will tell HDD the completion
4217 break;
4218 }
4219 else
4220 {
4221 //We need to indicate to HDD that we are done with this one.
Kiet Lam64c1b492013-07-12 13:56:44 +05304222 //vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004223 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
4224 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4225 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4226 pRoamInfo = &roamInfo;
4227 }
4228 }
4229 while(pCommand->u.roamCmd.pRoamBssEntry)
4230 {
4231 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Jeff Johnson295189b2012-06-20 16:38:30 -07004232 /*If concurrency enabled take the concurrent connected channel first. */
4233 /* Valid multichannel concurrent sessions exempted */
Jeff Johnsone7245742012-09-05 17:12:55 -07004234 if (vos_concurrent_sessions_running() &&
4235 !csrIsValidMcConcurrentSession(pMac, sessionId, &pScanResult->Result.BssDescriptor))
Jeff Johnson295189b2012-06-20 16:38:30 -07004236 {
4237 concurrentChannel =
4238 csrGetConcurrentOperationChannel(pMac);
4239 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004240 " csr Concurrent Channel = %d", __func__, concurrentChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07004241 if ((concurrentChannel) &&
4242 (concurrentChannel ==
4243 pScanResult->Result.BssDescriptor.channelId))
4244 {
4245 //make this 0 because we do not want the
4246 //below check to pass as we don't want to
4247 //connect on other channel
4248 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4249 FL("Concurrent channel match =%d"),
4250 concurrentChannel);
4251 concurrentChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004252 }
4253 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004254
4255 if (!concurrentChannel)
4256 {
4257
4258 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
4259 sessionId, &pScanResult->Result.BssDescriptor,
4260 pCommand->u.roamCmd.roamId)))
4261 {
4262 //Ok to roam this
4263 break;
4264 }
4265 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004266 else
4267 {
4268 eRoamState = eCsrStopRoamingDueToConcurrency;
4269 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004270 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4271 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4272 {
4273 //Done with all the BSSs
4274 fDone = eANI_BOOLEAN_TRUE;
4275 break;
4276 }
4277 }
4278 if(fDone)
4279 {
4280 break;
4281 }
4282 }
4283 }
4284 //We have something to roam, tell HDD when it is infra.
4285 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
4286 //For WDS, the indication is eCSR_ROAM_WDS_IND
4287 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4288 {
4289 if(pRoamInfo)
4290 {
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004291 if(pSession->bRefAssocStartCnt)
4292 {
4293 pSession->bRefAssocStartCnt--;
4294 //Complete the last association attemp because a new one is about to be tried
4295 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4296 eCSR_ROAM_ASSOCIATION_COMPLETION,
Jeff Johnson295189b2012-06-20 16:38:30 -07004297 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004298 }
4299 }
4300 /* If the roaming has stopped, not to continue the roaming command*/
4301 if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
4302 {
4303 //No need to complete roaming here as it already completes
4304 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed"),
4305 pCommand->u.roamCmd.roamReason);
4306 eRoamState = eCsrStopRoaming;
4307 csrSetAbortRoamingCommand(pMac, pCommand);
4308 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004309 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304310 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004311 if(pScanResult)
4312 {
4313 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07004314 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
4315 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004316 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004317 fDone = eANI_BOOLEAN_TRUE;
4318 eRoamState = eCsrStopRoaming;
4319 break;
4320 }
4321 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
4322 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
4323 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
4324 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
4325 CSR_IS_QOS_BSS(pIesLocal) &&
4326 CSR_IS_UAPSD_BSS(pIesLocal) )
4327 {
4328#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Jeff Johnson295189b2012-06-20 16:38:30 -07004329 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
4330 pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004331#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004332 }
4333 else
4334 {
4335 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4336 }
4337 if( pIesLocal && !pScanResult->Result.pvIes)
4338 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304339 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004340 }
4341 }
4342 else
4343 {
4344 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4345 }
4346 roamInfo.pProfile = pProfile;
4347 pSession->bRefAssocStartCnt++;
4348 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4349 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4350 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004351 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
4352 {
4353 // If this is a start IBSS profile, then we need to start the IBSS.
4354 if ( CSR_IS_START_IBSS(pProfile) )
4355 {
4356 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004357 // Attempt to start this IBSS...
4358 csrRoamAssignDefaultParam( pMac, pCommand );
4359 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
4360 if(HAL_STATUS_SUCCESS(status))
4361 {
4362 if ( fSameIbss )
4363 {
4364 eRoamState = eCsrStartIbssSameIbss;
4365 }
4366 else
4367 {
4368 eRoamState = eCsrContinueRoaming;
4369 }
4370 }
4371 else
4372 {
4373 //it somehow fail need to stop
4374 eRoamState = eCsrStopRoaming;
4375 }
4376 break;
4377 }
4378 else if ( (CSR_IS_WDS_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004379 || (CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004380 )
4381 {
4382 // Attempt to start this WDS...
4383 csrRoamAssignDefaultParam( pMac, pCommand );
4384 /* For AP WDS, we dont have any BSSDescription */
4385 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
4386 if(HAL_STATUS_SUCCESS(status))
4387 {
4388 eRoamState = eCsrContinueRoaming;
4389 }
4390 else
4391 {
4392 //it somehow fail need to stop
4393 eRoamState = eCsrStopRoaming;
4394 }
4395 }
4396 else
4397 {
4398 //Nothing we can do
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004399 smsLog(pMac, LOGW, FL("cannot continue without BSS list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004400 eRoamState = eCsrStopRoaming;
4401 break;
4402 }
4403 }
4404 else //We have BSS
4405 {
4406 //Need to assign these value because they are used in csrIsSameProfile
4407 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4408 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType = pScanResult->ucEncryptionType; //Negotiated while building scan result.
4409 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType = pScanResult->mcEncryptionType;
4410 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
4411 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
4412 {
4413 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4414 {
4415 eRoamState = eCsrStartIbssSameIbss;
4416 break;
4417 }
4418 }
4419 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
4420 {
4421 //trying to connect to the one already connected
4422 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
4423 eRoamState = eCsrReassocToSelfNoCapChange;
4424 break;
4425 }
4426 // Attempt to Join this Bss...
4427 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
4428 break;
4429 }
4430
4431 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004432 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
4433 {
4434 //Need to indicate association_completion if association_start has been done
4435 if(pSession->bRefAssocStartCnt > 0)
4436 {
4437 pSession->bRefAssocStartCnt--;
4438 //Complete the last association attemp because a new one is about to be tried
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004439 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07004440 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4441 eCSR_ROAM_ASSOCIATION_COMPLETION,
4442 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4443 }
4444 }
4445
4446 return( eRoamState );
4447}
4448
Jeff Johnson295189b2012-06-20 16:38:30 -07004449static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4450{
4451 eHalStatus status = eHAL_STATUS_SUCCESS;
4452 eCsrJoinState RoamState;
4453 tANI_U32 sessionId = pCommand->sessionId;
4454
Jeff Johnson295189b2012-06-20 16:38:30 -07004455 //***if( hddIsRadioStateOn( pAdapter ) )
4456 {
4457 // Attept to join a Bss...
4458 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07004459
Jeff Johnson295189b2012-06-20 16:38:30 -07004460 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07004461 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004462 {
4463 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004464 // and if connected in Infrastructure mode...
4465 if ( csrIsConnStateInfra(pMac, sessionId) )
4466 {
4467 //... then we need to issue a disassociation
4468 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
4469 if(!HAL_STATUS_SUCCESS(status))
4470 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004471 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004472 //roam command is completed by caller in the failed case
4473 fComplete = eANI_BOOLEAN_TRUE;
4474 }
4475 }
4476 else if( csrIsConnStateIbss(pMac, sessionId) )
4477 {
4478 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4479 if(!HAL_STATUS_SUCCESS(status))
4480 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004481 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004482 //roam command is completed by caller in the failed case
4483 fComplete = eANI_BOOLEAN_TRUE;
4484 }
4485 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004486 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
4487 {
4488 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4489 if(!HAL_STATUS_SUCCESS(status))
4490 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004491 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004492 //roam command is completed by caller in the failed case
4493 fComplete = eANI_BOOLEAN_TRUE;
4494 }
4495 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004496 else
4497 {
4498 fComplete = eANI_BOOLEAN_TRUE;
4499 }
4500 if(fComplete)
4501 {
4502 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07004503 if(eCsrStopRoamingDueToConcurrency == RoamState)
4504 {
4505 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
4506 }
4507 else
4508 {
4509 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
4510 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004511 }
4512 }
4513 else if ( eCsrReassocToSelfNoCapChange == RoamState )
4514 {
4515 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
4516 }
4517 else if ( eCsrStartIbssSameIbss == RoamState )
4518 {
4519 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
4520 }
4521 }//hddIsRadioStateOn
4522
4523 return status;
4524}
Jeff Johnson295189b2012-06-20 16:38:30 -07004525eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4526{
4527 tANI_U32 sessionId;
4528 tCsrRoamSession *pSession;
4529 tCsrScanResult *pScanResult = NULL;
4530 tSirBssDescription *pBssDesc = NULL;
4531 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004532 sessionId = pCommand->sessionId;
4533 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004534
4535 if(!pSession)
4536 {
4537 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4538 return eHAL_STATUS_FAILURE;
4539 }
4540
Jeff Johnson295189b2012-06-20 16:38:30 -07004541 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
4542 {
4543 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004544 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004545 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4546 return eHAL_STATUS_FAILURE;
4547 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004548 if (pCommand->u.roamCmd.pRoamBssEntry)
4549 {
4550 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4551 pBssDesc = &pScanResult->Result.BssDescriptor;
4552 }
4553 else
4554 {
4555 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004556 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004557 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4558 return eHAL_STATUS_FAILURE;
4559 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004560 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
4561 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
4562 return status;
4563}
4564
Jeff Johnson295189b2012-06-20 16:38:30 -07004565eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4566{
4567 eHalStatus status = eHAL_STATUS_SUCCESS;
4568 tCsrRoamInfo roamInfo;
4569 tANI_U32 sessionId = pCommand->sessionId;
4570 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004571
4572 if(!pSession)
4573 {
4574 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4575 return eHAL_STATUS_FAILURE;
4576 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004577
4578 switch ( pCommand->u.roamCmd.roamReason )
4579 {
4580 case eCsrForcedDisassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07004581 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004582 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004583 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004584 case eCsrSmeIssuedDisassocForHandoff:
4585 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
4586#if 0 // TODO : Confirm this change
4587 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
4588#else
4589 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4590#endif
4591
4592 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004593 case eCsrForcedDisassocMICFailure:
Jeff Johnson295189b2012-06-20 16:38:30 -07004594 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004595 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004596 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004597 case eCsrForcedDeauth:
Jeff Johnson295189b2012-06-20 16:38:30 -07004598 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004599 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004600 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004601 case eCsrHddIssuedReassocToSameAP:
4602 case eCsrSmeIssuedReassocToSameAP:
4603 {
4604 tDot11fBeaconIEs *pIes = NULL;
4605
Jeff Johnson295189b2012-06-20 16:38:30 -07004606 if( pSession->pConnectBssDesc )
4607 {
4608 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
4609 if(!HAL_STATUS_SUCCESS(status) )
4610 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004611 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004612 }
4613 else
4614 {
4615 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
4616 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
4617 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07004618 roamInfo.pBssDesc = pSession->pConnectBssDesc;
4619 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
4620 pSession->bRefAssocStartCnt++;
4621 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4622 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4623
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004624 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004625 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
4626 &pCommand->u.roamCmd.roamProfile );
4627 if(!HAL_STATUS_SUCCESS(status))
4628 {
4629 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08004630 csrReleaseCommandRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004631 }
4632
Kiet Lam64c1b492013-07-12 13:56:44 +05304633 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07004634 pIes = NULL;
4635 }
4636 }
4637 break;
4638 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004639 case eCsrCapsChange:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004640 smsLog(pMac, LOGE, FL("received eCsrCapsChange "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004641 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4642 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
4643 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004644 case eCsrSmeIssuedFTReassoc:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004645 smsLog(pMac, LOG1, FL("received FT Reassoc Req "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004646 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
4647 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07004648
Jeff Johnson295189b2012-06-20 16:38:30 -07004649 case eCsrStopBss:
4650 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4651 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4652 break;
4653
4654 case eCsrForcedDisassocSta:
4655 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4656 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
4657 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4658 pCommand->u.roamCmd.reason);
4659 break;
4660
4661 case eCsrForcedDeauthSta:
4662 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4663 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
4664 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4665 pCommand->u.roamCmd.reason);
4666 break;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004667
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004668 case eCsrPerformPreauth:
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08004669 smsLog(pMac, LOG1, FL("Attempting FT PreAuth Req"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004670 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
4671 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004672 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004673
4674 default:
4675 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4676
4677 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
4678 {
4679 //Remember the roaming profile
4680 csrFreeRoamProfile(pMac, sessionId);
Kiet Lam64c1b492013-07-12 13:56:44 +05304681 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
4682 if ( NULL != pSession->pCurRoamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004683 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304684 vos_mem_set(pSession->pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004685 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
4686 }
4687 }
4688
4689 //At this point, original uapsd_mask is saved in pCurRoamProfile
4690 //uapsd_mask in the pCommand may change from this point on.
4691
4692 // Attempt to roam with the new scan results (if we need to..)
4693 status = csrRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004694 if(!HAL_STATUS_SUCCESS(status))
4695 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004696 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X"), status);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004697 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004698 break;
4699 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004700 return (status);
4701}
4702
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004703void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4704{
4705 pCommand->u.roamCmd.pLastRoamBss = NULL;
4706 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4707 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05304708 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004709}
4710
Jeff Johnson295189b2012-06-20 16:38:30 -07004711void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4712{
4713 if(pCommand->u.roamCmd.fReleaseBssList)
4714 {
4715 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
4716 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
4717 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
4718 }
4719 if(pCommand->u.roamCmd.fReleaseProfile)
4720 {
4721 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
4722 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
4723 }
4724 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4725 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05304726 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004727}
4728
Jeff Johnson295189b2012-06-20 16:38:30 -07004729void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4730{
Kiet Lam64c1b492013-07-12 13:56:44 +05304731 vos_mem_set(&pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004732}
Jeff Johnson295189b2012-06-20 16:38:30 -07004733void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
4734{
4735 tListElem *pEntry;
4736 tSmeCmd *pCommand;
4737 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004738 smsLog( pMac, LOG2, "Roam Completion ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004739 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
4740 if ( pEntry )
4741 {
4742 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07004743 // If the head of the queue is Active and it is a ROAM command, remove
4744 // and put this on the Free queue.
4745 if ( eSmeCommandRoam == pCommand->command )
4746 {
4747 //we need to process the result first before removing it from active list because state changes
4748 //still happening insides roamQProcessRoamResults so no other roam command should be issued
4749 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
4750 if( fReleaseCommand )
4751 {
4752 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
4753 {
4754 csrReleaseCommandRoam( pMac, pCommand );
4755 }
4756 else
4757 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004758 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004759 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004760 }
4761 }
4762 else
4763 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004764 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004765 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004766 }
4767 }
4768 else
4769 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004770 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004771 }
4772 }
4773 else
4774 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004775 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004776 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004777 if( fReleaseCommand )
4778 {
4779 smeProcessPendingQueue( pMac );
4780 }
4781}
4782
Jeff Johnson295189b2012-06-20 16:38:30 -07004783void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4784{
4785 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004786 if(!pSession)
4787 {
4788 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4789 return;
4790 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304791 vos_mem_set(&(pSession->PmkidCandidateInfo[0]),
4792 sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004793 pSession->NumPmkidCandidate = 0;
4794}
Jeff Johnson295189b2012-06-20 16:38:30 -07004795#ifdef FEATURE_WLAN_WAPI
4796void csrResetBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4797{
4798 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004799 if(!pSession)
4800 {
4801 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4802 return;
4803 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304804 vos_mem_set(&(pSession->BkidCandidateInfo[0]),
4805 sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004806 pSession->NumBkidCandidate = 0;
4807}
4808#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004809extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
4810
Jeff Johnson295189b2012-06-20 16:38:30 -07004811static eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrAuthType authType,
4812 tSirBssDescription *pSirBssDesc,
4813 tDot11fBeaconIEs *pIes)
4814{
4815 eHalStatus status = eHAL_STATUS_SUCCESS;
4816 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4817 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004818
4819 if(!pSession)
4820 {
4821 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4822 return eHAL_STATUS_FAILURE;
4823 }
4824
Jeff Johnson295189b2012-06-20 16:38:30 -07004825 if((eCSR_AUTH_TYPE_WPA == authType) ||
4826 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
4827 (eCSR_AUTH_TYPE_RSN == authType) ||
4828 (eCSR_AUTH_TYPE_RSN_PSK == authType)
4829#if defined WLAN_FEATURE_VOWIFI_11R
4830 ||
4831 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4832 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
4833#endif /* FEATURE_WLAN_WAPI */
4834#ifdef FEATURE_WLAN_WAPI
4835 ||
4836 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4837 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
4838#endif /* FEATURE_WLAN_WAPI */
Chet Lanctot186b5732013-03-18 10:26:30 -07004839#ifdef WLAN_FEATURE_11W
4840 ||
4841 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType)
4842#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004843 )
4844 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004845 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4846 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004847 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004848 }
4849 if( pIesLocal )
4850 {
4851 tANI_U32 nIeLen;
4852 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07004853 if((eCSR_AUTH_TYPE_RSN == authType) ||
4854#if defined WLAN_FEATURE_VOWIFI_11R
4855 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4856 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
4857#endif /* WLAN_FEATURE_VOWIFI_11R */
Chet Lanctot186b5732013-03-18 10:26:30 -07004858#if defined WLAN_FEATURE_11W
4859 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
4860#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004861 (eCSR_AUTH_TYPE_RSN_PSK == authType))
4862 {
4863 if(pIesLocal->RSN.present)
4864 {
4865 //Calculate the actual length
4866 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
4867 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
4868 + 2 //akm_suite_count
4869 + pIesLocal->RSN.akm_suite_count * 4 //akm_suites
4870 + 2; //reserved
4871 if( pIesLocal->RSN.pmkid_count )
4872 {
4873 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
4874 }
4875 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304876 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
4877 if (NULL == pSession->pWpaRsnRspIE)
4878 status = eHAL_STATUS_FAILURE;
4879 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004880 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304881 vos_mem_set(pSession->pWpaRsnRspIE, nIeLen + 2, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004882 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
4883 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4884 //copy upto akm_suites
4885 pIeBuf = pSession->pWpaRsnRspIE + 2;
Kiet Lam64c1b492013-07-12 13:56:44 +05304886 vos_mem_copy(pIeBuf, &pIesLocal->RSN.version,
4887 sizeof(pIesLocal->RSN.version));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004888 pIeBuf += sizeof(pIesLocal->RSN.version);
Kiet Lam64c1b492013-07-12 13:56:44 +05304889 vos_mem_copy(pIeBuf, &pIesLocal->RSN.gp_cipher_suite,
4890 sizeof(pIesLocal->RSN.gp_cipher_suite));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004891 pIeBuf += sizeof(pIesLocal->RSN.gp_cipher_suite);
Kiet Lam64c1b492013-07-12 13:56:44 +05304892 vos_mem_copy(pIeBuf, &pIesLocal->RSN.pwise_cipher_suite_count,
4893 sizeof(pIesLocal->RSN.pwise_cipher_suite_count));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004894 pIeBuf += sizeof(pIesLocal->RSN.pwise_cipher_suite_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07004895 if( pIesLocal->RSN.pwise_cipher_suite_count )
4896 {
4897 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304898 vos_mem_copy(pIeBuf,
4899 pIesLocal->RSN.pwise_cipher_suites,
4900 pIesLocal->RSN.pwise_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004901 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
4902 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304903 vos_mem_copy(pIeBuf, &pIesLocal->RSN.akm_suite_count, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004904 pIeBuf += 2;
4905 if( pIesLocal->RSN.akm_suite_count )
4906 {
4907 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304908 vos_mem_copy(pIeBuf,
4909 pIesLocal->RSN.akm_suites,
4910 pIesLocal->RSN.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004911 pIeBuf += pIesLocal->RSN.akm_suite_count * 4;
4912 }
4913 //copy the rest
Kiet Lam64c1b492013-07-12 13:56:44 +05304914 vos_mem_copy(pIeBuf,
4915 pIesLocal->RSN.akm_suites + pIesLocal->RSN.akm_suite_count * 4,
4916 2 + pIesLocal->RSN.pmkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004917 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4918 }
4919 }
4920 }
4921 else if((eCSR_AUTH_TYPE_WPA == authType) ||
4922 (eCSR_AUTH_TYPE_WPA_PSK == authType))
4923 {
4924 if(pIesLocal->WPA.present)
4925 {
4926 //Calculate the actual length
4927 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
4928 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
4929 + 2 //auth_suite_count
4930 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
4931 // The WPA capabilities follows the Auth Suite (two octects)--
4932 // this field is optional, and we always "send" zero, so just
4933 // remove it. This is consistent with our assumptions in the
4934 // frames compiler; c.f. bug 15234:
4935 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304936
4937 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
4938 if ( NULL == pSession->pWpaRsnRspIE )
4939 status = eHAL_STATUS_FAILURE;
4940 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004941 {
4942 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
4943 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4944 pIeBuf = pSession->pWpaRsnRspIE + 2;
4945 //Copy WPA OUI
Kiet Lam64c1b492013-07-12 13:56:44 +05304946 vos_mem_copy(pIeBuf, &csrWpaOui[1], 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004947 pIeBuf += 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05304948 vos_mem_copy(pIeBuf, &pIesLocal->WPA.version,
4949 8 + pIesLocal->WPA.unicast_cipher_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004950 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05304951 vos_mem_copy(pIeBuf, &pIesLocal->WPA.auth_suite_count,
4952 2 + pIesLocal->WPA.auth_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004953 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
4954 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4955 }
4956 }
4957 }
4958#ifdef FEATURE_WLAN_WAPI
4959 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4960 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
4961 {
4962 if(pIesLocal->WAPI.present)
4963 {
4964 //Calculate the actual length
4965 nIeLen = 4 //version + akm_suite_count
4966 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
4967 + 2 //pwise_cipher_suite_count
4968 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
4969 + 6; //gp_cipher_suite + preauth + reserved
4970 if( pIesLocal->WAPI.bkid_count )
4971 {
4972 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
4973 }
4974
4975 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304976 pSession->pWapiRspIE = vos_mem_malloc(nIeLen + 2);
4977 if ( NULL == pSession->pWapiRspIE )
4978 status = eHAL_STATUS_FAILURE;
4979 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004980 {
4981 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
4982 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
4983 pIeBuf = pSession->pWapiRspIE + 2;
4984 //copy upto akm_suite_count
Kiet Lam64c1b492013-07-12 13:56:44 +05304985 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.version, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004986 pIeBuf += 4;
4987 if( pIesLocal->WAPI.akm_suite_count )
4988 {
4989 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304990 vos_mem_copy(pIeBuf, pIesLocal->WAPI.akm_suites,
4991 pIesLocal->WAPI.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004992 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05304993 }
4994 vos_mem_copy(pIeBuf,
4995 &pIesLocal->WAPI.unicast_cipher_suite_count,
4996 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004997 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07004998 if( pIesLocal->WAPI.unicast_cipher_suite_count )
4999 {
5000 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305001 vos_mem_copy( pIeBuf,
5002 pIesLocal->WAPI.unicast_cipher_suites,
5003 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005004 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
5005 }
lukez3c809222013-05-03 10:23:02 -07005006 //gp_cipher_suite
Kiet Lam64c1b492013-07-12 13:56:44 +05305007 vos_mem_copy(pIeBuf,
5008 pIesLocal->WAPI.multicast_cipher_suite,
5009 4);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005010 pIeBuf += 4;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305011 //preauth + reserved
Kiet Lam64c1b492013-07-12 13:56:44 +05305012 vos_mem_copy(pIeBuf,
5013 pIesLocal->WAPI.multicast_cipher_suite + 4,
5014 2);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005015 pIeBuf += 2;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305016 //bkid_count
Kiet Lam64c1b492013-07-12 13:56:44 +05305017 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.bkid_count, 2);
5018
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005019 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005020 if( pIesLocal->WAPI.bkid_count )
5021 {
5022 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305023 vos_mem_copy(pIeBuf, pIesLocal->WAPI.bkid,
5024 pIesLocal->WAPI.bkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005025 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
5026 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305027 pSession->nWapiRspIeLength = nIeLen + 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005028 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005029 }
5030 }
5031#endif /* FEATURE_WLAN_WAPI */
5032 if( !pIes )
5033 {
5034 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05305035 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07005036 }
5037 }
5038 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005039 return (status);
5040}
5041
Jeff Johnson295189b2012-06-20 16:38:30 -07005042static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
5043{
5044 v_U8_t bACWeights[WLANTL_MAX_AC];
5045 v_U8_t paramBk, paramBe, paramVi, paramVo;
5046 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005047 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
5048 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
5049 //of the higher AC one, make the higher AC has the same weight as the lower AC.
5050 //This doesn't address the case where the lower AC needs a real higher weight
5051 if( pIEs->WMMParams.present )
5052 {
5053 //no change to the lowest ones
5054 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
5055 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
5056 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
5057 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
5058 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
5059 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
5060 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
5061 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
5062 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
5063 {
5064 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
5065 fWeightChange = VOS_TRUE;
5066 }
5067 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
5068 {
5069 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
5070 fWeightChange = VOS_TRUE;
5071 }
5072 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
5073 {
5074 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
5075 fWeightChange = VOS_TRUE;
5076 }
5077 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
5078 {
5079 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
5080 fWeightChange = VOS_TRUE;
5081 }
5082 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
5083 {
5084 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
5085 fWeightChange = VOS_TRUE;
5086 }
5087 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
5088 {
5089 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
5090 fWeightChange = VOS_TRUE;
5091 }
5092 if(fWeightChange)
5093 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005094 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)"), bACWeights[0], bACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07005095 bACWeights[2], bACWeights[3]);
5096 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
5097 }
5098 }
5099}
Jeff Johnson295189b2012-06-20 16:38:30 -07005100#ifdef WLAN_FEATURE_VOWIFI_11R
5101//Returns whether the current association is a 11r assoc or not
5102tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
5103{
5104#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5105 return csrNeighborRoamIs11rAssoc(pMac);
5106#else
5107 return eANI_BOOLEAN_FALSE;
5108#endif
5109}
5110#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005111#ifdef FEATURE_WLAN_ESE
5112//Returns whether the current association is a ESE assoc or not
5113tANI_BOOLEAN csrRoamIsESEAssoc(tpAniSirGlobal pMac)
Jeff Johnson295189b2012-06-20 16:38:30 -07005114{
5115#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005116 return csrNeighborRoamIsESEAssoc(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07005117#else
5118 return eANI_BOOLEAN_FALSE;
5119#endif
5120}
5121#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005122#ifdef FEATURE_WLAN_LFR
5123//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305124tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005125{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305126 tCsrRoamSession *pSession = NULL;
5127
5128 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
5129 {
5130 pSession = CSR_GET_SESSION( pMac, sessionId );
5131 if (NULL != pSession->pCurRoamProfile)
5132 {
5133 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
5134 {
5135 return eANI_BOOLEAN_FALSE;
5136 }
5137 }
5138 }
5139
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005140#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5141 if (eANI_BOOLEAN_TRUE == CSR_IS_FASTROAM_IN_CONCURRENCY_INI_FEATURE_ENABLED(pMac))
5142 {
5143 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled);
5144 }
5145 else
5146#endif
5147 {
5148 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07005149 (!csrIsConcurrentSessionRunning(pMac)));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005150 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005151}
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005152
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005153#ifdef FEATURE_WLAN_ESE
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005154/* ---------------------------------------------------------------------------
5155
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005156 \fn csrNeighborRoamIsESEAssoc
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005157
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005158 \brief This function returns whether the current association is a ESE assoc or not
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005159
5160 \param pMac - The handle returned by macOpen.
5161
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005162 \return eANI_BOOLEAN_TRUE if current assoc is ESE, eANI_BOOLEAN_FALSE otherwise
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005163
5164---------------------------------------------------------------------------*/
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005165tANI_BOOLEAN csrNeighborRoamIsESEAssoc(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005166{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005167 return pMac->roam.neighborRoamInfo.isESEAssoc;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005168}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005169#endif /* FEATURE_WLAN_ESE */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005170
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005171#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5172//Returns whether "FW based BG scan" is currently enabled...or not
5173tANI_BOOLEAN csrRoamIsRoamOffloadScanEnabled(tpAniSirGlobal pMac)
5174{
5175 return (pMac->roam.configParam.isRoamOffloadScanEnabled);
5176}
5177#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005178#endif
5179
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005180#if defined(FEATURE_WLAN_ESE)
5181tANI_BOOLEAN csrRoamIsEseIniFeatureEnabled(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005182{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005183 return pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005184}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005185#endif /*FEATURE_WLAN_ESE*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005186
Jeff Johnson295189b2012-06-20 16:38:30 -07005187//Return true means the command can be release, else not
5188static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
5189 eCsrRoamCompleteResult Result, void *Context )
5190{
5191 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
5192 tSirBssDescription *pSirBssDesc = NULL;
5193 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
5194 tCsrScanResult *pScanResult = NULL;
5195 tCsrRoamInfo roamInfo;
5196 sme_QosAssocInfo assocInfo;
5197 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
5198 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
5199 tDot11fBeaconIEs *pIes = NULL;
5200 tANI_U32 sessionId = pCommand->sessionId;
5201 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5202 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
5203 eRoamCmdStatus roamStatus;
5204 eCsrRoamResult roamResult;
5205 eHalStatus status;
5206 tANI_U32 key_timeout_interval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005207 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005208
Jeff Johnson32d95a32012-09-10 13:15:23 -07005209 if(!pSession)
5210 {
5211 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5212 return eANI_BOOLEAN_FALSE;
5213 }
5214
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005215 smsLog( pMac, LOG1, FL("Processing ROAM results..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07005216 switch( Result )
5217 {
5218 case eCsrJoinSuccess:
5219 // reset the IDLE timer
5220 // !!
5221 // !! fall through to the next CASE statement here is intentional !!
5222 // !!
5223 case eCsrReassocSuccess:
5224 if(eCsrReassocSuccess == Result)
5225 {
5226 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
5227 }
5228 else
5229 {
5230 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
5231 }
5232 // Success Join Response from LIM. Tell NDIS we are connected and save the
5233 // Connected state...
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005234 smsLog(pMac, LOGW, FL("receives association indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305235 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005236 //always free the memory here
5237 if(pSession->pWpaRsnRspIE)
5238 {
5239 pSession->nWpaRsnRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305240 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005241 pSession->pWpaRsnRspIE = NULL;
5242 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005243#ifdef FEATURE_WLAN_WAPI
5244 if(pSession->pWapiRspIE)
5245 {
5246 pSession->nWapiRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305247 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005248 pSession->pWapiRspIE = NULL;
5249 }
5250#endif /* FEATURE_WLAN_WAPI */
5251#ifdef FEATURE_WLAN_BTAMP_UT_RF
5252 //Reset counter so no join retry is needed.
5253 pSession->maxRetryCount = 0;
5254 csrRoamStopJoinRetryTimer(pMac, sessionId);
5255#endif
5256 /* This creates problem since we have not saved the connected profile.
5257 So moving this after saving the profile
5258 */
5259 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
Abhishek Singh36abbcb2014-03-20 13:04:09 +05305260
5261 /* Reset remainInPowerActiveTillDHCP as it might have been set
5262 * by last failed secured connection.
5263 * It should be set only for secured connection.
5264 */
5265 pMac->pmc.remainInPowerActiveTillDHCP = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005266 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
5267 {
5268 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
5269 }
5270 else
5271 {
5272 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
5273 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005274 //Use the last connected bssdesc for reassoc-ing to the same AP.
5275 //NOTE: What to do when reassoc to a different AP???
5276 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5277 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5278 {
5279 pSirBssDesc = pSession->pConnectBssDesc;
5280 if(pSirBssDesc)
5281 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305282 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5283 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005284 }
5285 }
5286 else
5287 {
5288
5289 if(pCommand->u.roamCmd.pRoamBssEntry)
5290 {
5291 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
5292 if(pScanResult != NULL)
5293 {
5294 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5295 //this can be NULL
5296 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
Kiet Lam64c1b492013-07-12 13:56:44 +05305297 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5298 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005299 }
5300 }
5301 }
5302 if( pSirBssDesc )
5303 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005304 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07005305 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5306 //Save WPA/RSN IE
5307 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005308#ifdef FEATURE_WLAN_ESE
5309 roamInfo.isESEAssoc = pSession->connectedProfile.isESEAssoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005310#endif
5311
5312 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
5313 // substate change.
5314 // Moving even save profile above so that below mentioned conditon is also met.
5315 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
5316 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005317 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
5318 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
5319 // will be dropped for the security context may not be set properly.
5320 //
5321 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
5322 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
5323 //
5324 // this reordering was done on titan_prod_usb branch and is being replicated here.
5325 //
5326
5327 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
5328 !pProfile->bWPSAssociation)
5329 {
5330 // Issue the set Context request to LIM to establish the Unicast STA context
5331 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
5332 pProfile->negotiatedUCEncryptionType,
5333 pSirBssDesc, &(pSirBssDesc->bssId),
5334 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
5335 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005336 smsLog( pMac, LOGE, FL(" Set context for unicast fail") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005337 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5338 }
5339 // Issue the set Context request to LIM to establish the Broadcast STA context
5340 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
5341 pSirBssDesc, &BroadcastMac,
5342 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5343 }
5344 else
5345 {
5346 //Need to wait for supplicant authtication
5347 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005348 //Set the subestate to WaitForKey in case authentiation is needed
5349 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
5350
Jeff Johnson295189b2012-06-20 16:38:30 -07005351 if(pProfile->bWPSAssociation)
5352 {
5353 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
5354 }
5355 else
5356 {
5357 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
5358 }
5359
5360 //Save sessionId in case of timeout
5361 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
5362 //This time should be long enough for the rest of the process plus setting key
5363 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
5364 {
5365 //Reset our state so nothting is blocked.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005366 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005367 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
5368 }
5369 }
5370
5371 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
5372 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005373 if(Context)
5374 {
5375 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
5376 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07005377 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5378 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
5379#ifdef WLAN_FEATURE_VOWIFI_11R
5380 len += pJoinRsp->parsedRicRspLen;
5381#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005382#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005383 len += pJoinRsp->tspecIeLen;
5384#endif
5385 if(len)
5386 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305387 pSession->connectedInfo.pbFrames = vos_mem_malloc(len);
5388 if ( pSession->connectedInfo.pbFrames != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07005389 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305390 vos_mem_copy(pSession->connectedInfo.pbFrames,
5391 pJoinRsp->frames, len);
5392 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5393 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5394 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
Jeff Johnson295189b2012-06-20 16:38:30 -07005395#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05305396 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005397#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005398#ifdef FEATURE_WLAN_ESE
Kiet Lam64c1b492013-07-12 13:56:44 +05305399 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005400#endif
Kiet Lam64c1b492013-07-12 13:56:44 +05305401 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5402 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5403 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
5404 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
Jeff Johnson295189b2012-06-20 16:38:30 -07005405 }
5406 }
5407 if(pCommand->u.roamCmd.fReassoc)
5408 {
5409 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5410 }
5411 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5412 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5413 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
5414 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
5415 }
5416 else
5417 {
5418 if(pCommand->u.roamCmd.fReassoc)
5419 {
5420 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5421 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5422 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5423 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5424 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5425 }
5426 }
5427#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5428 // Indicate SME-QOS with reassoc success event, only after
5429 // copying the frames
5430 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
5431#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005432 roamInfo.pBssDesc = pSirBssDesc;
5433 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5434 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5435#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5436 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
5437#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
5438 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005439 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
5440 //It may be better to let QoS do this????
5441 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
5442 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005443 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now",
Jeff Johnson295189b2012-06-20 16:38:30 -07005444 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
5445 pmcStartUapsd( pMac, NULL, NULL );
5446 }
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05305447 pSession->connectedProfile.dot11Mode = pSession->bssParams.uCfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005448 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5449 if( pSession->bRefAssocStartCnt > 0 )
5450 {
5451 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005452 //Remove this code once SLM_Sessionization is supported
5453 //BMPS_WORKAROUND_NOT_NEEDED
5454 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005455 {
5456 pMac->roam.configParam.doBMPSWorkaround = 1;
5457 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005458 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5459 }
5460
5461 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005462 // reset the PMKID candidate list
5463 csrResetPMKIDCandidateList( pMac, sessionId );
5464 //Update TL's AC weight base on the current EDCA parameters
5465 //These parameters may change in the course of the connection, that sictuation
5466 //is not taken care here. This change is mainly to address a WIFI WMM test where
5467 //BE has a equal or higher TX priority than VI.
5468 //We only do this for infra link
5469 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
5470 {
5471 csrCheckAndUpdateACWeight(pMac, pIes);
5472 }
5473#ifdef FEATURE_WLAN_WAPI
5474 // reset the BKID candidate list
5475 csrResetBKIDCandidateList( pMac, sessionId );
5476#endif /* FEATURE_WLAN_WAPI */
5477 }
5478 else
5479 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005480 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc");
Jeff Johnson295189b2012-06-20 16:38:30 -07005481 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005482 csrScanCancelIdleScan(pMac);
5483 //Not to signal link up because keys are yet to be set.
5484 //The linkup function will overwrite the sub-state that we need to keep at this point.
5485 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
5486 {
5487 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
5488 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005489 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
5490 //enough to let security and DHCP handshake succeed before entry into BMPS
5491 if (pmcShouldBmpsTimerRun(pMac))
5492 {
Abhishek Singh65d939e2014-04-25 13:33:07 +05305493 /* Set remainInPowerActiveTillDHCP to make sure we wait for
5494 * until keys are set before going into BMPS.
5495 */
5496 if(eANI_BOOLEAN_TRUE == roamInfo.fAuthRequired)
5497 {
5498 pMac->pmc.remainInPowerActiveTillDHCP = TRUE;
5499 smsLog(pMac, LOG1, FL("Set remainInPowerActiveTillDHCP "
5500 "to make sure we wait until keys are set before"
5501 " going to BMPS"));
5502 }
5503
Jeff Johnson295189b2012-06-20 16:38:30 -07005504 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
5505 != eHAL_STATUS_SUCCESS)
5506 {
5507 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
5508 }
5509 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
5510 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005511 break;
5512
Jeff Johnson295189b2012-06-20 16:38:30 -07005513 case eCsrStartBssSuccess:
5514 // on the StartBss Response, LIM is returning the Bss Description that we
5515 // are beaconing. Add this Bss Description to our scan results and
5516 // chain the Profile to this Bss Description. On a Start BSS, there was no
5517 // detected Bss description (no partner) so we issued the Start Bss to
5518 // start the Ibss without any Bss description. Lim was kind enough to return
5519 // the Bss Description that we start beaconing for the newly started Ibss.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005520 smsLog(pMac, LOG2, FL("receives start BSS ok indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005521 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005522 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
Kiet Lam64c1b492013-07-12 13:56:44 +05305523 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005524 if( CSR_IS_IBSS( pProfile ) )
5525 {
5526 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
5527 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005528 else if (CSR_IS_INFRA_AP(pProfile))
5529 {
5530 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
5531 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005532 else
5533 {
5534 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
5535 }
5536 if( !CSR_IS_WDS_STA( pProfile ) )
5537 {
5538 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005539 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
Jeff Johnson295189b2012-06-20 16:38:30 -07005540 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
5541 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05305542 smsLog(pMac, LOGW, FL("cannot parse IBSS IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005543 roamInfo.pBssDesc = pSirBssDesc;
5544 //We need to associate_complete it first, becasue Associate_start already indicated.
5545 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5546 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
5547 break;
5548 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005549 if (!CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07005550 {
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07005551 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005552 }
5553 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
5554 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5555 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5556 if(pSirBssDesc)
5557 {
5558 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
Kiet Lam64c1b492013-07-12 13:56:44 +05305559 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5560 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005561 }
5562 //We are doen with the IEs so free it
Kiet Lam64c1b492013-07-12 13:56:44 +05305563 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005564#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5565 {
5566 vos_log_ibss_pkt_type *pIbssLog;
5567 tANI_U32 bi;
5568
5569 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5570 if(pIbssLog)
5571 {
5572 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5573 {
5574 //We start the IBSS (didn't find any matched IBSS out there)
5575 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
5576 }
5577 else
5578 {
5579 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
5580 }
5581 if(pSirBssDesc)
5582 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305583 vos_mem_copy(pIbssLog->bssid, pSirBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07005584 pIbssLog->operatingChannel = pSirBssDesc->channelId;
5585 }
5586 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
5587 {
5588 //***U8 is not enough for beacon interval
5589 pIbssLog->beaconInterval = (v_U8_t)bi;
5590 }
5591 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5592 }
5593 }
5594#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5595 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
5596 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07005597 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
5598 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005599 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
5600 csrRoamIssueSetContextReq( pMac, sessionId,
5601 pProfile->negotiatedMCEncryptionType,
5602 pSirBssDesc, &BroadcastMac,
5603 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5604 }
5605 }
5606 else
5607 {
5608 //Keep the state to eCSR_ROAMING_STATE_JOINING
5609 //Need to send join_req.
5610 if(pCommand->u.roamCmd.pRoamBssEntry)
5611 {
5612 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
5613 {
5614 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5615 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
5616 // Set the roaming substate to 'join attempt'...
5617 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08005618 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07005619 }
5620 }
5621 else
5622 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005623 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc" );
Jeff Johnson295189b2012-06-20 16:38:30 -07005624 VOS_ASSERT( 0 );
5625 }
5626 }
5627 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5628 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5629 //trigger the connection start indication in Vista
5630 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
5631 {
5632 roamStatus = eCSR_ROAM_IBSS_IND;
5633 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5634 if( CSR_IS_WDS( pProfile ) )
5635 {
5636 roamStatus = eCSR_ROAM_WDS_IND;
5637 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5638 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005639 if( CSR_IS_INFRA_AP( pProfile ) )
5640 {
5641 roamStatus = eCSR_ROAM_INFRA_IND;
5642 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
5643 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005644
5645 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5646 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5647 //trigger the connection start indication in Vista
Kiet Lam64c1b492013-07-12 13:56:44 +05305648 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005649 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5650 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
krunal soni3fc26642013-10-08 22:41:42 -07005651 //We start the IBSS (didn't find any matched IBSS out there)
5652 roamInfo.pBssDesc = pSirBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005653 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
Kiet Lam64c1b492013-07-12 13:56:44 +05305654 vos_mem_copy(roamInfo.bssid, pSirBssDesc->bssId,
5655 sizeof(tCsrBssid));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005656 //Remove this code once SLM_Sessionization is supported
5657 //BMPS_WORKAROUND_NOT_NEEDED
5658 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07005659 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005660 {
5661 pMac->roam.configParam.doBMPSWorkaround = 1;
5662 }
Mohit Khanna349bc392012-09-11 17:24:52 -07005663
Jeff Johnson295189b2012-06-20 16:38:30 -07005664 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5665 }
5666
5667 csrScanCancelIdleScan(pMac);
Ravi Joshi414b14c2013-10-04 16:33:26 -07005668
5669 if( CSR_IS_WDS_STA( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005670 {
5671 //need to send stop BSS because we fail to send join_req
5672 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
5673 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5674 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
5675 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005676 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005677 case eCsrStartBssFailure:
5678#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5679 {
5680 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07005681 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5682 if(pIbssLog)
5683 {
5684 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
5685 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5686 }
5687 }
5688#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07005689 roamStatus = eCSR_ROAM_IBSS_IND;
5690 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5691 if( CSR_IS_WDS( pProfile ) )
5692 {
5693 roamStatus = eCSR_ROAM_WDS_IND;
5694 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5695 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005696 if( CSR_IS_INFRA_AP( pProfile ) )
5697 {
5698 roamStatus = eCSR_ROAM_INFRA_IND;
5699 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
5700 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005701 if(Context)
5702 {
5703 pSirBssDesc = (tSirBssDescription *)Context;
5704 }
5705 else
5706 {
5707 pSirBssDesc = NULL;
5708 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305709 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005710 roamInfo.pBssDesc = pSirBssDesc;
5711 //We need to associate_complete it first, becasue Associate_start already indicated.
5712 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5713 csrSetDefaultDot11Mode( pMac );
5714 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005715 case eCsrSilentlyStopRoaming:
5716 // We are here because we try to start the same IBSS
5717 //No message to PE
5718 // return the roaming state to Joined.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005719 smsLog(pMac, LOGW, FL("receives silently roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005720 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
5721 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05305722 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005723 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5724 if( roamInfo.pBssDesc )
5725 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305726 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5727 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005728 }
5729 //Since there is no change in the current state, simply pass back no result otherwise
5730 //HDD may be mistakenly mark to disconnected state.
5731 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5732 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005733 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005734 case eCsrSilentlyStopRoamingSaveState:
5735 //We are here because we try to connect to the same AP
5736 //No message to PE
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005737 smsLog(pMac, LOGW, FL("receives silently stop roaming indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305738 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005739
5740 //to aviod resetting the substate to NONE
5741 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
5742 //No need to change substate to wai_for_key because there is no state change
5743 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5744 if( roamInfo.pBssDesc )
5745 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305746 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5747 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005748 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005749 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5750 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5751 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5752 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5753 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5754 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5755 roamInfo.staId = pSession->connectedInfo.staId;
5756 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005757 VOS_ASSERT( roamInfo.staId != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005758 pSession->bRefAssocStartCnt--;
5759 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5760 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5761 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
5762 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005763 case eCsrReassocFailure:
5764#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5765 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
5766#endif
5767 case eCsrJoinWdsFailure:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005768 smsLog(pMac, LOGW, FL("failed to join WDS"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005769 csrFreeConnectBssDesc(pMac, sessionId);
5770 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5771 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
Kiet Lam64c1b492013-07-12 13:56:44 +05305772 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005773 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5774 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5775 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5776 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5777 eCSR_ROAM_WDS_IND,
5778 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
5779 //Need to issue stop_bss
5780 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005781 case eCsrJoinFailure:
5782 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07005783 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07005784 default:
5785 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005786 smsLog(pMac, LOGW, FL("receives no association indication"));
5787 smsLog(pMac, LOG1, FL("Assoc ref count %d"),
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07005788 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07005789 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
5790 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
5791 {
5792 //do not free for the other profiles as we need to send down stop BSS later
5793 csrFreeConnectBssDesc(pMac, sessionId);
5794 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5795 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5796 csrSetDefaultDot11Mode( pMac );
5797 }
5798
5799 switch( pCommand->u.roamCmd.roamReason )
5800 {
5801 // If this transition is because of an 802.11 OID, then we transition
5802 // back to INIT state so we sit waiting for more OIDs to be issued and
5803 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07005804 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07005805 case eCsrSmeIssuedAssocToSimilarAP:
5806 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08005807 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07005808 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05305809 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005810 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5811 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5812 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Kiet Lam64c1b492013-07-12 13:56:44 +05305813 vos_mem_copy(&roamInfo.bssid,
5814 &pSession->joinFailStatusCode.bssId,
5815 sizeof(tCsrBssid));
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005816
Jeff Johnson295189b2012-06-20 16:38:30 -07005817 /* Defeaturize this later if needed */
5818#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5819 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
5820 if (csrRoamIsHandoffInProgress(pMac))
5821 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005822 /* Should indicate neighbor roam algorithm about the connect failure here */
5823 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
5824 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005825#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005826 if(pSession->bRefAssocStartCnt > 0)
5827 {
5828 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07005829 if(eCsrJoinFailureDueToConcurrency == Result)
5830 {
5831 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5832 eCSR_ROAM_ASSOCIATION_COMPLETION,
5833 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
5834 }
5835 else
5836 {
5837 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005838 eCSR_ROAM_ASSOCIATION_COMPLETION,
5839 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07005840 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005841 }
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005842 else
5843 {
5844 /* bRefAssocStartCnt is not incremented when
5845 * eRoamState == eCsrStopRoamingDueToConcurrency
5846 * in csrRoamJoinNextBss API. so handle this in
5847 * else case by sending assoc failure
5848 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005849 csrRoamCallCallback(pMac, sessionId, &roamInfo,
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005850 pCommand->u.scanCmd.roamId,
5851 eCSR_ROAM_ASSOCIATION_FAILURE,
5852 eCSR_ROAM_RESULT_FAILURE);
5853 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005854 smsLog(pMac, LOG1, FL(" roam(reason %d) failed"), pCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07005855#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Mukul Sharma5960ac82014-01-09 20:31:35 +05305856 sme_QosUpdateHandOff((tANI_U8)sessionId, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005857 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5858#endif
5859 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5860 csrScanStartIdleScan(pMac);
5861#ifdef FEATURE_WLAN_BTAMP_UT_RF
5862 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
5863 //BT activity and not able to recevie WLAN traffic. Retry the join
5864 if( CSR_IS_WDS_STA(pProfile) )
5865 {
5866 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
5867 }
5868#endif
5869 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005870 case eCsrHddIssuedReassocToSameAP:
5871 case eCsrSmeIssuedReassocToSameAP:
5872 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5873
5874 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5875#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5876 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5877#endif
5878 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5879 csrScanStartIdleScan(pMac);
5880 break;
5881 case eCsrForcedDisassoc:
5882 case eCsrForcedDeauth:
5883 case eCsrSmeIssuedIbssJoinFailure:
5884 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5885
5886 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
5887 {
5888 // Notify HDD that IBSS join failed
5889 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
5890 }
5891 else
5892 {
5893 csrRoamCallCallback(pMac, sessionId, NULL,
5894 pCommand->u.roamCmd.roamId,
5895 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5896 }
5897#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5898 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5899#endif
5900 csrRoamLinkDown(pMac, sessionId);
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08005901 /*
5902 *DelSta not done FW still in conneced state so dont
5903 *issue IMPS req
5904 */
5905 if (pMac->roam.deauthRspStatus == eSIR_SME_DEAUTH_STATUS)
5906 {
5907 smsLog(pMac, LOGW, FL("FW still in connected state "));
5908 break;
5909 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005910 csrScanStartIdleScan(pMac);
5911 break;
5912 case eCsrForcedIbssLeave:
5913 csrRoamCallCallback(pMac, sessionId, NULL,
5914 pCommand->u.roamCmd.roamId,
5915 eCSR_ROAM_IBSS_LEAVE,
5916 eCSR_ROAM_RESULT_IBSS_STOP);
5917 break;
5918 case eCsrForcedDisassocMICFailure:
5919 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5920
5921 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
5922#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5923 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
5924#endif
5925 csrScanStartIdleScan(pMac);
5926 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005927 case eCsrStopBss:
5928 csrRoamCallCallback(pMac, sessionId, NULL,
5929 pCommand->u.roamCmd.roamId,
5930 eCSR_ROAM_INFRA_IND,
5931 eCSR_ROAM_RESULT_INFRA_STOPPED);
5932 break;
5933 case eCsrForcedDisassocSta:
5934 case eCsrForcedDeauthSta:
5935 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
5936 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
5937 {
5938 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005939
5940 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
5941 {
5942 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05305943 vos_mem_copy(roamInfo.peerMac,
5944 pCommand->u.roamCmd.peerMac,
5945 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07005946 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
5947 roamInfo.statusCode = eSIR_SME_SUCCESS;
5948 status = csrRoamCallCallback(pMac, sessionId,
5949 &roamInfo, pCommand->u.roamCmd.roamId,
5950 eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
5951 }
5952 }
5953 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005954 case eCsrLostLink1:
5955 // if lost link roam1 failed, then issue lost link Scan2 ...
5956 csrScanRequestLostLink2(pMac, sessionId);
5957 break;
5958 case eCsrLostLink2:
5959 // if lost link roam2 failed, then issue lost link scan3 ...
5960 csrScanRequestLostLink3(pMac, sessionId);
5961 break;
5962 case eCsrLostLink3:
5963 default:
5964 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5965
5966 //We are done with one round of lostlink roaming here
5967 csrScanHandleFailedLostlink3(pMac, sessionId);
5968 break;
5969 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005970 break;
5971 }
5972 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005973 return ( fReleaseCommand );
5974}
5975
Jeff Johnson295189b2012-06-20 16:38:30 -07005976eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
5977{
5978 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005979 return (status);
5980}
5981
Jeff Johnson295189b2012-06-20 16:38:30 -07005982eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
5983{
5984 eHalStatus status = eHAL_STATUS_SUCCESS;
5985 tANI_U32 size = 0;
5986
5987 do
5988 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305989 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005990 if(pSrcProfile->BSSIDs.numOfBSSIDs)
5991 {
5992 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05305993 pDstProfile->BSSIDs.bssid = vos_mem_malloc(size);
5994 if ( NULL == pDstProfile->BSSIDs.bssid )
5995 status = eHAL_STATUS_FAILURE;
5996 else
5997 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07005998 if(!HAL_STATUS_SUCCESS(status))
5999 {
6000 break;
6001 }
6002 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306003 vos_mem_copy(pDstProfile->BSSIDs.bssid,
6004 pSrcProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07006005 }
6006 if(pSrcProfile->SSIDs.numOfSSIDs)
6007 {
6008 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306009 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(size);
6010 if ( NULL == pDstProfile->SSIDs.SSIDList )
6011 status = eHAL_STATUS_FAILURE;
6012 else
6013 status = eHAL_STATUS_SUCCESS;
6014 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006015 {
6016 break;
6017 }
6018 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306019 vos_mem_copy(pDstProfile->SSIDs.SSIDList,
6020 pSrcProfile->SSIDs.SSIDList, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07006021 }
6022 if(pSrcProfile->nWPAReqIELength)
6023 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306024 pDstProfile->pWPAReqIE = vos_mem_malloc(pSrcProfile->nWPAReqIELength);
6025 if ( NULL == pDstProfile->pWPAReqIE )
6026 status = eHAL_STATUS_FAILURE;
6027 else
6028 status = eHAL_STATUS_SUCCESS;
6029
6030 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006031 {
6032 break;
6033 }
6034 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306035 vos_mem_copy(pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE,
6036 pSrcProfile->nWPAReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006037 }
6038 if(pSrcProfile->nRSNReqIELength)
6039 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306040 pDstProfile->pRSNReqIE = vos_mem_malloc(pSrcProfile->nRSNReqIELength);
6041 if ( NULL == pDstProfile->pRSNReqIE )
6042 status = eHAL_STATUS_FAILURE;
6043 else
6044 status = eHAL_STATUS_SUCCESS;
6045
6046 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006047 {
6048 break;
6049 }
6050 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306051 vos_mem_copy(pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE,
6052 pSrcProfile->nRSNReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006053 }
6054#ifdef FEATURE_WLAN_WAPI
6055 if(pSrcProfile->nWAPIReqIELength)
6056 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306057 pDstProfile->pWAPIReqIE = vos_mem_malloc(pSrcProfile->nWAPIReqIELength);
6058 if ( NULL == pDstProfile->pWAPIReqIE )
6059 status = eHAL_STATUS_FAILURE;
6060 else
6061 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006062 if(!HAL_STATUS_SUCCESS(status))
6063 {
6064 break;
6065 }
6066 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306067 vos_mem_copy(pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE,
6068 pSrcProfile->nWAPIReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006069 }
6070#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07006071 if(pSrcProfile->nAddIEScanLength)
6072 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05306073 memset(pDstProfile->addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH);
6074 if ( SIR_MAC_MAX_IE_LENGTH >= pSrcProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -07006075 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05306076 vos_mem_copy(pDstProfile->addIEScan, pSrcProfile->addIEScan,
Kiet Lam64c1b492013-07-12 13:56:44 +05306077 pSrcProfile->nAddIEScanLength);
Agarwal Ashish4f616132013-12-30 23:32:50 +05306078 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
6079 }
6080 else
6081 {
6082 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
6083 FL(" AddIEScanLength is not valid %u"),
6084 pSrcProfile->nAddIEScanLength);
6085 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006086 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006087 if(pSrcProfile->nAddIEAssocLength)
6088 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306089 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6090 if ( NULL == pDstProfile->pAddIEAssoc )
6091 status = eHAL_STATUS_FAILURE;
6092 else
6093 status = eHAL_STATUS_SUCCESS;
6094
Jeff Johnson295189b2012-06-20 16:38:30 -07006095 if(!HAL_STATUS_SUCCESS(status))
6096 {
6097 break;
6098 }
6099 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306100 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6101 pSrcProfile->nAddIEAssocLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006102 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006103 if(pSrcProfile->ChannelInfo.ChannelList)
6104 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306105 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(
6106 pSrcProfile->ChannelInfo.numOfChannels);
6107 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6108 status = eHAL_STATUS_FAILURE;
6109 else
6110 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006111 if(!HAL_STATUS_SUCCESS(status))
6112 {
6113 break;
6114 }
6115 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
Kiet Lam64c1b492013-07-12 13:56:44 +05306116 vos_mem_copy(pDstProfile->ChannelInfo.ChannelList,
6117 pSrcProfile->ChannelInfo.ChannelList,
6118 pSrcProfile->ChannelInfo.numOfChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07006119 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006120 pDstProfile->AuthType = pSrcProfile->AuthType;
6121 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
6122 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
6123 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
6124 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
6125 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
Chet Lanctot186b5732013-03-18 10:26:30 -07006126#ifdef WLAN_FEATURE_11W
6127 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
6128 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
6129 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
6130#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006131 pDstProfile->BSSType = pSrcProfile->BSSType;
6132 pDstProfile->phyMode = pSrcProfile->phyMode;
6133 pDstProfile->csrPersona = pSrcProfile->csrPersona;
6134
6135#ifdef FEATURE_WLAN_WAPI
6136 if(csrIsProfileWapi(pSrcProfile))
6137 {
6138 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
6139 {
6140 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
6141 }
6142 }
6143#endif /* FEATURE_WLAN_WAPI */
6144 pDstProfile->CBMode = pSrcProfile->CBMode;
6145 /*Save the WPS info*/
6146 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006147 pDstProfile->bOSENAssociation = pSrcProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07006148 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006149 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07006150 pDstProfile->privacy = pSrcProfile->privacy;
6151 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
6152 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
6153 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
6154 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
6155 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
6156 pDstProfile->protEnabled = pSrcProfile->protEnabled;
6157 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
6158 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
6159 pDstProfile->wps_state = pSrcProfile->wps_state;
6160 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
Kiet Lam64c1b492013-07-12 13:56:44 +05306161 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6162 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006163#ifdef WLAN_FEATURE_VOWIFI_11R
6164 if (pSrcProfile->MDID.mdiePresent)
6165 {
6166 pDstProfile->MDID.mdiePresent = 1;
6167 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6168 }
6169#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006170 }while(0);
6171
6172 if(!HAL_STATUS_SUCCESS(status))
6173 {
6174 csrReleaseProfile(pMac, pDstProfile);
6175 pDstProfile = NULL;
6176 }
6177
6178 return (status);
6179}
Jeff Johnson295189b2012-06-20 16:38:30 -07006180eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
6181{
6182 eHalStatus status = eHAL_STATUS_SUCCESS;
6183 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
6184 do
6185 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306186 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006187 if(pSrcProfile->bssid)
6188 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306189 pDstProfile->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
6190 if ( NULL == pDstProfile->BSSIDs.bssid )
6191 status = eHAL_STATUS_FAILURE;
6192 else
6193 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006194 if(!HAL_STATUS_SUCCESS(status))
6195 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306196 smsLog( pMac, LOGE,
6197 FL("failed to allocate memory for BSSID"
6198 "%02x:%02x:%02x:%02x:%02x:%02x"),
6199 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6200 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006201 break;
6202 }
6203 pDstProfile->BSSIDs.numOfBSSIDs = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05306204 vos_mem_copy(pDstProfile->BSSIDs.bssid, pSrcProfile->bssid,
6205 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006206 }
6207 if(pSrcProfile->SSID.ssId)
6208 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306209 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
6210 if ( NULL == pDstProfile->SSIDs.SSIDList )
6211 status = eHAL_STATUS_FAILURE;
6212 else
6213 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006214 if(!HAL_STATUS_SUCCESS(status))
6215 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306216 smsLog( pMac, LOGE,
6217 FL("failed to allocate memory for SSIDList"
6218 "%02x:%02x:%02x:%02x:%02x:%02x"),
6219 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6220 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006221 break;
6222 }
6223 pDstProfile->SSIDs.numOfSSIDs = 1;
6224 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
6225 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
Kiet Lam64c1b492013-07-12 13:56:44 +05306226 vos_mem_copy(&pDstProfile->SSIDs.SSIDList[0].SSID,
6227 &pSrcProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006228 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006229 if(pSrcProfile->nAddIEAssocLength)
6230 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306231 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6232 if ( NULL == pDstProfile->pAddIEAssoc)
6233 status = eHAL_STATUS_FAILURE;
6234 else
6235 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006236 if(!HAL_STATUS_SUCCESS(status))
6237 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006238 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs ") );
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006239 break;
6240 }
6241 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306242 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6243 pSrcProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006244 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306245 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(1);
6246 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6247 status = eHAL_STATUS_FAILURE;
6248 else
6249 status = eHAL_STATUS_SUCCESS;
6250
Jeff Johnson295189b2012-06-20 16:38:30 -07006251 if(!HAL_STATUS_SUCCESS(status))
6252 {
6253 break;
6254 }
6255 pDstProfile->ChannelInfo.numOfChannels = 1;
6256 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006257 pDstProfile->AuthType.numEntries = 1;
6258 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
6259 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
6260 pDstProfile->EncryptionType.numEntries = 1;
6261 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
6262 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
6263 pDstProfile->mcEncryptionType.numEntries = 1;
6264 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
6265 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
6266 pDstProfile->BSSType = pSrcProfile->BSSType;
6267 pDstProfile->CBMode = pSrcProfile->CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +05306268 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6269 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006270#ifdef WLAN_FEATURE_VOWIFI_11R
6271 if (pSrcProfile->MDID.mdiePresent)
6272 {
6273 pDstProfile->MDID.mdiePresent = 1;
6274 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6275 }
6276#endif
6277
6278 }while(0);
6279
6280 if(!HAL_STATUS_SUCCESS(status))
6281 {
6282 csrReleaseProfile(pMac, pDstProfile);
6283 pDstProfile = NULL;
6284 }
6285
6286 return (status);
6287}
6288
Jeff Johnson295189b2012-06-20 16:38:30 -07006289eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6290 tScanResultHandle hBSSList,
6291 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
6292 tANI_BOOLEAN fClearScan)
6293{
6294 eHalStatus status = eHAL_STATUS_SUCCESS;
6295 tSmeCmd *pCommand;
6296
6297 pCommand = csrGetCommandBuffer(pMac);
6298 if(NULL == pCommand)
6299 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006300 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006301 status = eHAL_STATUS_RESOURCES;
6302 }
6303 else
6304 {
6305 if( fClearScan )
6306 {
6307 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306308 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006309 }
6310 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6311 if(NULL == pProfile)
6312 {
6313 //We can roam now
6314 //Since pProfile is NULL, we need to build our own profile, set everything to default
6315 //We can only support open and no encryption
6316 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
6317 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
6318 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
6319 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6320 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
6321 }
6322 else
6323 {
6324 //make a copy of the profile
6325 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6326 if(HAL_STATUS_SUCCESS(status))
6327 {
6328 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6329 }
6330 }
6331 pCommand->command = eSmeCommandRoam;
6332 pCommand->sessionId = (tANI_U8)sessionId;
6333 pCommand->u.roamCmd.hBSSList = hBSSList;
6334 pCommand->u.roamCmd.roamId = roamId;
6335 pCommand->u.roamCmd.roamReason = reason;
6336 //We need to free the BssList when the command is done
6337 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
6338 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006339 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6340 FL("CSR PERSONA=%d"),
6341 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07006342 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6343 if( !HAL_STATUS_SUCCESS( status ) )
6344 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006345 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006346 csrReleaseCommandRoam( pMac, pCommand );
6347 }
6348 }
6349
6350 return (status);
6351}
Jeff Johnson295189b2012-06-20 16:38:30 -07006352eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6353 tCsrRoamModifyProfileFields *pMmodProfileFields,
6354 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
6355{
6356 eHalStatus status = eHAL_STATUS_SUCCESS;
6357 tSmeCmd *pCommand;
6358
6359 pCommand = csrGetCommandBuffer(pMac);
6360 if(NULL == pCommand)
6361 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006362 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006363 status = eHAL_STATUS_RESOURCES;
6364 }
6365 else
6366 {
6367 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306368 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006369 if(pProfile)
6370 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006371 //This is likely trying to reassoc to different profile
6372 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6373 //make a copy of the profile
6374 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6375 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006376 }
6377 else
6378 {
6379 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
6380 //how to update WPA/WPA2 info in roamProfile??
6381 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006382 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006383 if(HAL_STATUS_SUCCESS(status))
6384 {
6385 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6386 }
6387 pCommand->command = eSmeCommandRoam;
6388 pCommand->sessionId = (tANI_U8)sessionId;
6389 pCommand->u.roamCmd.roamId = roamId;
6390 pCommand->u.roamCmd.roamReason = reason;
6391 //We need to free the BssList when the command is done
6392 //For reassoc there is no BSS list, so the boolean set to false
6393 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
6394 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
6395 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006396 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6397 if( !HAL_STATUS_SUCCESS( status ) )
6398 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006399 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006400 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6401 csrReleaseCommandRoam( pMac, pCommand );
6402 }
6403 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006404 return (status);
6405}
6406
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006407eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
6408 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306409// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006410{
6411 eHalStatus status = eHAL_STATUS_SUCCESS;
6412 tSmeCmd *pCommand;
6413
6414 pCommand = csrGetCommandBuffer(pMac);
6415 if(NULL == pCommand)
6416 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006417 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006418 status = eHAL_STATUS_RESOURCES;
6419 }
6420 else
6421 {
6422 if(pBssDescription)
6423 {
6424 //copy over the parameters we need later
6425 pCommand->command = eSmeCommandRoam;
6426 pCommand->sessionId = (tANI_U8)sessionId;
6427 pCommand->u.roamCmd.roamReason = reason;
6428 //this is the important parameter
6429 //in this case we are using this field for the "next" BSS
6430 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
6431 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
6432 if( !HAL_STATUS_SUCCESS( status ) )
6433 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006434 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d"), status );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006435 csrReleaseCommandPreauth( pMac, pCommand );
6436 }
6437 }
6438 else
6439 {
6440 //Return failure
6441 status = eHAL_STATUS_RESOURCES;
6442 }
6443 }
6444 return (status);
6445}
6446
6447eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
6448{
6449 tListElem *pEntry;
6450 tSmeCmd *pCommand;
6451 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6452 if ( pEntry )
6453 {
6454 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6455 if ( (eSmeCommandRoam == pCommand->command) &&
6456 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
6457 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006458 smsLog( pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006459 pCommand->command, pCommand->u.roamCmd.roamReason);
6460 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
6461 csrReleaseCommandPreauth( pMac, pCommand );
6462 }
6463 } else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006464 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d "),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006465 pCommand->command, pCommand->u.roamCmd.roamReason);
6466 }
6467 }
6468 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006469 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006470 }
6471 smeProcessPendingQueue( pMac );
6472 return eHAL_STATUS_SUCCESS;
6473}
6474
Jeff Johnson295189b2012-06-20 16:38:30 -07006475eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6476 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6477{
6478 eHalStatus status = eHAL_STATUS_FAILURE;
6479 tScanResultHandle hBSSList;
6480 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006481 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
6482 if(HAL_STATUS_SUCCESS(status))
6483 {
6484 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6485 if(pRoamId)
6486 {
6487 *pRoamId = roamId;
6488 }
6489 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6490 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6491 if(!HAL_STATUS_SUCCESS(status))
6492 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006493 smsLog(pMac, LOGE, FL("failed to start a join process"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006494 csrScanResultPurge(pMac, hBSSList);
6495 }
6496 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006497 return (status);
6498}
6499
Jeff Johnson295189b2012-06-20 16:38:30 -07006500eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6501 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6502{
6503 eHalStatus status = eHAL_STATUS_SUCCESS;
6504 tScanResultHandle hBSSList;
6505 tCsrScanResultFilter *pScanFilter;
6506 tANI_U32 roamId = 0;
6507 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
6508 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006509 if (NULL == pProfile)
6510 {
6511 smsLog(pMac, LOGP, FL("No profile specified"));
6512 return eHAL_STATUS_FAILURE;
6513 }
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05306514 smsLog(pMac, LOG1, FL("called BSSType = %s (%d) authtype = %d "
6515 "encryType = %d"),
6516 lim_BssTypetoString(pProfile->BSSType),
6517 pProfile->BSSType,
6518 pProfile->AuthType.authType[0],
6519 pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006520 if( CSR_IS_WDS( pProfile ) &&
6521 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
6522 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006523 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d"),
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006524 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006525 return status;
6526 }
6527 csrRoamCancelRoaming(pMac, sessionId);
6528 csrScanRemoveFreshScanCommand(pMac, sessionId);
6529 csrScanCancelIdleScan(pMac);
6530 //Only abort the scan if it is not used for other roam/connect purpose
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05306531 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Jeff Johnson295189b2012-06-20 16:38:30 -07006532 if (!vos_concurrent_sessions_running() && (VOS_STA_SAP_MODE == pProfile->csrPersona))//In case of AP mode we do not want idle mode scan
6533 {
6534 csrScanDisable(pMac);
6535 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006536 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6537 //Check whether ssid changes
6538 if(csrIsConnStateConnected(pMac, sessionId))
6539 {
6540 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6541 {
6542 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6543 }
6544 }
6545#ifdef FEATURE_WLAN_BTAMP_UT_RF
6546 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
6547#endif
6548 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
6549 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006550 smsLog(pMac, LOG1, FL("is called with BSSList"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006551 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
6552 if(pRoamId)
6553 {
6554 roamId = *pRoamId;
6555 }
6556 if(!HAL_STATUS_SUCCESS(status))
6557 {
6558 fCallCallback = eANI_BOOLEAN_TRUE;
6559 }
6560 }
6561 else
6562 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306563 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
6564 if ( NULL == pScanFilter )
6565 status = eHAL_STATUS_FAILURE;
6566 else
6567 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006568 if(HAL_STATUS_SUCCESS(status))
6569 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306570 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006571 //Try to connect to any BSS
6572 if(NULL == pProfile)
6573 {
6574 //No encryption
6575 pScanFilter->EncryptionType.numEntries = 1;
6576 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6577 }//we don't have a profile
6578 else
6579 {
6580 //Here is the profile we need to connect to
6581 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6582 }//We have a profile
6583 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6584 if(pRoamId)
6585 {
6586 *pRoamId = roamId;
6587 }
6588
6589 if(HAL_STATUS_SUCCESS(status))
6590 {
6591 /*Save the WPS info*/
6592 if(NULL != pProfile)
6593 {
6594 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006595 pScanFilter->bOSENAssociation = pProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07006596 }
6597 else
6598 {
6599 pScanFilter->bWPSAssociation = 0;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006600 pScanFilter->bOSENAssociation = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006601 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006602 do
6603 {
6604 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006605 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006606 )
6607 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006608 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07006609 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6610 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6611 if(!HAL_STATUS_SUCCESS(status))
6612 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006613 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006614 fCallCallback = eANI_BOOLEAN_TRUE;
6615 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006616 else
6617 {
6618 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
6619 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006620 break;
6621 }
6622 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006623 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006624 if(HAL_STATUS_SUCCESS(status))
6625 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006626 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6627 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6628 if(!HAL_STATUS_SUCCESS(status))
6629 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006630 smsLog(pMac, LOGE, FL(" CSR failed to issue connect command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006631 csrScanResultPurge(pMac, hBSSList);
6632 fCallCallback = eANI_BOOLEAN_TRUE;
6633 }
6634 }//Have scan result
6635 else if(NULL != pProfile)
6636 {
6637 //Check whether it is for start ibss
6638 if(CSR_IS_START_IBSS(pProfile))
6639 {
6640 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6641 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6642 if(!HAL_STATUS_SUCCESS(status))
6643 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006644 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006645 fCallCallback = eANI_BOOLEAN_TRUE;
6646 }
6647 }
6648 else
6649 {
6650 //scan for this SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006651 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006652 if(!HAL_STATUS_SUCCESS(status))
6653 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006654 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006655 fCallCallback = eANI_BOOLEAN_TRUE;
6656 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006657 else
6658 {
6659 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
6660 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006661 }
6662 }
6663 else
6664 {
6665 fCallCallback = eANI_BOOLEAN_TRUE;
6666 }
6667 } while (0);
6668 if(NULL != pProfile)
6669 {
6670 //we need to free memory for filter if profile exists
6671 csrFreeScanFilter(pMac, pScanFilter);
6672 }
6673 }//Got the scan filter from profile
6674
Kiet Lam64c1b492013-07-12 13:56:44 +05306675 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006676 }//allocated memory for pScanFilter
6677 }//No Bsslist coming in
6678 //tell the caller if we fail to trigger a join request
6679 if( fCallCallback )
6680 {
6681 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6682 }
6683
6684 return (status);
6685}
Jeff Johnson295189b2012-06-20 16:38:30 -07006686eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6687 tCsrRoamModifyProfileFields modProfileFields,
6688 tANI_U32 *pRoamId)
6689{
6690 eHalStatus status = eHAL_STATUS_SUCCESS;
6691 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
6692 tANI_U32 roamId = 0;
6693 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006694 if (NULL == pProfile)
6695 {
6696 smsLog(pMac, LOGP, FL("No profile specified"));
6697 return eHAL_STATUS_FAILURE;
6698 }
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05306699 smsLog(pMac, LOG1, FL("called BSSType = %s (%d) authtype = %d "
6700 "encryType = %d"),
6701 lim_BssTypetoString(pProfile->BSSType),
6702 pProfile->BSSType,
6703 pProfile->AuthType.authType[0],
6704 pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006705 csrRoamCancelRoaming(pMac, sessionId);
6706 csrScanRemoveFreshScanCommand(pMac, sessionId);
6707 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306708 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006709 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07006710 if(csrIsConnStateConnected(pMac, sessionId))
6711 {
6712 if(pProfile)
6713 {
6714 if(pProfile->SSIDs.numOfSSIDs &&
6715 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6716 {
6717 fCallCallback = eANI_BOOLEAN_FALSE;
6718 }
6719 else
6720 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006721 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006722 }
6723 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306724 else if (!vos_mem_compare(&modProfileFields,
6725 &pSession->connectedProfile.modifyProfileFields,
6726 sizeof(tCsrRoamModifyProfileFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -07006727 {
6728 fCallCallback = eANI_BOOLEAN_FALSE;
6729 }
6730 else
6731 {
6732 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006733 "in tCsrRoamModifyProfileFields got modified"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006734 }
6735 }
6736 else
6737 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006738 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006739 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006740 if(!fCallCallback)
6741 {
6742 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6743 if(pRoamId)
6744 {
6745 *pRoamId = roamId;
6746 }
6747
Jeff Johnson295189b2012-06-20 16:38:30 -07006748 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
6749 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006750 }
6751 else
6752 {
6753 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
6754 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6755 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006756 return status;
6757}
Jeff Johnson295189b2012-06-20 16:38:30 -07006758eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6759{
6760 eHalStatus status = eHAL_STATUS_FAILURE;
6761 tScanResultHandle hBSSList = NULL;
6762 tCsrScanResultFilter *pScanFilter = NULL;
6763 tANI_U32 roamId;
6764 tCsrRoamProfile *pProfile = NULL;
6765 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006766
6767 if(!pSession)
6768 {
6769 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6770 return eHAL_STATUS_FAILURE;
6771 }
6772
Jeff Johnson295189b2012-06-20 16:38:30 -07006773 do
6774 {
6775 if(pSession->pCurRoamProfile)
6776 {
6777 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306778 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006779 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
Kiet Lam64c1b492013-07-12 13:56:44 +05306780 pProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
6781 if ( NULL == pProfile )
6782 status = eHAL_STATUS_FAILURE;
6783 else
6784 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006785 if(!HAL_STATUS_SUCCESS(status))
6786 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05306787 vos_mem_set(pProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006788 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05306789 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006790 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05306791 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
6792 if ( NULL == pScanFilter )
6793 status = eHAL_STATUS_FAILURE;
6794 else
6795 status = eHAL_STATUS_SUCCESS;
6796
Jeff Johnson295189b2012-06-20 16:38:30 -07006797 if(!HAL_STATUS_SUCCESS(status))
6798 {
6799 break;
6800 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306801 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006802 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6803 if(!HAL_STATUS_SUCCESS(status))
6804 {
6805 break;
6806 }
6807 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6808 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
6809 if(HAL_STATUS_SUCCESS(status))
6810 {
6811 //we want to put the last connected BSS to the very beginning, if possible
6812 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
6813 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6814 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6815 if(!HAL_STATUS_SUCCESS(status))
6816 {
6817 csrScanResultPurge(pMac, hBSSList);
6818 break;
6819 }
6820 }
6821 else
6822 {
6823 //Do a scan on this profile
6824 //scan for this SSID only in case the AP suppresses SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006825 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006826 if(!HAL_STATUS_SUCCESS(status))
6827 {
6828 break;
6829 }
6830 }
6831 }//We have a profile
6832 else
6833 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006834 smsLog(pMac, LOGW, FL("cannot find a roaming profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006835 break;
6836 }
6837 }while(0);
6838 if(pScanFilter)
6839 {
6840 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05306841 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006842 }
6843 if(NULL != pProfile)
6844 {
6845 csrReleaseProfile(pMac, pProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05306846 vos_mem_free(pProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07006847 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006848 return (status);
6849}
Jeff Johnson295189b2012-06-20 16:38:30 -07006850eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
6851{
6852 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006853 if(csrIsConnStateConnected(pMac, sessionId))
6854 {
6855 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6856 if(HAL_STATUS_SUCCESS(status))
6857 {
6858 status = csrRoamJoinLastProfile(pMac, sessionId);
6859 }
6860 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006861 return (status);
6862}
6863
Jeff Johnson295189b2012-06-20 16:38:30 -07006864eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6865{
6866 eHalStatus status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006867 smsLog(pMac, LOGW, FL("is called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006868 csrRoamCancelRoaming(pMac, sessionId);
6869 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6870 if(csrIsConnStateDisconnected(pMac, sessionId))
6871 {
6872 status = csrRoamJoinLastProfile(pMac, sessionId);
6873 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006874 return (status);
6875}
6876
Jeff Johnson295189b2012-06-20 16:38:30 -07006877eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
6878{
6879 eHalStatus status = eHAL_STATUS_SUCCESS;
6880 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
6881 eCsrRoamSubState NewSubstate;
6882 tANI_U32 sessionId = pCommand->sessionId;
6883
6884 // change state to 'Roaming'...
6885 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
6886
6887 if ( csrIsConnStateIbss( pMac, sessionId ) )
6888 {
6889 // If we are in an IBSS, then stop the IBSS...
6890 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6891 fComplete = (!HAL_STATUS_SUCCESS(status));
6892 }
6893 else if ( csrIsConnStateInfra( pMac, sessionId ) )
6894 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006895 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 -07006896 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
6897 //Restore AC weight in case we change it
6898 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
6899 // in Infrasturcture, we need to disassociate from the Infrastructure network...
6900 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
6901 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
6902 {
6903 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
6904 }
Abhishek Singhcf4590b2014-04-16 18:58:08 +05306905 else
6906 {
6907 // If we are in neighbor preauth done state then on receiving
6908 // disassoc or deauth we dont roam instead we just disassoc
6909 // from current ap and then go to disconnected state
6910 // This happens for ESE and 11r FT connections ONLY.
6911#ifdef WLAN_FEATURE_VOWIFI_11R
6912 if (csrRoamIs11rAssoc(pMac) &&
6913 (csrNeighborRoamStatePreauthDone(pMac)))
6914 {
6915 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
6916 }
6917#endif
6918#ifdef FEATURE_WLAN_ESE
6919 if (csrRoamIsESEAssoc(pMac) &&
6920 (csrNeighborRoamStatePreauthDone(pMac)))
6921 {
6922 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
6923 }
6924#endif
6925#ifdef FEATURE_WLAN_LFR
6926 if (csrRoamIsFastRoamEnabled(pMac, sessionId) &&
6927 (csrNeighborRoamStatePreauthDone(pMac)))
6928 {
6929 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
6930 }
6931#endif
6932 }
6933
Jeff Johnson295189b2012-06-20 16:38:30 -07006934 if( fDisassoc )
6935 {
6936 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
6937 }
6938 else
6939 {
6940 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
6941 }
6942 fComplete = (!HAL_STATUS_SUCCESS(status));
6943 }
6944 else if ( csrIsConnStateWds( pMac, sessionId ) )
6945 {
6946 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
6947 {
6948 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6949 fComplete = (!HAL_STATUS_SUCCESS(status));
6950 }
6951 //This has to be WDS station
6952 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
6953 {
6954
6955 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
6956 if( fDisassoc )
6957 {
6958 status = csrRoamIssueDisassociate( pMac, sessionId,
6959 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
6960 fComplete = (!HAL_STATUS_SUCCESS(status));
6961 }
6962 }
6963 } else {
6964 // we got a dis-assoc request while not connected to any peer
6965 // just complete the command
6966 fComplete = eANI_BOOLEAN_TRUE;
6967 status = eHAL_STATUS_FAILURE;
6968 }
6969 if(fComplete)
6970 {
6971 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
6972 }
6973
6974 if(HAL_STATUS_SUCCESS(status))
6975 {
6976 if ( csrIsConnStateInfra( pMac, sessionId ) )
6977 {
6978 //Set the state to disconnect here
6979 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
6980 }
6981 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006982 else
6983 {
6984 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
6985 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006986 return (status);
6987}
6988
Jeff Johnson295189b2012-06-20 16:38:30 -07006989/* This is been removed from latest code base */
6990/*
6991static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
6992{
6993 eHalStatus status;
6994 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07006995 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
6996 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07006997 return ( status );
6998}
6999*/
7000
Jeff Johnson295189b2012-06-20 16:38:30 -07007001eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
7002{
7003 eHalStatus status = eHAL_STATUS_SUCCESS;
7004 tSmeCmd *pCommand;
7005 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007006 do
7007 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08007008 smsLog( pMac, LOG1, FL(" reason = %d"), reason );
Jeff Johnson295189b2012-06-20 16:38:30 -07007009 pCommand = csrGetCommandBuffer( pMac );
7010 if ( !pCommand )
7011 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007012 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007013 status = eHAL_STATUS_RESOURCES;
7014 break;
7015 }
7016 //Change the substate in case it is wait-for-key
7017 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7018 {
7019 csrRoamStopWaitForKeyTimer( pMac );
7020 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7021 }
7022 pCommand->command = eSmeCommandRoam;
7023 pCommand->sessionId = (tANI_U8)sessionId;
7024 switch ( reason )
7025 {
7026 case eCSR_DISCONNECT_REASON_MIC_ERROR:
7027 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
7028 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007029 case eCSR_DISCONNECT_REASON_DEAUTH:
7030 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
7031 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007032 case eCSR_DISCONNECT_REASON_HANDOFF:
7033 fHighPriority = eANI_BOOLEAN_TRUE;
7034 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
7035 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007036 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
7037 case eCSR_DISCONNECT_REASON_DISASSOC:
7038 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
7039 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007040 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
7041 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
7042 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007043 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
7044 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
7045 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007046 default:
7047 break;
7048 }
7049 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7050 if( !HAL_STATUS_SUCCESS( status ) )
7051 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007052 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007053 csrReleaseCommandRoam( pMac, pCommand );
7054 }
7055 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07007056 return( status );
7057}
7058
Jeff Johnson295189b2012-06-20 16:38:30 -07007059eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
7060{
7061 eHalStatus status = eHAL_STATUS_SUCCESS;
7062 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007063 pCommand = csrGetCommandBuffer( pMac );
7064 if ( NULL != pCommand )
7065 {
7066 //Change the substate in case it is wait-for-key
7067 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
7068 {
7069 csrRoamStopWaitForKeyTimer( pMac );
7070 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7071 }
7072 pCommand->command = eSmeCommandRoam;
7073 pCommand->sessionId = (tANI_U8)sessionId;
7074 pCommand->u.roamCmd.roamReason = eCsrStopBss;
7075 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7076 if( !HAL_STATUS_SUCCESS( status ) )
7077 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007078 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007079 csrReleaseCommandRoam( pMac, pCommand );
7080 }
7081 }
7082 else
7083 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007084 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007085 status = eHAL_STATUS_RESOURCES;
7086 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007087 return ( status );
7088}
7089
Jeff Johnson295189b2012-06-20 16:38:30 -07007090eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7091{
7092 eHalStatus status = eHAL_STATUS_SUCCESS;
7093 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007094
7095 if(!pSession)
7096 {
7097 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7098 return eHAL_STATUS_FAILURE;
7099 }
7100
Jeff Johnson295189b2012-06-20 16:38:30 -07007101#ifdef FEATURE_WLAN_BTAMP_UT_RF
7102 //Stop te retry
7103 pSession->maxRetryCount = 0;
7104 csrRoamStopJoinRetryTimer(pMac, sessionId);
7105#endif
7106 //Not to call cancel roaming here
7107 //Only issue disconnect when necessary
7108 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
7109 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
7110 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
7111
7112 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007113 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007114 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
7115 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307116 else
7117 {
7118 smsLog( pMac, LOGE, FL("Roam command is not present"));
7119 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007120 return (status);
7121}
7122
Jeff Johnson295189b2012-06-20 16:38:30 -07007123eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7124{
7125 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007126
7127 if(!pSession)
7128 {
7129 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7130 return eHAL_STATUS_FAILURE;
7131 }
7132
Jeff Johnson295189b2012-06-20 16:38:30 -07007133 csrRoamCancelRoaming(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007134 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
7135
7136 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
7137}
7138
Jeff Johnson295189b2012-06-20 16:38:30 -07007139eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
7140 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
7141{
7142 eHalStatus status = eHAL_STATUS_SUCCESS;
7143 tDot11fBeaconIEs *pIesTemp = pIes;
7144 tANI_U8 index;
7145 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7146 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007147
7148 if(!pSession)
7149 {
7150 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7151 return eHAL_STATUS_FAILURE;
7152 }
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007153 if(pConnectProfile->pAddIEAssoc)
7154 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307155 vos_mem_free(pConnectProfile->pAddIEAssoc);
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007156 pConnectProfile->pAddIEAssoc = NULL;
7157 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307158 vos_mem_set(&pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007159 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
7160 pConnectProfile->AuthInfo = pProfile->AuthType;
7161 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
7162 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
7163 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
7164 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
7165 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
7166 pConnectProfile->BSSType = pProfile->BSSType;
7167 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
7168 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07007169 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
AnjaneeDevi Kapparapu4b043912014-02-18 13:22:35 +05307170 if (!pConnectProfile->beaconInterval)
7171 {
7172 smsLog(pMac, LOGW, FL("ERROR: Beacon interval is ZERO"));
7173 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307174 vos_mem_copy(&pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007175 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
7176 if(pProfile->nAddIEAssocLength)
7177 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307178 pConnectProfile->pAddIEAssoc = vos_mem_malloc(pProfile->nAddIEAssocLength);
7179 if ( NULL == pConnectProfile->pAddIEAssoc )
7180 status = eHAL_STATUS_FAILURE;
7181 else
7182 status = eHAL_STATUS_SUCCESS;
7183 if (!HAL_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007184 {
7185 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
7186 return eHAL_STATUS_FAILURE;
7187 }
7188 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05307189 vos_mem_copy(pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
7190 pProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007191 }
7192
Jeff Johnson295189b2012-06-20 16:38:30 -07007193 //Save bssid
7194 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
7195#ifdef WLAN_FEATURE_VOWIFI_11R
7196 if (pSirBssDesc->mdiePresent)
7197 {
7198 pConnectProfile->MDID.mdiePresent = 1;
7199 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
7200 }
7201#endif
Leela Venkata Kiran Kumar Reddy Chiralad48e3272013-04-12 14:21:07 -07007202 if( NULL == pIesTemp )
7203 {
7204 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
7205 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007206#ifdef FEATURE_WLAN_ESE
7207 if ((csrIsProfileESE(pProfile) ||
7208 ((pIesTemp->ESEVersion.present)
Sandeep Puligilla798d6f22014-04-24 23:30:36 +05307209 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007210 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07007211 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007212 pConnectProfile->isESEAssoc = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007213 }
7214#endif
7215 //save ssid
Jeff Johnson295189b2012-06-20 16:38:30 -07007216 if(HAL_STATUS_SUCCESS(status))
7217 {
7218 if(pIesTemp->SSID.present)
7219 {
7220 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +05307221 vos_mem_copy(pConnectProfile->SSID.ssId, pIesTemp->SSID.ssid,
7222 pIesTemp->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07007223 }
7224
7225 //Save the bss desc
7226 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307227
7228 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07007229 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307230 //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 -07007231 pConnectProfile->qap = TRUE;
7232 }
7233 else
7234 {
7235 pConnectProfile->qap = FALSE;
7236 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007237 if ( NULL == pIes )
7238 {
7239 //Free memory if it allocated locally
Kiet Lam64c1b492013-07-12 13:56:44 +05307240 vos_mem_free(pIesTemp);
Jeff Johnson295189b2012-06-20 16:38:30 -07007241 }
7242 }
7243 //Save Qos connection
7244 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
7245
7246 if(!HAL_STATUS_SUCCESS(status))
7247 {
7248 csrFreeConnectBssDesc(pMac, sessionId);
7249 }
7250 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
7251 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307252 if ((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
7253 vos_mem_compare(pProfile->SSIDs.SSIDList[index].SSID.ssId,
7254 pConnectProfile->SSID.ssId,
7255 pConnectProfile->SSID.length))
Jeff Johnson295189b2012-06-20 16:38:30 -07007256 {
7257 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
7258 break;
7259 }
7260 pConnectProfile->handoffPermitted = FALSE;
7261 }
7262
7263 return (status);
7264}
7265
Jeff Johnson295189b2012-06-20 16:38:30 -07007266static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
7267{
7268 tListElem *pEntry = NULL;
7269 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007270 //The head of the active list is the request we sent
7271 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7272 if(pEntry)
7273 {
7274 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7275 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007276 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7277 {
7278 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
7279 {
7280#ifndef WLAN_MDM_CODE_REDUCTION_OPT
7281 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7282#endif
7283 }
7284 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
7285 }
7286 else
7287 {
7288 tANI_U32 roamId = 0;
7289 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007290 if(!pSession)
7291 {
7292 smsLog(pMac, LOGE, FL(" session %d not found "), pSmeJoinRsp->sessionId);
7293 return;
7294 }
7295
Jeff Johnson295189b2012-06-20 16:38:30 -07007296
7297 //The head of the active list is the request we sent
7298 //Try to get back the same profile and roam again
7299 if(pCommand)
7300 {
7301 roamId = pCommand->u.roamCmd.roamId;
7302 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007303 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
7304 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007305 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007306#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7307 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
7308 if (csrRoamIsHandoffInProgress(pMac))
7309 {
7310 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
7311 /* Should indicate neighbor roam algorithm about the connect failure here */
7312 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
7313 }
7314#endif
7315 if (pCommand)
7316 {
7317 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
7318 {
7319 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7320 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
7321 csrRoamReissueRoamCommand(pMac);
7322 }
7323 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
7324 {
7325 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7326 }
7327 else
7328 {
7329 csrRoam(pMac, pCommand);
7330 }
7331 }
7332 else
7333 {
7334 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7335 }
7336 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
7337}
7338
Jeff Johnson295189b2012-06-20 16:38:30 -07007339eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7340 tDot11fBeaconIEs *pIes,
7341 tCsrRoamProfile *pProfile, tANI_U32 roamId )
7342{
7343 eHalStatus status;
Arif Hussain24bafea2013-11-15 15:10:03 -08007344 smsLog( pMac, LOG1, "Attempting to Join Bssid= "MAC_ADDRESS_STR,
7345 MAC_ADDR_ARRAY(pSirBssDesc->bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07007346
7347 // Set the roaming substate to 'join attempt'...
7348 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007349 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007350 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007351 return (status);
7352}
7353
Jeff Johnson295189b2012-06-20 16:38:30 -07007354static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7355 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
7356{
7357 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007358 // Set the roaming substate to 'join attempt'...
7359 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
7360
Kaushik, Sushant8489f472014-01-27 11:41:22 +05307361 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7362 FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007363
7364 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007365 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07007366}
7367
Jeff Johnson295189b2012-06-20 16:38:30 -07007368void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
7369{
7370 tListElem *pEntry;
7371 tSmeCmd *pCommand;
7372 tCsrRoamInfo roamInfo;
7373 tANI_U32 sessionId;
7374 tCsrRoamSession *pSession;
7375
7376 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7377 if(pEntry)
7378 {
7379 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7380 if ( eSmeCommandRoam == pCommand->command )
7381 {
7382 sessionId = pCommand->sessionId;
7383 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007384
7385 if(!pSession)
7386 {
7387 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7388 return;
7389 }
Abhishek Singhaf15f152013-11-30 16:08:55 +05307390 /* While switching between two AP, csr will reissue roam command again
7391 to the nextbss if it was interrupted by the dissconnect req for the
7392 previous bss.During this csr is incrementing bRefAssocStartCnt twice.
7393 so reset the bRefAssocStartCnt.
7394 */
7395 if(pSession->bRefAssocStartCnt > 0)
7396 {
7397 pSession->bRefAssocStartCnt--;
7398 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007399 if( pCommand->u.roamCmd.fStopWds )
7400 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307401 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007402 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
7403 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
7404 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007405 if (CSR_IS_WDS(&pSession->connectedProfile)){
Jeff Johnson295189b2012-06-20 16:38:30 -07007406 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
7407 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7408 eCSR_ROAM_WDS_IND,
7409 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
Jeff Johnson295189b2012-06-20 16:38:30 -07007410 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
7411 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
7412 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7413 eCSR_ROAM_INFRA_IND,
7414 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
7415 }
7416
Jeff Johnson295189b2012-06-20 16:38:30 -07007417
Jeff Johnson295189b2012-06-20 16:38:30 -07007418 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
7419 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007420 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007421 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7422 }
7423 }
7424 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
7425 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007426 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007427 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7428 }
7429 }
7430 else
7431 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007432 smsLog(pMac, LOGW, " Command is not roaming after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007433 }
7434 }
7435 else
7436 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007437 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available");
Jeff Johnson295189b2012-06-20 16:38:30 -07007438 }
7439}
7440
Jeff Johnson295189b2012-06-20 16:38:30 -07007441tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
7442{
7443 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7444 tListElem *pEntry;
7445 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007446 //alwasy lock active list before locking pending list
7447 csrLLLock( &pMac->sme.smeCmdActiveList );
7448 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7449 if(pEntry)
7450 {
7451 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7452 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7453 {
7454 fRet = eANI_BOOLEAN_TRUE;
7455 }
7456 }
7457 if(eANI_BOOLEAN_FALSE == fRet)
7458 {
7459 csrLLLock(&pMac->sme.smeCmdPendingList);
7460 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
7461 while(pEntry)
7462 {
7463 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7464 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7465 {
7466 fRet = eANI_BOOLEAN_TRUE;
7467 break;
7468 }
7469 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7470 }
7471 csrLLUnlock(&pMac->sme.smeCmdPendingList);
7472 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307473 if (eANI_BOOLEAN_FALSE == fRet)
7474 {
7475 csrLLLock(&pMac->roam.roamCmdPendingList);
7476 pEntry = csrLLPeekHead(&pMac->roam.roamCmdPendingList, LL_ACCESS_NOLOCK);
7477 while (pEntry)
7478 {
7479 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7480 if (( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7481 {
7482 fRet = eANI_BOOLEAN_TRUE;
7483 break;
7484 }
7485 pEntry = csrLLNext(&pMac->roam.roamCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7486 }
7487 csrLLUnlock(&pMac->roam.roamCmdPendingList);
7488 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007489 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007490 return (fRet);
7491}
7492
Jeff Johnson295189b2012-06-20 16:38:30 -07007493tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
7494{
7495 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7496 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07007497 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
7498 {
7499 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
7500 {
7501 break;
7502 }
7503 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007504 return ( fRet );
7505}
7506
Jeff Johnson295189b2012-06-20 16:38:30 -07007507tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
7508{
7509 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007510 //alwasy lock active list before locking pending list
7511 csrLLLock( &pMac->sme.smeCmdActiveList );
7512 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7513 if(eANI_BOOLEAN_FALSE == fRet)
7514 {
7515 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
7516 }
7517 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007518 return (fRet);
7519}
7520
Jeff Johnson295189b2012-06-20 16:38:30 -07007521tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
7522{
7523 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7524 tListElem *pEntry;
7525 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007526 //alwasy lock active list before locking pending list
7527 csrLLLock( &pMac->sme.smeCmdActiveList );
7528 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7529 if( pEntry )
7530 {
7531 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
7532 if( ( eCsrRoamCommandScan == pCommand->command ) &&
7533 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
7534 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
7535 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
7536 {
7537 fRet = eANI_BOOLEAN_TRUE;
7538 }
7539 }
7540 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007541 return (fRet);
7542}
Jeff Johnson295189b2012-06-20 16:38:30 -07007543eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
7544{
7545 eHalStatus status = eHAL_STATUS_SUCCESS;
7546 tSmeCmd *pCommand = NULL;
7547 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
7548 tANI_BOOLEAN fRemoveCmd = FALSE;
7549 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07007550 // Delete the old assoc command. All is setup for reassoc to be serialized
7551 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7552 if ( pEntry )
7553 {
7554 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
7555 if ( !pCommand )
7556 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007557 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007558 return eHAL_STATUS_RESOURCES;
7559 }
7560 if ( eSmeCommandRoam == pCommand->command )
7561 {
7562 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
7563 {
7564 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7565 }
7566 else
7567 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007568 smsLog( pMac, LOGE, FL(" Unexpected active roam command present ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007569 }
7570 if (fRemoveCmd == FALSE)
7571 {
7572 // Implies we did not get the serialized assoc command we
7573 // were expecting
7574 pCommand = NULL;
7575 }
7576 }
7577 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007578 if(NULL == pCommand)
7579 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007580 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007581 return eHAL_STATUS_RESOURCES;
7582 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007583 do
7584 {
7585 //Change the substate in case it is wait-for-key
7586 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7587 {
7588 csrRoamStopWaitForKeyTimer( pMac );
7589 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
7590 }
7591 pCommand->command = eSmeCommandRoam;
7592 pCommand->sessionId = (tANI_U8)sessionId;
7593 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07007594 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7595 if( !HAL_STATUS_SUCCESS( status ) )
7596 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007597 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007598 csrReleaseCommandRoam( pMac, pCommand );
7599 }
7600 } while( 0 );
7601
Jeff Johnson295189b2012-06-20 16:38:30 -07007602 return( status );
7603}
7604static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
7605{
7606 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7607 tCsrScanResult *pScanResult = NULL;
7608 tSirBssDescription *pBssDesc = NULL;
7609 tSmeCmd *pCommand = NULL;
7610 tANI_U32 sessionId;
7611 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07007612 if(NULL == pEntry)
7613 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307614 smsLog(pMac, LOGE, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07007615 return;
7616 }
7617 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7618 sessionId = pCommand->sessionId;
7619 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007620
7621 if(!pSession)
7622 {
7623 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7624 return;
7625 }
7626
Jeff Johnson295189b2012-06-20 16:38:30 -07007627 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
7628 {
7629 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007630 smsLog(pMac, LOGW, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007631 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7632 }
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07007633 /* If the roaming has stopped, not to continue the roaming command*/
7634 else if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
7635 {
7636 //No need to complete roaming here as it already completes
7637 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed\n"),
7638 pCommand->u.roamCmd.roamReason);
7639 csrSetAbortRoamingCommand( pMac, pCommand );
7640 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7641 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007642 else
7643 {
7644 if ( CCM_IS_RESULT_SUCCESS(result) )
7645 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007646 smsLog(pMac, LOG2, "Cfg sequence complete");
Jeff Johnson295189b2012-06-20 16:38:30 -07007647 // Successfully set the configuration parameters for the new Bss. Attempt to
7648 // join the roaming Bss.
7649 if(pCommand->u.roamCmd.pRoamBssEntry)
7650 {
7651 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
7652 pBssDesc = &pScanResult->Result.BssDescriptor;
7653 }
7654 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
7655 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07007656 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07007657 )
7658 {
7659 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
7660 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
7661 pBssDesc, pCommand->u.roamCmd.roamId )))
7662 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307663 smsLog(pMac, LOGE, " CSR start BSS failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07007664 //We need to complete the command
7665 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7666 }
7667 }
7668 else
7669 {
7670 if (!pCommand->u.roamCmd.pRoamBssEntry)
7671 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307672 smsLog(pMac, LOGE, " pRoamBssEntry is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07007673 //We need to complete the command
7674 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
7675 return;
7676 }
7677 // If we are roaming TO an Infrastructure BSS...
7678 VOS_ASSERT(pScanResult != NULL);
7679 if ( csrIsInfraBssDesc( pBssDesc ) )
7680 {
7681 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07007682 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
7683 {
7684 // ..and currently in an Infrastructure connection....
7685 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
7686 {
7687 // ...and the SSIDs are equal, then we Reassoc.
7688 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
7689 pIesLocal ) )
7690 // ..and currently in an infrastructure connection
7691 {
7692 // then issue a Reassoc.
7693 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
7694 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
7695 &pCommand->u.roamCmd.roamProfile );
7696 }
7697 else
7698 {
7699
7700 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
7701 // previously associated AP.
7702 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7703 pIesLocal,
7704 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
7705 {
7706 //try something else
7707 csrRoam( pMac, pCommand );
7708 }
7709 }
7710 }
7711 else
7712 {
7713 eHalStatus status = eHAL_STATUS_SUCCESS;
7714
7715 /* We need to come with other way to figure out that this is because of HO in BMP
7716 The below API will be only available for Android as it uses a different HO algorithm */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007717 /* Reassoc request will be used only for ESE and 11r handoff whereas other legacy roaming should
Jeff Johnson295189b2012-06-20 16:38:30 -07007718 * use join request */
7719#ifdef WLAN_FEATURE_VOWIFI_11R
7720 if (csrRoamIsHandoffInProgress(pMac) &&
7721 csrRoamIs11rAssoc(pMac))
7722 {
7723 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
7724 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
7725 }
7726 else
7727#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007728#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07007729 if (csrRoamIsHandoffInProgress(pMac) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007730 csrRoamIsESEAssoc(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07007731 {
7732 // Now serialize the reassoc command.
7733 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7734 }
7735 else
7736#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007737#ifdef FEATURE_WLAN_LFR
7738 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05307739 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007740 {
7741 // Now serialize the reassoc command.
7742 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7743 }
7744 else
7745#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007746 // else we are not connected and attempting to Join. Issue the
7747 // Join request.
7748 {
7749 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7750 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
7751 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
7752 }
7753 if(!HAL_STATUS_SUCCESS(status))
7754 {
7755 //try something else
7756 csrRoam( pMac, pCommand );
7757 }
7758 }
7759 if( !pScanResult->Result.pvIes )
7760 {
7761 //Locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05307762 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07007763 }
7764 }
7765 }//if ( csrIsInfraBssDesc( pBssDesc ) )
7766 else
7767 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007768 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007769 }
7770 }//else
7771 }//if ( WNI_CFG_SUCCESS == result )
7772 else
7773 {
7774 // In the event the configuration failed, for infra let the roam processor
7775 //attempt to join something else...
7776 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
7777 {
7778 csrRoam(pMac, pCommand);
7779 }
7780 else
7781 {
7782 //We need to complete the command
7783 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
7784 {
7785 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7786 }
7787 else
7788 {
7789 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7790 }
7791 }
7792 }
7793 }//we have active entry
7794}
7795
Jeff Johnson295189b2012-06-20 16:38:30 -07007796static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
7797{
7798 //No one is sending eWNI_SME_AUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007799 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007800 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
7801 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007802 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007803 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
7804 // join the new one...
7805 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07007806 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
7807 }
7808 else {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007809 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08X [%d]", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007810 /***profHandleLostLinkAfterReset(pAdapter);
7811 // In the event the authenticate fails, let the roam processor attempt to join something else...
7812 roamRoam( pAdapter );***/
7813 }
7814}
7815
Jeff Johnson295189b2012-06-20 16:38:30 -07007816static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
7817{
7818 eCsrRoamCompleteResult result;
7819 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
7820 tCsrRoamInfo roamInfo;
7821 tANI_U32 roamId = 0;
7822
7823 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7824 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007825 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007826 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07007827 /* Defeaturize this part later if needed */
7828#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
7829 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
7830 * we need the response contents while processing the result in csrRoamProcessResults() */
7831 if (csrRoamIsHandoffInProgress(pMac))
7832 {
7833 /* Need to dig more on indicating events to SME QoS module */
7834 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7835 csrRoamComplete( pMac, result, pSmeJoinRsp);
7836 }
7837 else
7838#endif
7839 {
7840 csrRoamComplete( pMac, result, NULL );
7841 }
7842 }
7843 /* Should we handle this similar to handling the join failure? Is it ok
7844 * to call csrRoamComplete() with state as CsrJoinFailure */
7845 else
7846 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007847 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007848 result = eCsrReassocFailure;
7849#ifdef WLAN_FEATURE_VOWIFI_11R
7850 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
7851 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode))
7852 {
7853 // Inform HDD to turn off FT flag in HDD
7854 if (pNeighborRoamInfo)
7855 {
7856 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7857 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
7858 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07007859 /*
7860 * Since the above callback sends a disconnect
7861 * to HDD, we should clean-up our state
7862 * machine as well to be in sync with the upper
7863 * layers. There is no need to send a disassoc
7864 * since: 1) we will never reassoc to the current
7865 * AP in LFR, and 2) there is no need to issue a
7866 * disassoc to the AP with which we were trying
7867 * to reassoc.
7868 */
7869 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7870 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07007871 }
7872 }
7873#endif
7874 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
7875 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
7876 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
7877 //The disassoc rsp message will remove the command from active list
7878 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
7879 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
7880 {
7881 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7882 }
7883 }
7884}
7885
Jeff Johnson295189b2012-06-20 16:38:30 -07007886static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
7887{
Jeff Johnson295189b2012-06-20 16:38:30 -07007888#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7889 {
7890 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07007891 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
7892 if(pIbssLog)
7893 {
7894 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
7895 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
7896 {
7897 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
7898 }
7899 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
7900 }
7901 }
7902#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07007903 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7904 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
7905 {
7906 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7907 }
7908 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
7909 {
7910 csrRoamReissueRoamCommand(pMac);
7911 }
7912}
7913
Jeff Johnson295189b2012-06-20 16:38:30 -07007914void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
7915{
7916 tSirResultCodes statusCode;
7917#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7918 tScanResultHandle hBSSList;
7919 tANI_BOOLEAN fCallCallback, fRemoveCmd;
7920 eHalStatus status;
7921 tCsrRoamInfo roamInfo;
7922 tCsrScanResultFilter *pScanFilter = NULL;
7923 tANI_U32 roamId = 0;
7924 tCsrRoamProfile *pCurRoamProfile = NULL;
7925 tListElem *pEntry = NULL;
7926 tSmeCmd *pCommand = NULL;
7927#endif
7928 tANI_U32 sessionId;
7929 tCsrRoamSession *pSession;
Jeff Johnsone7245742012-09-05 17:12:55 -07007930
Jeff Johnson295189b2012-06-20 16:38:30 -07007931 tSirSmeDisassocRsp SmeDisassocRsp;
7932
7933 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
7934 sessionId = SmeDisassocRsp.sessionId;
7935 statusCode = SmeDisassocRsp.statusCode;
7936
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007937 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007938
7939 if ( csrIsConnStateInfra( pMac, sessionId ) )
7940 {
7941 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7942 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007943 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007944
7945 if(!pSession)
7946 {
7947 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7948 return;
7949 }
7950
Jeff Johnson295189b2012-06-20 16:38:30 -07007951 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
7952 {
7953 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7954 }
7955 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
7956 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
7957 {
7958 if ( eSIR_SME_SUCCESS == statusCode )
7959 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007960 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007961 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
7962 }
7963 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7964 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007965 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
7966 {
Kaushik, Sushant8489f472014-01-27 11:41:22 +05307967 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH,
7968 "CSR SmeDisassocReq due to HO on session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007969#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007970 /*
7971 * First ensure if the roam profile is in the scan cache.
7972 * If not, post a reassoc failure and disconnect.
7973 */
Kiet Lam64c1b492013-07-12 13:56:44 +05307974 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
7975 if ( NULL == pScanFilter )
7976 status = eHAL_STATUS_FAILURE;
7977 else
7978 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007979 if(HAL_STATUS_SUCCESS(status))
7980 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307981 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007982 status = csrRoamPrepareFilterFromProfile(pMac,
7983 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
7984 if(!HAL_STATUS_SUCCESS(status))
7985 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007986 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007987 __func__, status);
7988 goto POST_ROAM_FAILURE;
7989 }
7990 else
7991 {
7992 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
7993 if (!HAL_STATUS_SUCCESS(status))
7994 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007995 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007996 __func__, status);
7997 goto POST_ROAM_FAILURE;
7998 }
7999 }
8000 }
8001 else
8002 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008003 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008004 __func__, status);
8005 goto POST_ROAM_FAILURE;
8006 }
8007
8008 /*
8009 * After ensuring that the roam profile is in the scan result list,
8010 * dequeue the command from the active list.
8011 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008012 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
8013 if ( pEntry )
8014 {
8015 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008016 /* If the head of the queue is Active and it is a ROAM command, remove
8017 * and put this on the Free queue.
8018 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008019 if ( eSmeCommandRoam == pCommand->command )
8020 {
Jeff Johnsone7245742012-09-05 17:12:55 -07008021
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008022 /*
8023 * we need to process the result first before removing it from active list
8024 * because state changes still happening insides roamQProcessRoamResults so
8025 * no other roam command should be issued.
8026 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008027 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
8028 if(pCommand->u.roamCmd.fReleaseProfile)
8029 {
8030 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
8031 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
8032 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008033 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07008034 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07008035 else
8036 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008037 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008038 __func__, pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07008039 }
8040 }
8041 else
8042 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008043 smsLog( pMac, LOGE, "%s: roam command not active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008044 }
8045 }
8046 else
8047 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008048 smsLog( pMac, LOGE, "%s: NO commands are active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008049 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008050
8051 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07008052 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
8053
Kiet Lam64c1b492013-07-12 13:56:44 +05308054 vos_mem_copy(roamInfo.bssid,
8055 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
8056 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008057
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008058 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
8059 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008060
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008061 /* Copy the connected profile to apply the same for this connection as well */
Kiet Lam64c1b492013-07-12 13:56:44 +05308062 pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
8063 if ( pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07008064 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308065 vos_mem_set(pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008066 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
8067 //make sure to put it at the head of the cmd queue
8068 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
8069 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
8070 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
8071
Jeff Johnson295189b2012-06-20 16:38:30 -07008072 if(!HAL_STATUS_SUCCESS(status))
8073 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008074 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008075 __func__, status);
8076 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008077 }
8078
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008079 /* Notify sub-modules like QoS etc. that handoff happening */
8080 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08008081 csrReleaseProfile(pMac, pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05308082 vos_mem_free(pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07008083 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308084 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008085 return;
8086 }
8087
8088POST_ROAM_FAILURE:
8089 if (pScanFilter)
8090 {
8091 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308092 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008093 }
8094 if (pCurRoamProfile)
Kiet Lam64c1b492013-07-12 13:56:44 +05308095 vos_mem_free(pCurRoamProfile);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008096
8097 /* Inform the upper layers that the reassoc failed */
8098 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
8099 csrRoamCallCallback(pMac, sessionId,
8100 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
8101
8102 /*
8103 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
8104 * Upon success, we would re-enter this routine after receiving the disassoc
8105 * response and will fall into the reassoc fail sub-state. And, eventually
8106 * call csrRoamComplete which would remove the roam command from SME active
8107 * queue.
8108 */
8109 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
8110 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
8111 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008112 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008113 __func__, status);
8114 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07008115 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008116#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008117
Jeff Johnson295189b2012-06-20 16:38:30 -07008118 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
8119 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
8120 {
8121 // Disassoc due to Reassoc failure falls into this codepath....
8122 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8123 }
8124 else
8125 {
8126 if ( eSIR_SME_SUCCESS == statusCode )
8127 {
8128 // Successfully disassociated from the 'old' Bss...
8129 //
8130 // We get Disassociate response in three conditions.
8131 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
8132 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
8133 // Infrastructure network.
8134 // - Third is where we are doing an Infra to Infra roam between networks with different
8135 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
8136
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008137 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008138 }
8139 else
8140 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008141 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008142 }
8143 //We are not done yet. Get the data and continue roaming
8144 csrRoamReissueRoamCommand(pMac);
8145 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008146}
8147
Jeff Johnson295189b2012-06-20 16:38:30 -07008148static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
8149{
8150 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008151 //No one is sending eWNI_SME_DEAUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008152 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008153 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08008154 pMac->roam.deauthRspStatus = statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008155 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
8156 {
8157 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8158 }
8159 else
8160 {
8161 if ( eSIR_SME_SUCCESS == statusCode )
8162 {
8163 // Successfully deauth from the 'old' Bss...
8164 //
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008165 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008166 }
8167 else
8168 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008169 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008170 }
8171 //We are not done yet. Get the data and continue roaming
8172 csrRoamReissueRoamCommand(pMac);
8173 }
8174}
8175
Jeff Johnson295189b2012-06-20 16:38:30 -07008176static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
8177{
8178 eCsrRoamCompleteResult result;
8179
8180 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
8181 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008182 smsLog( pMac, LOGW, "SmeStartBssReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008183 result = eCsrStartBssSuccess;
8184 }
8185 else
8186 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008187 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08X", pSmeStartBssRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008188 //Let csrRoamComplete decide what to do
8189 result = eCsrStartBssFailure;
8190 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008191 csrRoamComplete( pMac, result, pSmeStartBssRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -07008192}
8193
Jeff Johnson295189b2012-06-20 16:38:30 -07008194/*
8195 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
8196 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
8197 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
8198 For the messages where sender allocates memory for specific structures, then it can be
8199 cast accordingly.
8200*/
8201void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8202{
8203 tSirSmeRsp *pSmeRsp;
8204 tSmeIbssPeerInd *pIbssPeerInd;
8205 tCsrRoamInfo roamInfo;
8206 // TODO Session Id need to be acquired in this function
8207 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008208 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308209 smsLog(pMac, LOG2, FL("Message %d[0x%04X] received in substate %s"),
8210 pSmeRsp->messageType, pSmeRsp->messageType,
8211 macTraceGetcsrRoamSubState(
8212 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008213 pSmeRsp->messageType = (pSmeRsp->messageType);
8214 pSmeRsp->length = (pSmeRsp->length);
8215 pSmeRsp->statusCode = (pSmeRsp->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008216 switch (pSmeRsp->messageType)
8217 {
8218
8219 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
8220 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
8221 {
8222 //We sent a JOIN_REQ
8223 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
8224 }
8225 break;
8226
8227 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
8228 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
8229 {
8230 //We sent a AUTH_REQ
8231 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
8232 }
8233 break;
8234
8235 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
8236 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
8237 {
8238 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
8239 }
8240 break;
8241
8242 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
8243 {
8244 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
8245 }
8246 break;
8247
8248 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
8249 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
8250 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
8251 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
8252 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
8253 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
8254//HO
8255 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
8256 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308257 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %s"),
8258 macTraceGetcsrRoamSubState(
8259 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008260 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
8261 }
8262 break;
8263
8264 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
8265 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
8266 {
8267 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
8268 }
8269 break;
8270
8271 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
8272 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
8273 {
8274 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
8275 }
8276 break;
8277
8278 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
8279 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
8280 {
8281 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
8282 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008283 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008284 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
8285 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
8286 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008287 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state");
Kiet Lam64c1b492013-07-12 13:56:44 +05308288 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
8289 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008290 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
8291 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05308292 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
8293 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008294 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
8295 eCSR_ROAM_CONNECT_STATUS_UPDATE,
8296 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
8297 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008298 default:
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308299 smsLog(pMac, LOG1,
8300 FL("Unexpected message type = %d[0x%X] received in substate %s"),
8301 pSmeRsp->messageType, pSmeRsp->messageType,
8302 macTraceGetcsrRoamSubState(
8303 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008304
8305 //If we are connected, check the link status change
8306 if(!csrIsConnStateDisconnected(pMac, sessionId))
8307 {
8308 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
8309 }
8310 break;
8311 }
8312}
8313
Jeff Johnson295189b2012-06-20 16:38:30 -07008314void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8315{
8316 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07008317 switch (pSirMsg->messageType)
8318 {
8319 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008320 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008321 csrRoamStatsRspProcessor( pMac, pSirMsg );
8322 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008323 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
8324 {
8325 tCsrRoamSession *pSession;
8326 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
8327 tCsrRoamInfo roamInfo;
8328 tCsrRoamInfo *pRoamInfo = NULL;
8329 tANI_U32 sessionId;
8330 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008331 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer "));
Kiet Lam64c1b492013-07-12 13:56:44 +05308332 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008333 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07008334 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
8335 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
8336 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008337
8338 if(!pSession)
8339 {
8340 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8341 return;
8342 }
8343
Jeff Johnson295189b2012-06-20 16:38:30 -07008344 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
8345 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07008346 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
8347 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
8348 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07008349 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
8350 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05308351 vos_mem_copy(pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr,
8352 sizeof(tSirMacAddr));
8353 vos_mem_copy(&pRoamInfo->bssid, pUpperLayerAssocCnf->bssId,
8354 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008355 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07008356 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
8357 {
8358 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
8359 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
8360 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
8361 }
8362 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8363 {
8364 vos_sleep( 100 );
8365 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
8366 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
8367 }
8368
Jeff Johnson295189b2012-06-20 16:38:30 -07008369 }
8370 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008371 default:
8372 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
8373 break;
8374 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008375}
8376
Jeff Johnson295189b2012-06-20 16:38:30 -07008377eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
8378 tSirBssDescription *pBssDescription,
8379 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
8380 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
8381 tANI_U8 keyId, tANI_U16 keyLength,
8382 tANI_U8 *pKey, tANI_U8 paeRole )
8383{
8384 eHalStatus status = eHAL_STATUS_SUCCESS;
8385 tAniEdType edType;
8386
8387 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
8388 {
8389 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
8390 }
8391
8392 edType = csrTranslateEncryptTypeToEdType( EncryptType );
8393
8394 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
8395 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
8396 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
8397 addKey )
8398 {
8399 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07008400 setKey.encType = EncryptType;
8401 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308402 vos_mem_copy(&setKey.peerMac, bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008403 setKey.paeRole = paeRole; //0 for supplicant
8404 setKey.keyId = keyId; // Kye index
8405 setKey.keyLength = keyLength;
8406 if( keyLength )
8407 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308408 vos_mem_copy(setKey.Key, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008409 }
8410 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
8411 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008412 return (status);
8413}
8414
Jeff Johnson295189b2012-06-20 16:38:30 -07008415static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8416 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8417{
8418 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8419 tSmeCmd *pCommand = NULL;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008420#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008421 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008422#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07008423
8424 do
8425 {
8426 pCommand = csrGetCommandBuffer(pMac);
8427 if(NULL == pCommand)
8428 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008429 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008430 status = eHAL_STATUS_RESOURCES;
8431 break;
8432 }
8433 pCommand->command = eSmeCommandSetKey;
8434 pCommand->sessionId = (tANI_U8)sessionId;
8435 // validate the key length, Adjust if too long...
8436 // for static WEP the keys are not set thru' SetContextReq
8437 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
8438 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
8439 {
8440 //KeyLength maybe 0 for static WEP
8441 if( pSetKey->keyLength )
8442 {
8443 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
8444 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008445 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008446 break;
8447 }
8448
8449 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308450 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8451 CSR_WEP40_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008452 }
8453 }
8454 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
8455 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
8456 {
8457 //KeyLength maybe 0 for static WEP
8458 if( pSetKey->keyLength )
8459 {
8460 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
8461 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008462 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008463 break;
8464 }
8465
8466 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308467 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8468 CSR_WEP104_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008469 }
8470 }
8471 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
8472 {
8473 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
8474 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008475 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008476 break;
8477 }
8478 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308479 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8480 CSR_TKIP_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008481 }
8482 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
8483 {
8484 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
8485 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008486 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008487 break;
8488 }
8489 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308490 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8491 CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008492 }
8493#ifdef FEATURE_WLAN_WAPI
8494 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
8495 {
8496 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
8497 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008498 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008499 break;
8500 }
8501 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308502 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8503 CSR_WAPI_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008504 }
8505#endif /* FEATURE_WLAN_WAPI */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008506#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008507 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8508 {
8509 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
8510 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008511 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008512 break;
8513 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008514 vos_mem_copy(pSession->eseCckmInfo.krk, pSetKey->Key,
Kiet Lam64c1b492013-07-12 13:56:44 +05308515 CSR_KRK_KEY_LEN);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008516 pSession->eseCckmInfo.reassoc_req_num=1;
8517 pSession->eseCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008518 status = eHAL_STATUS_SUCCESS;
8519 break;
8520 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008521#endif /* FEATURE_WLAN_ESE */
Jeff Johnsone7245742012-09-05 17:12:55 -07008522
Jeff Johnson295189b2012-06-20 16:38:30 -07008523#ifdef WLAN_FEATURE_11W
8524 //Check for 11w BIP
Chet Lanctot186b5732013-03-18 10:26:30 -07008525 else if (eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008526 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008527 if (pSetKey->keyLength < CSR_AES_KEY_LEN)
Jeff Johnson295189b2012-06-20 16:38:30 -07008528 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008529 smsLog(pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008530 break;
8531 }
8532 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308533 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008534 }
8535#endif
8536 status = eHAL_STATUS_SUCCESS;
8537 pCommand->u.setKeyCmd.roamId = roamId;
8538 pCommand->u.setKeyCmd.encType = pSetKey->encType;
8539 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308540 vos_mem_copy(&pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac,
8541 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008542 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
8543 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
Kiet Lam64c1b492013-07-12 13:56:44 +05308544 vos_mem_copy(pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008545 //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
8546
8547 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
8548 if( !HAL_STATUS_SUCCESS( status ) )
8549 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008550 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008551 }
8552 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008553 // Free the command if there has been a failure, or it is a
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008554 // "local" operation like the set ESE CCKM KRK key.
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008555 if ( ( NULL != pCommand ) &&
8556 ( (!HAL_STATUS_SUCCESS( status ) )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008557#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008558 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008559#endif /* FEATURE_WLAN_ESE */
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008560 ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008561 {
8562 csrReleaseCommandSetKey( pMac, pCommand );
8563 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008564 return( status );
8565}
8566
Jeff Johnson295189b2012-06-20 16:38:30 -07008567eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8568 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
8569{
8570 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8571 tSmeCmd *pCommand = NULL;
8572 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008573 do
8574 {
8575 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8576 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008577 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008578 status = eHAL_STATUS_CSR_WRONG_STATE;
8579 break;
8580 }
8581 pCommand = csrGetCommandBuffer(pMac);
8582 if(NULL == pCommand)
8583 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008584 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008585 status = eHAL_STATUS_RESOURCES;
8586 break;
8587 }
8588 pCommand->command = eSmeCommandRemoveKey;
8589 pCommand->sessionId = (tANI_U8)sessionId;
8590 pCommand->u.removeKeyCmd.roamId = roamId;
8591 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
Kiet Lam64c1b492013-07-12 13:56:44 +05308592 vos_mem_copy(&pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac,
8593 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008594 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
8595 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8596 {
8597 //in this case, put it to the end of the Q incase there is a set key pending.
8598 fImediate = eANI_BOOLEAN_FALSE;
8599 }
Arif Hussain24bafea2013-11-15 15:10:03 -08008600 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac="MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07008601 pRemoveKey->encType, pRemoveKey->keyId,
Arif Hussain24bafea2013-11-15 15:10:03 -08008602 MAC_ADDR_ARRAY(pCommand->u.removeKeyCmd.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07008603 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
8604 if( !HAL_STATUS_SUCCESS( status ) )
8605 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008606 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008607 break;
8608 }
8609 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008610 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
8611 {
8612 csrReleaseCommandRemoveKey( pMac, pCommand );
8613 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008614 return (status );
8615}
8616
Jeff Johnson295189b2012-06-20 16:38:30 -07008617eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8618{
8619 eHalStatus status;
8620 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
8621 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
8622 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
8623 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008624#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8625 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8626 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
lukez3c809222013-05-03 10:23:02 -07008627 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008628 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308629 vos_mem_set(&setKeyEvent,
8630 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008631 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8632 {
8633 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_REQ;
8634 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8635 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8636 }
8637 else
8638 {
8639 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_REQ;
8640 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8641 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8642 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308643 vos_mem_copy(setKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
lukez3c809222013-05-03 10:23:02 -07008644 if(CSR_IS_ENC_TYPE_STATIC(pCommand->u.setKeyCmd.encType))
Jeff Johnson295189b2012-06-20 16:38:30 -07008645 {
8646 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008647 //It has to be static WEP here
8648 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
8649 {
8650 setKeyEvent.keyId = (v_U8_t)defKeyId;
8651 }
8652 }
8653 else
8654 {
8655 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
8656 }
8657 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8658 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8659 }
8660#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008661 if( csrIsSetKeyAllowed(pMac, sessionId) )
8662 {
8663 status = csrSendMBSetContextReqMsg( pMac, sessionId,
8664 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
8665 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
8666 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
8667 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
8668 pCommand->u.setKeyCmd.keyRsc);
8669 }
8670 else
8671 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008672 smsLog( pMac, LOGW, FL(" cannot process not connected") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008673 //Set this status so the error handling take care of the case.
8674 status = eHAL_STATUS_CSR_WRONG_STATE;
8675 }
8676 if( !HAL_STATUS_SUCCESS(status) )
8677 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008678 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008679 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008680#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
lukez3c809222013-05-03 10:23:02 -07008681 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008682 {
8683 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8684 {
8685 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
8686 }
8687 else
8688 {
8689 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
8690 }
8691 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
8692 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8693 }
8694#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008695 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008696 return ( status );
8697}
8698
Jeff Johnson295189b2012-06-20 16:38:30 -07008699eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8700{
8701 eHalStatus status;
8702 tpSirSmeRemoveKeyReq pMsg = NULL;
8703 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
8704 tANI_U8 *p;
8705 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008706#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8707 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8708 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +05308709 vos_mem_set(&removeKeyEvent,
8710 sizeof(vos_event_wlan_security_payload_type),0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008711 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
8712 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8713 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05308714 vos_mem_copy(removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07008715 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
8716 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8717 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8718#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008719 if( csrIsSetKeyAllowed(pMac, sessionId) )
8720 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308721 pMsg = vos_mem_malloc(wMsgLen);
8722 if ( NULL == pMsg )
8723 status = eHAL_STATUS_FAILURE;
8724 else
8725 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008726 }
8727 else
8728 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008729 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008730 //Set the error status so error handling kicks in below
8731 status = eHAL_STATUS_CSR_WRONG_STATE;
8732 }
8733 if( HAL_STATUS_SUCCESS( status ) )
8734 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308735 vos_mem_set(pMsg, wMsgLen ,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008736 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
8737 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008738 pMsg->sessionId = (tANI_U8)sessionId;
8739 pMsg->transactionId = 0;
8740 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
8741 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
8742 // bssId - copy from session Info
Kiet Lam64c1b492013-07-12 13:56:44 +05308743 vos_mem_copy(p,
8744 &pMac->roam.roamSession[sessionId].connectedProfile.bssid,
8745 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008746 p += sizeof(tSirMacAddr);
8747 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +05308748 vos_mem_copy(p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008749 p += sizeof(tSirMacAddr);
8750 // edType
8751 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
8752 p++;
8753 // weptype
8754 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
8755 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
8756 {
8757 *p = (tANI_U8)eSIR_WEP_STATIC;
8758 }
8759 else
8760 {
8761 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
8762 }
8763 p++;
8764 //keyid
8765 *p = pCommand->u.removeKeyCmd.keyId;
8766 p++;
8767 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008768 status = palSendMBMessage(pMac->hHdd, pMsg);
8769 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008770 if( !HAL_STATUS_SUCCESS( status ) )
8771 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008772 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008773#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8774 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07008775 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008776 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8777#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008778 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
8779 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008780 return ( status );
8781}
8782
Jeff Johnson295189b2012-06-20 16:38:30 -07008783eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8784{
8785 eHalStatus status;
8786
8787 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8788 {
8789 status = eHAL_STATUS_CSR_WRONG_STATE;
8790 }
8791 else
8792 {
8793 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
8794 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008795 return ( status );
8796}
8797
Jeff Johnson295189b2012-06-20 16:38:30 -07008798/*
8799 Prepare a filter base on a profile for parsing the scan results.
8800 Upon successful return, caller MUST call csrFreeScanFilter on
8801 pScanFilter when it is done with the filter.
8802*/
8803eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
8804 tCsrScanResultFilter *pScanFilter)
8805{
8806 eHalStatus status = eHAL_STATUS_SUCCESS;
8807 tANI_U32 size = 0;
8808 tANI_U8 index = 0;
8809
8810 do
8811 {
8812 if(pProfile->BSSIDs.numOfBSSIDs)
8813 {
8814 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308815 pScanFilter->BSSIDs.bssid = vos_mem_malloc(size);
8816 if ( NULL == pScanFilter->BSSIDs.bssid )
8817 status = eHAL_STATUS_FAILURE;
8818 else
8819 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008820 if(!HAL_STATUS_SUCCESS(status))
8821 {
8822 break;
8823 }
8824 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308825 vos_mem_copy(pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07008826 }
8827 if(pProfile->SSIDs.numOfSSIDs)
8828 {
8829 if( !CSR_IS_WDS_STA( pProfile ) )
8830 {
8831 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
8832 }
8833 else
8834 {
8835 //For WDS station
8836 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
8837 pScanFilter->SSIDs.numOfSSIDs = 1;
8838 }
8839 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308840 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(size);
8841 if ( NULL == pScanFilter->SSIDs.SSIDList )
8842 status = eHAL_STATUS_FAILURE;
8843 else
8844 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008845 if(!HAL_STATUS_SUCCESS(status))
8846 {
8847 break;
8848 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308849 vos_mem_copy(pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList,
8850 size);
Jeff Johnson295189b2012-06-20 16:38:30 -07008851 }
8852 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
8853 {
8854 pScanFilter->ChannelInfo.numOfChannels = 0;
8855 pScanFilter->ChannelInfo.ChannelList = NULL;
8856 }
8857 else if(pProfile->ChannelInfo.numOfChannels)
8858 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308859 pScanFilter->ChannelInfo.ChannelList = vos_mem_malloc(
8860 sizeof(*pScanFilter->ChannelInfo.ChannelList) *
8861 pProfile->ChannelInfo.numOfChannels);
8862 if ( NULL == pScanFilter->ChannelInfo.ChannelList )
8863 status = eHAL_STATUS_FAILURE;
8864 else
8865 status = eHAL_STATUS_SUCCESS;
8866
Jeff Johnson295189b2012-06-20 16:38:30 -07008867 pScanFilter->ChannelInfo.numOfChannels = 0;
8868 if(HAL_STATUS_SUCCESS(status))
8869 {
8870 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
8871 {
8872 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
8873 {
8874 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
8875 = pProfile->ChannelInfo.ChannelList[index];
8876 pScanFilter->ChannelInfo.numOfChannels++;
8877 }
8878 else
8879 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008880 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid"), pProfile->ChannelInfo.ChannelList[index]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008881 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008882 }
8883 }
8884 else
8885 {
8886 break;
8887 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008888 }
8889 else
8890 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05308891 smsLog(pMac, LOGE, FL("Channel list empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008892 status = eHAL_STATUS_FAILURE;
8893 break;
8894 }
8895 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
8896 pScanFilter->authType = pProfile->AuthType;
8897 pScanFilter->EncryptionType = pProfile->EncryptionType;
8898 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
8899 pScanFilter->BSSType = pProfile->BSSType;
8900 pScanFilter->phyMode = pProfile->phyMode;
8901#ifdef FEATURE_WLAN_WAPI
8902 //check if user asked for WAPI with 11n or auto mode, in that case modify
8903 //the phymode to 11g
8904 if(csrIsProfileWapi(pProfile))
8905 {
8906 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
8907 {
8908 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
8909 }
8910 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
8911 {
8912 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
8913 }
8914 if(!pScanFilter->phyMode)
8915 {
8916 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
8917 }
8918 }
8919#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07008920 /*Save the WPS info*/
8921 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -07008922 pScanFilter->bOSENAssociation = pProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07008923 if( pProfile->countryCode[0] )
8924 {
8925 //This causes the matching function to use countryCode as one of the criteria.
Kiet Lam64c1b492013-07-12 13:56:44 +05308926 vos_mem_copy(pScanFilter->countryCode, pProfile->countryCode,
8927 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008928 }
8929#ifdef WLAN_FEATURE_VOWIFI_11R
8930 if (pProfile->MDID.mdiePresent)
8931 {
8932 pScanFilter->MDID.mdiePresent = 1;
8933 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
8934 }
8935#endif
8936
8937 }while(0);
8938
8939 if(!HAL_STATUS_SUCCESS(status))
8940 {
8941 csrFreeScanFilter(pMac, pScanFilter);
8942 }
8943
8944 return(status);
8945}
8946
Jeff Johnson295189b2012-06-20 16:38:30 -07008947tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
8948 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
8949{
8950 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
8951 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008952 do
8953 {
8954 // Validate the type is ok...
8955 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
8956 pCommand = csrGetCommandBuffer( pMac );
8957 if ( !pCommand )
8958 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008959 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008960 break;
8961 }
8962 //Change the substate in case it is waiting for key
8963 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8964 {
8965 csrRoamStopWaitForKeyTimer( pMac );
8966 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
8967 }
8968 pCommand->command = eSmeCommandWmStatusChange;
8969 pCommand->sessionId = (tANI_U8)sessionId;
8970 pCommand->u.wmStatusChangeCmd.Type = Type;
8971 if ( eCsrDisassociated == Type )
8972 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308973 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg,
8974 pSmeRsp,
8975 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07008976 }
8977 else
8978 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308979 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg,
8980 pSmeRsp,
8981 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07008982 }
8983 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
8984 {
8985 fCommandQueued = eANI_BOOLEAN_TRUE;
8986 }
8987 else
8988 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008989 smsLog( pMac, LOGE, FL(" fail to send message ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008990 csrReleaseCommandWmStatusChange( pMac, pCommand );
8991 }
8992
Jeff Johnson295189b2012-06-20 16:38:30 -07008993 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
8994 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07008995 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07008996 return( fCommandQueued );
8997}
8998
Jeff Johnson295189b2012-06-20 16:38:30 -07008999static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
9000{
9001 v_S7_t rssi = 0;
9002 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
9003 if(pGetRssiReq)
9004 {
9005 if(NULL != pGetRssiReq->pVosContext)
9006 {
9007 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
9008 }
9009 else
9010 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009011 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009012 return;
9013 }
9014
9015 if(NULL != pGetRssiReq->rssiCallback)
9016 {
9017 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
9018 }
9019 else
9020 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009021 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009022 return;
9023 }
9024 }
9025 else
9026 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009027 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009028 }
9029 return;
9030}
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309031
9032static void csrUpdateSnr(tpAniSirGlobal pMac, void* pMsg)
9033{
9034 tANI_S8 snr = 0;
9035 tAniGetSnrReq *pGetSnrReq = (tAniGetSnrReq*)pMsg;
9036
9037 if (pGetSnrReq)
9038 {
9039 if (VOS_STATUS_SUCCESS !=
9040 WDA_GetSnr(pGetSnrReq->staId, &snr))
9041 {
9042 smsLog(pMac, LOGE, FL("Error in WLANTL_GetSnr"));
9043 return;
9044 }
9045
9046 if (pGetSnrReq->snrCallback)
9047 {
9048 ((tCsrSnrCallback)(pGetSnrReq->snrCallback))(snr, pGetSnrReq->staId,
9049 pGetSnrReq->pDevContext);
9050 }
9051 else
9052 {
9053 smsLog(pMac, LOGE, FL("pGetSnrReq->snrCallback is NULL"));
9054 return;
9055 }
9056 }
9057 else
9058 {
9059 smsLog(pMac, LOGE, FL("pGetSnrReq is NULL"));
9060 }
9061 return;
9062}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009063#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009064void csrRoamRssiRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9065{
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009066 tAniGetRoamRssiRsp* pRoamRssiRsp = (tAniGetRoamRssiRsp*)pMsg;
9067
Jeff Johnson36d483b2013-04-08 11:08:53 -07009068 if (NULL != pRoamRssiRsp)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009069 {
Jeff Johnson36d483b2013-04-08 11:08:53 -07009070 /* Get roam Rssi request is backed up and passed back to the response,
9071 Extract the request message to fetch callback */
9072 tpAniGetRssiReq reqBkp = (tAniGetRssiReq*)pRoamRssiRsp->rssiReq;
9073 v_S7_t rssi = pRoamRssiRsp->rssi;
9074
9075 if ((NULL != reqBkp) && (NULL != reqBkp->rssiCallback))
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009076 {
9077 ((tCsrRssiCallback)(reqBkp->rssiCallback))(rssi, pRoamRssiRsp->staId, reqBkp->pDevContext);
9078 reqBkp->rssiCallback = NULL;
9079 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009080 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009081 }
9082 else
9083 {
9084 smsLog( pMac, LOGE, FL("reqBkp->rssiCallback is NULL"));
9085 if (NULL != reqBkp)
9086 {
9087 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009088 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009089 }
9090 }
9091 }
9092 else
9093 {
9094 smsLog( pMac, LOGE, FL("pRoamRssiRsp is NULL"));
9095 }
9096 return;
9097}
9098#endif
9099
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009100
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009101#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009102void csrTsmStatsRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9103{
9104 tAniGetTsmStatsRsp* pTsmStatsRsp = (tAniGetTsmStatsRsp*)pMsg;
9105
9106 if (NULL != pTsmStatsRsp)
9107 {
9108 /* Get roam Rssi request is backed up and passed back to the response,
9109 Extract the request message to fetch callback */
9110 tpAniGetTsmStatsReq reqBkp = (tAniGetTsmStatsReq*)pTsmStatsRsp->tsmStatsReq;
9111
9112 if (NULL != reqBkp)
9113 {
9114 if (NULL != reqBkp->tsmStatsCallback)
9115 {
9116 ((tCsrTsmStatsCallback)(reqBkp->tsmStatsCallback))(pTsmStatsRsp->tsmMetrics,
9117 pTsmStatsRsp->staId, reqBkp->pDevContext);
9118 reqBkp->tsmStatsCallback = NULL;
9119 }
9120 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009121 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009122 }
9123 else
9124 {
9125 smsLog( pMac, LOGE, FL("reqBkp is NULL"));
9126 if (NULL != reqBkp)
9127 {
9128 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009129 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009130 }
9131 }
9132 }
9133 else
9134 {
9135 smsLog( pMac, LOGE, FL("pTsmStatsRsp is NULL"));
9136 }
9137 return;
9138}
9139
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009140void csrSendEseAdjacentApRepInd(tpAniSirGlobal pMac, tCsrRoamSession *pSession)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009141{
9142 tANI_U32 roamTS2 = 0;
9143 tCsrRoamInfo roamInfo;
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009144 tpPESession pSessionEntry = NULL;
9145 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009146
9147 if (NULL == pSession)
9148 {
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009149 smsLog(pMac, LOGE, FL("pSession is NULL"));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009150 return;
9151 }
9152
9153 roamTS2 = vos_timer_get_system_time();
9154 roamInfo.tsmRoamDelay = roamTS2 - pSession->roamTS1;
Arif Hussaina7c8e412013-11-20 11:06:42 -08009155 smsLog(pMac, LOG1, "Bssid("MAC_ADDRESS_STR") Roaming Delay(%u ms)",
9156 MAC_ADDR_ARRAY(pSession->connectedProfile.bssid),
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009157 roamInfo.tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009158
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009159 pSessionEntry = peFindSessionByBssid(pMac, pSession->connectedProfile.bssid, &sessionId);
9160 if (NULL == pSessionEntry)
9161 {
9162 smsLog(pMac, LOGE, FL("session %d not found"), sessionId);
9163 return;
9164 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009165 pSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly = roamInfo.tsmRoamDelay;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009166 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009167 0, eCSR_ROAM_ESE_ADJ_AP_REPORT_IND, 0);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009168}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009169#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009170
Jeff Johnsone7245742012-09-05 17:12:55 -07009171static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
9172{
9173 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
9174 if(pTlRssiInd)
9175 {
9176 if(NULL != pTlRssiInd->tlCallback)
9177 {
9178 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -08009179 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07009180 }
9181 else
9182 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009183 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009184 }
9185 }
9186 else
9187 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009188 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009189 }
9190 return;
9191}
Jeff Johnson295189b2012-06-20 16:38:30 -07009192
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309193eHalStatus csrSendResetApCapsChanged(tpAniSirGlobal pMac, tSirMacAddr *bssId)
9194{
9195 tpSirResetAPCapsChange pMsg;
9196 tANI_U16 len;
9197 eHalStatus status = eHAL_STATUS_SUCCESS;
9198
9199 /* Create the message and send to lim */
9200 len = sizeof(tSirResetAPCapsChange);
Kiet Lam64c1b492013-07-12 13:56:44 +05309201 pMsg = vos_mem_malloc(len);
9202 if ( NULL == pMsg )
9203 status = eHAL_STATUS_FAILURE;
9204 else
9205 status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309206 if (HAL_STATUS_SUCCESS(status))
9207 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309208 vos_mem_set(pMsg, sizeof(tSirResetAPCapsChange), 0);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309209 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
9210 pMsg->length = len;
Kiet Lam64c1b492013-07-12 13:56:44 +05309211 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08009212 smsLog( pMac, LOG1, FL("CSR reset caps change for Bssid= "MAC_ADDRESS_STR),
9213 MAC_ADDR_ARRAY(pMsg->bssId));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309214 status = palSendMBMessage(pMac->hHdd, pMsg);
9215 }
9216 else
9217 {
9218 smsLog( pMac, LOGE, FL("Memory allocation failed\n"));
9219 }
9220 return status;
9221}
9222
Jeff Johnson295189b2012-06-20 16:38:30 -07009223void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
9224{
9225 tSirSmeAssocInd *pAssocInd;
9226 tSirSmeDisassocInd *pDisassocInd;
9227 tSirSmeDeauthInd *pDeauthInd;
9228 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
9229 tSirSmeNewBssInfo *pNewBss;
9230 tSmeIbssPeerInd *pIbssPeerInd;
9231 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
9232 tSirSmeApNewCaps *pApNewCaps;
9233 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
9234 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
9235 tCsrRoamInfo *pRoamInfo = NULL;
9236 tCsrRoamInfo roamInfo;
9237 eHalStatus status;
9238 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
9239 tCsrRoamSession *pSession = NULL;
9240 tpSirSmeSwitchChannelInd pSwitchChnInd;
9241 tSmeMaxAssocInd *pSmeMaxAssocInd;
Kiet Lam64c1b492013-07-12 13:56:44 +05309242 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
krunal soni587bf012014-02-04 12:35:11 -08009243
9244
9245 if (NULL == pSirMsg)
9246 { smsLog(pMac, LOGE, FL("pSirMsg is NULL"));
9247 return;
9248 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009249 switch( pSirMsg->messageType )
9250 {
9251 case eWNI_SME_ASSOC_IND:
9252 {
9253 tCsrRoamSession *pSession;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009254 smsLog( pMac, LOG1, FL("ASSOCIATION Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009255 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
9256 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
9257 if( HAL_STATUS_SUCCESS( status ) )
9258 {
9259 pSession = CSR_GET_SESSION(pMac, sessionId);
9260
Jeff Johnson32d95a32012-09-10 13:15:23 -07009261 if(!pSession)
9262 {
9263 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9264 return;
9265 }
9266
Jeff Johnson295189b2012-06-20 16:38:30 -07009267 pRoamInfo = &roamInfo;
9268
9269 // Required for indicating the frames to upper layer
9270 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
9271 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
9272
9273 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
9274 pRoamInfo->beaconLength = pAssocInd->beaconLength;
9275 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
9276 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9277
9278 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
9279 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
9280 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
9281
9282 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
9283 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05309284 vos_mem_copy(pRoamInfo->peerMac, pAssocInd->peerMacAddr,
9285 sizeof(tSirMacAddr));
9286 vos_mem_copy(&pRoamInfo->bssid, pAssocInd->bssId,
9287 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009288 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
9289 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07009290 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -07009291 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
9292 {
9293 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
9294 {
9295 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
9296 pSession->pConnectBssDesc,
9297 &(pRoamInfo->peerMac),
9298 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9299 pRoamInfo->fAuthRequired = FALSE;
9300 }
9301 else
9302 {
9303 pRoamInfo->fAuthRequired = TRUE;
9304 }
9305 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
9306 if (!HAL_STATUS_SUCCESS(status))
9307 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
9308 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009309 /* Send Association completion message to PE */
9310 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
9311
9312 /* send a message to CSR itself just to avoid the EAPOL frames going
9313 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -07009314 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
9315 {
9316 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9317 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009318 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
9319 {
9320 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
9321 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
9322 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9323 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009324 }
9325 }
9326 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009327 case eWNI_SME_DISASSOC_IND:
Jeff Johnson295189b2012-06-20 16:38:30 -07009328 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309329 // Check if AP dis-associated us because of MIC failure. If so,
9330 // then we need to take action immediately and not wait till the
9331 // the WmStatusChange requests is pushed and processed
9332 tSmeCmd *pCommand;
9333
9334 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
9335 status = csrRoamGetSessionIdFromBSSID( pMac,
9336 (tCsrBssid *)pDisassocInd->bssId, &sessionId );
9337 if( HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009338 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309339 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC"
9340 " for session %d "), sessionId);
9341 smsLog( pMac, LOGE, FL("DISASSOCIATION from peer ="
9342 MAC_ADDRESS_STR " "
9343 " reason = %d status = %d "),
9344 MAC_ADDR_ARRAY(pDisassocInd->peerMacAddr),
9345 pDisassocInd->reasonCode,
9346 pDisassocInd->statusCode);
9347 // If we are in neighbor preauth done state then on receiving
9348 // disassoc or deauth we dont roam instead we just disassoc
9349 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009350 // This happens for ESE and 11r FT connections ONLY.
Agarwal Ashish4f616132013-12-30 23:32:50 +05309351#ifdef WLAN_FEATURE_VOWIFI_11R
9352 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9353 {
9354 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9355 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009356#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009357#ifdef FEATURE_WLAN_ESE
9358 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Agarwal Ashish4f616132013-12-30 23:32:50 +05309359 {
9360 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9361 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009362#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009363#ifdef FEATURE_WLAN_LFR
Agarwal Ashish4f616132013-12-30 23:32:50 +05309364 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
9365 {
9366 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9367 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009368#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +05309369 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009370
Agarwal Ashish4f616132013-12-30 23:32:50 +05309371 if (!pSession)
9372 {
9373 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9374 return;
9375 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07009376
Agarwal Ashish4f616132013-12-30 23:32:50 +05309377 if ( csrIsConnStateInfra( pMac, sessionId ) )
9378 {
9379 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9380 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009381#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Agarwal Ashish4f616132013-12-30 23:32:50 +05309382 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009383#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +05309384 csrRoamLinkDown(pMac, sessionId);
9385 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
9386 if (CSR_IS_INFRA_AP(&pSession->connectedProfile))
9387 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309388 pRoamInfo = &roamInfo;
9389 pRoamInfo->statusCode = pDisassocInd->statusCode;
9390 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9391 pRoamInfo->staId = (tANI_U8)pDisassocInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009392
Agarwal Ashish4f616132013-12-30 23:32:50 +05309393 vos_mem_copy(pRoamInfo->peerMac, pDisassocInd->peerMacAddr,
9394 sizeof(tSirMacAddr));
9395 vos_mem_copy(&pRoamInfo->bssid, pDisassocInd->bssId,
9396 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009397
Agarwal Ashish4f616132013-12-30 23:32:50 +05309398 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9399 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DISASSOC_IND);
Jeff Johnson295189b2012-06-20 16:38:30 -07009400
Agarwal Ashish4f616132013-12-30 23:32:50 +05309401 /*
9402 * STA/P2P client got disassociated so remove any pending deauth
9403 * commands in sme pending list
9404 */
Kaushik, Sushant488df382014-03-05 11:43:47 +05309405 pCommand = csrGetCommandBuffer(pMac);
9406 if (NULL == pCommand)
9407 {
9408 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
9409 status = eHAL_STATUS_RESOURCES;
9410 return;
9411 }
Agarwal Ashish4f616132013-12-30 23:32:50 +05309412 pCommand->command = eSmeCommandRoam;
9413 pCommand->sessionId = (tANI_U8)sessionId;
9414 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
9415 vos_mem_copy(pCommand->u.roamCmd.peerMac,
9416 pDisassocInd->peerMacAddr,
9417 sizeof(tSirMacAddr));
9418 csrRoamRemoveDuplicateCommand(pMac, sessionId, pCommand, eCsrForcedDeauthSta);
9419 csrReleaseCommand( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07009420
Agarwal Ashish4f616132013-12-30 23:32:50 +05309421 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009422 }
Agarwal Ashish4f616132013-12-30 23:32:50 +05309423 else
9424 {
9425 smsLog(pMac, LOGE, FL(" Session Id not found for BSSID " MAC_ADDRESS_STR),
9426 MAC_ADDR_ARRAY(pDisassocInd->bssId));
9427 }
Kiet Lam82004c62013-11-11 13:24:28 +05309428 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009429 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009430 case eWNI_SME_DEAUTH_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009431 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009432 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
9433 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
9434 if( HAL_STATUS_SUCCESS( status ) )
9435 {
9436 // If we are in neighbor preauth done state then on receiving
9437 // disassoc or deauth we dont roam instead we just disassoc
9438 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009439 // This happens for ESE and 11r FT connections ONLY.
Jeff Johnson295189b2012-06-20 16:38:30 -07009440#ifdef WLAN_FEATURE_VOWIFI_11R
9441 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9442 {
9443 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9444 }
9445#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009446#ifdef FEATURE_WLAN_ESE
9447 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson295189b2012-06-20 16:38:30 -07009448 {
9449 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9450 }
9451#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009452#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05309453 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009454 {
9455 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9456 }
9457#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009458 pSession = CSR_GET_SESSION( pMac, sessionId );
9459
Jeff Johnson32d95a32012-09-10 13:15:23 -07009460 if(!pSession)
9461 {
9462 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9463 return;
9464 }
9465
Jeff Johnson295189b2012-06-20 16:38:30 -07009466 if ( csrIsConnStateInfra( pMac, sessionId ) )
9467 {
9468 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9469 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009470#ifndef WLAN_MDM_CODE_REDUCTION_OPT
9471 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
9472#endif
9473 csrRoamLinkDown(pMac, sessionId);
9474 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07009475 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
9476 {
9477
9478 pRoamInfo = &roamInfo;
9479
9480 pRoamInfo->statusCode = pDeauthInd->statusCode;
9481 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9482
9483 pRoamInfo->staId = (tANI_U8)pDeauthInd->staId;
9484
Kiet Lam64c1b492013-07-12 13:56:44 +05309485 vos_mem_copy(pRoamInfo->peerMac, pDeauthInd->peerMacAddr,
9486 sizeof(tSirMacAddr));
9487 vos_mem_copy(&pRoamInfo->bssid, pDeauthInd->bssId,
9488 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009489
9490 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DEAUTH_IND);
9491 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009492 }
9493 break;
9494
9495 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 -08009496 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009497 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
9498 //Update with the new channel id.
9499 //The channel id is hidden in the statusCode.
9500 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
9501 if( HAL_STATUS_SUCCESS( status ) )
9502 {
9503 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009504 if(!pSession)
9505 {
9506 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9507 return;
9508 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009509 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
9510 if(pSession->pConnectBssDesc)
9511 {
9512 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
9513 }
9514 }
9515 break;
9516
9517 case eWNI_SME_DEAUTH_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009518 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009519 {
9520 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
9521 sessionId = pDeauthRsp->sessionId;
9522 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9523 {
9524 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009525 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9526 {
9527 pRoamInfo = &roamInfo;
9528 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309529 vos_mem_copy(pRoamInfo->peerMac, pDeauthRsp->peerMacAddr,
9530 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009531 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9532 pRoamInfo->statusCode = pDeauthRsp->statusCode;
9533 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9534 }
9535 }
9536 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009537 break;
9538
9539 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009540 /* session id is invalid here so cant use it to access the array curSubstate as index */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009541 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -07009542 {
9543 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
9544 sessionId = pDisassocRsp->sessionId;
9545 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9546 {
9547 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009548 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9549 {
9550 pRoamInfo = &roamInfo;
9551 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309552 vos_mem_copy(pRoamInfo->peerMac, pDisassocRsp->peerMacAddr,
9553 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009554 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9555 pRoamInfo->statusCode = pDisassocRsp->statusCode;
9556 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9557 }
9558 }
9559 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009560 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009561 case eWNI_SME_MIC_FAILURE_IND:
9562 {
9563 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
9564 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
9565 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Leo Chang9b01ad92013-09-12 17:26:56 -07009566
9567 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
9568 if( HAL_STATUS_SUCCESS( status ) )
9569 {
Kiet Lamf2f201e2013-11-16 21:24:16 +05309570 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Leo Chang9b01ad92013-09-12 17:26:56 -07009571 roamInfo.u.pMICFailureInfo = &pMicInd->info;
9572 pRoamInfo = &roamInfo;
9573 if(pMicInd->info.multicast)
9574 {
9575 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
9576 }
9577 else
9578 {
9579 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
9580 }
9581 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
9582 }
9583
Jeff Johnson295189b2012-06-20 16:38:30 -07009584#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9585 {
lukez3c809222013-05-03 10:23:02 -07009586 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07009587 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009588 if(!pSession)
9589 {
9590 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9591 return;
9592 }
lukez3c809222013-05-03 10:23:02 -07009593
Kiet Lam64c1b492013-07-12 13:56:44 +05309594 vos_mem_set(&secEvent, sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009595 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
9596 secEvent.encryptionModeMulticast =
9597 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9598 secEvent.encryptionModeUnicast =
9599 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9600 secEvent.authMode =
9601 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309602 vos_mem_copy(secEvent.bssid,
9603 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009604 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
9605 }
9606#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009607 }
9608 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009609 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
9610 {
9611 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
9612 tCsrRoamInfo roamInfo;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009613 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009614
9615 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
9616 if( HAL_STATUS_SUCCESS( status ) )
9617 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309618 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009619 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
9620 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
9621 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
9622 }
9623 }
9624 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009625
Jeff Johnson295189b2012-06-20 16:38:30 -07009626 case eWNI_SME_WM_STATUS_CHANGE_NTF:
9627 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
9628 switch( pStatusChangeMsg->statusChangeCode )
9629 {
9630 case eSIR_SME_IBSS_ACTIVE:
9631 sessionId = csrFindIbssSession( pMac );
9632 if( CSR_SESSION_ID_INVALID != sessionId )
9633 {
9634 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009635 if(!pSession)
9636 {
9637 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9638 return;
9639 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009640 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
9641 if(pSession->pConnectBssDesc)
9642 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309643 vos_mem_copy(&roamInfo.bssid,
9644 pSession->pConnectBssDesc->bssId,
9645 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009646 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
9647 pRoamInfo = &roamInfo;
9648 }
9649 else
9650 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009651 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009652 }
9653 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
9654 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9655 }
9656 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009657 case eSIR_SME_IBSS_INACTIVE:
9658 sessionId = csrFindIbssSession( pMac );
9659 if( CSR_SESSION_ID_INVALID != sessionId )
9660 {
9661 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009662 if(!pSession)
9663 {
9664 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9665 return;
9666 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009667 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
9668 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
9669 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9670 }
9671 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009672 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
9673 sessionId = csrFindIbssSession( pMac );
9674 if( CSR_SESSION_ID_INVALID != sessionId )
9675 {
9676 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009677 if(!pSession)
9678 {
9679 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9680 return;
9681 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009682 // update the connection state information
9683 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009684#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9685 {
9686 vos_log_ibss_pkt_type *pIbssLog;
9687 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -07009688 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9689 if(pIbssLog)
9690 {
9691 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
9692 if(pNewBss)
9693 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309694 vos_mem_copy(pIbssLog->bssid, pNewBss->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009695 if(pNewBss->ssId.length)
9696 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309697 vos_mem_copy(pIbssLog->ssid, pNewBss->ssId.ssId,
9698 pNewBss->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07009699 }
9700 pIbssLog->operatingChannel = pNewBss->channelNumber;
9701 }
9702 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
9703 {
9704 //***U8 is not enough for beacon interval
9705 pIbssLog->beaconInterval = (v_U8_t)bi;
9706 }
9707 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9708 }
9709 }
9710#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009711 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009712
9713 if ((eCSR_ENCRYPT_TYPE_NONE ==
9714 pSession->connectedProfile.EncryptionType ))
9715 {
9716 csrRoamIssueSetContextReq( pMac, sessionId,
9717 pSession->connectedProfile.EncryptionType,
9718 pSession->pConnectBssDesc,
9719 &Broadcastaddr,
9720 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
9721 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009722 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
9723 roamStatus = eCSR_ROAM_IBSS_IND;
Kiet Lam64c1b492013-07-12 13:56:44 +05309724 vos_mem_copy(&roamInfo.bssid, &pNewBss->bssId,
9725 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009726 pRoamInfo = &roamInfo;
9727 //This BSSID is th ereal BSSID, let's save it
9728 if(pSession->pConnectBssDesc)
9729 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309730 vos_mem_copy(pSession->pConnectBssDesc->bssId,
9731 &pNewBss->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009732 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009733 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009734 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Jeff Johnson295189b2012-06-20 16:38:30 -07009735 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009736 // detection by LIM that the capabilities of the associated AP have changed.
9737 case eSIR_SME_AP_CAPS_CHANGED:
9738 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009739 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED");
Jeff Johnson295189b2012-06-20 16:38:30 -07009740 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
9741 if( HAL_STATUS_SUCCESS( status ) )
9742 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009743 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
9744 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309745 (eCSR_ROAM_SUBSTATE_NONE == pMac->roam.curSubState[sessionId]) ||
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009746 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
9747 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
9748 )
9749 {
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309750 smsLog(pMac, LOGW, "Calling csrRoamDisconnectInternal");
9751 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009752 }
9753 else
9754 {
9755 smsLog(pMac, LOGW,
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05309756 FL("Skipping csrScanForCapabilityChange as "
9757 "CSR is in state %s and sub-state %s"),
9758 macTraceGetcsrRoamState(
9759 pMac->roam.curState[sessionId]),
9760 macTraceGetcsrRoamSubState(
9761 pMac->roam.curSubState[sessionId]));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309762 /* We ignore the caps change event if CSR is not in full connected state.
9763 * Send one event to PE to reset limSentCapsChangeNtf
9764 * Once limSentCapsChangeNtf set 0, lim can send sub sequent CAPS change event
9765 * otherwise lim cannot send any CAPS change events to SME */
9766 csrSendResetApCapsChanged(pMac, &pApNewCaps->bssId);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009767 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009768 }
9769 break;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309770
Jeff Johnson295189b2012-06-20 16:38:30 -07009771 default:
9772 roamStatus = eCSR_ROAM_FAILED;
9773 result = eCSR_ROAM_RESULT_NONE;
9774 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009775 } // end switch on statusChangeCode
9776 if(eCSR_ROAM_RESULT_NONE != result)
9777 {
9778 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
9779 }
9780 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009781 case eWNI_SME_IBSS_NEW_PEER_IND:
9782 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07009783#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9784 {
9785 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07009786 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9787 if(pIbssLog)
9788 {
9789 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309790 vos_mem_copy(pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009791 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9792 }
9793 }
9794#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009795 sessionId = csrFindIbssSession( pMac );
9796 if( CSR_SESSION_ID_INVALID != sessionId )
9797 {
9798 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009799
9800 if(!pSession)
9801 {
9802 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9803 return;
9804 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009805 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
9806 if(pSession->pConnectBssDesc)
9807 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309808 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
9809 sizeof(tCsrBssid));
9810 vos_mem_copy(&roamInfo.bssid, pSession->pConnectBssDesc->bssId,
9811 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009812 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
9813 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309814 roamInfo.pbFrames = vos_mem_malloc((pIbssPeerInd->mesgLen
9815 - sizeof(tSmeIbssPeerInd)));
9816 if ( NULL == roamInfo.pbFrames )
9817 status = eHAL_STATUS_FAILURE;
9818 else
9819 status = eHAL_STATUS_SUCCESS;
9820 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07009821 {
9822 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
Kiet Lam64c1b492013-07-12 13:56:44 +05309823 vos_mem_copy(roamInfo.pbFrames,
9824 ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
9825 roamInfo.nBeaconLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07009826 }
9827 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9828 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9829 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05309830 roamInfo.pBssDesc = vos_mem_malloc(pSession->pConnectBssDesc->length);
9831 if ( NULL == roamInfo.pBssDesc )
9832 status = eHAL_STATUS_FAILURE;
9833 else
9834 status = eHAL_STATUS_SUCCESS;
9835 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07009836 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309837 vos_mem_copy(roamInfo.pBssDesc,
9838 pSession->pConnectBssDesc,
9839 pSession->pConnectBssDesc->length);
Jeff Johnson295189b2012-06-20 16:38:30 -07009840 }
9841 if(HAL_STATUS_SUCCESS(status))
9842 {
9843 pRoamInfo = &roamInfo;
9844 }
9845 else
9846 {
9847 if(roamInfo.pbFrames)
9848 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309849 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -07009850 }
9851 if(roamInfo.pBssDesc)
9852 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309853 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07009854 }
9855 }
9856 }
9857 else
9858 {
9859 pRoamInfo = &roamInfo;
9860 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009861 if ((eCSR_ENCRYPT_TYPE_NONE ==
9862 pSession->connectedProfile.EncryptionType ))
9863 {
9864 csrRoamIssueSetContextReq( pMac, sessionId,
9865 pSession->connectedProfile.EncryptionType,
9866 pSession->pConnectBssDesc,
9867 &(pIbssPeerInd->peerAddr),
9868 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9869 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009870 }
9871 else
9872 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009873 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009874 }
9875 //send up the sec type for the new peer
9876 if (pRoamInfo)
9877 {
9878 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9879 }
9880 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9881 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
9882 if(pRoamInfo)
9883 {
9884 if(roamInfo.pbFrames)
9885 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309886 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -07009887 }
9888 if(roamInfo.pBssDesc)
9889 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309890 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07009891 }
9892 }
9893 }
9894 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009895 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
9896 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
9897 sessionId = csrFindIbssSession( pMac );
9898 if( CSR_SESSION_ID_INVALID != sessionId )
9899 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009900#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9901 {
9902 vos_log_ibss_pkt_type *pIbssLog;
9903
9904 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9905 if(pIbssLog)
9906 {
9907 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
9908 if(pIbssPeerInd)
9909 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309910 vos_mem_copy(pIbssLog->peerMacAddr,
9911 &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009912 }
9913 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9914 }
9915 }
9916#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009917 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM");
Jeff Johnson295189b2012-06-20 16:38:30 -07009918 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9919 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9920 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05309921 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
9922 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009923 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9924 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
9925 }
9926 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009927 case eWNI_SME_SETCONTEXT_RSP:
9928 {
9929 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
9930 tListElem *pEntry;
9931 tSmeCmd *pCommand;
9932
9933 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9934 if ( pEntry )
9935 {
9936 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9937 if ( eSmeCommandSetKey == pCommand->command )
9938 {
Sandeep Puligilla9f384742014-04-11 02:27:04 +05309939 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009940 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009941
9942 if(!pSession)
9943 {
9944 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9945 return;
9946 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009947
9948#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9949 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
9950 {
9951 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +05309952 vos_mem_set(&setKeyEvent,
9953 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009954 if( pRsp->peerMacAddr[0] & 0x01 )
9955 {
9956 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
9957 }
9958 else
9959 {
9960 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
9961 }
9962 setKeyEvent.encryptionModeMulticast =
9963 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9964 setKeyEvent.encryptionModeUnicast =
9965 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309966 vos_mem_copy(setKeyEvent.bssid,
9967 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009968 setKeyEvent.authMode =
9969 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -07009970 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009971 {
9972 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
9973 }
9974 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
9975 }
9976#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
9977 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
9978 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -08009979 csrRoamStopWaitForKeyTimer( pMac );
9980
Jeff Johnson295189b2012-06-20 16:38:30 -07009981 //We are done with authentication, whethere succeed or not
9982 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009983 //We do it here because this linkup function is not called after association
9984 //when a key needs to be set.
9985 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
9986 {
9987 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
9988 }
9989 }
Jeff Johnson43971f52012-07-17 12:26:56 -07009990 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -07009991 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309992 vos_mem_copy(&roamInfo.peerMac,
9993 &pRsp->peerMacAddr, sizeof(tCsrBssid));
Jeff Johnsone7245742012-09-05 17:12:55 -07009994 //Make sure we install the GTK before indicating to HDD as authenticated
9995 //This is to prevent broadcast packets go out after PTK and before GTK.
Kiet Lam64c1b492013-07-12 13:56:44 +05309996 if ( vos_mem_compare( &Broadcastaddr, pRsp->peerMacAddr,
9997 sizeof(tSirMacAddr) ) )
Jeff Johnsone7245742012-09-05 17:12:55 -07009998 {
Yathish9f22e662012-12-10 14:21:35 -08009999#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
10000 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
10001 {
10002 tpSirSetActiveModeSetBncFilterReq pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053010003 pMsg = vos_mem_malloc(sizeof(tSirSetActiveModeSetBncFilterReq));
Yathish9f22e662012-12-10 14:21:35 -080010004 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
10005 pMsg->length = pal_cpu_to_be16(sizeof( tANI_U8));
10006 pMsg->seesionId = sessionId;
10007 status = palSendMBMessage(pMac->hHdd, pMsg );
10008 }
10009#endif
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010010 /* OBSS SCAN Indication will be sent to Firmware to start OBSS Scan */
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010011 if( CSR_IS_CHANNEL_24GHZ(pSession->connectedProfile.operationChannel)
10012 && IS_HT40_OBSS_SCAN_FEATURE_ENABLE )
10013 {
10014 tpSirSmeHT40OBSSScanInd pMsg;
10015 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSScanInd));
10016 pMsg->messageType =
10017 pal_cpu_to_be16((tANI_U16)eWNI_SME_HT40_OBSS_SCAN_IND);
10018 pMsg->length =
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010019 pal_cpu_to_be16(sizeof( tSirSmeHT40OBSSScanInd));
10020 vos_mem_copy(pMsg->peerMacAddr,
10021 pSession->connectedProfile.bssid,
10022 sizeof(tSirMacAddr));
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010023 status = palSendMBMessage(pMac->hHdd,
10024 pMsg );
10025 }
10026 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -070010027 }
10028 else
10029 {
10030 result = eCSR_ROAM_RESULT_NONE;
10031 }
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010032 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010033 }
10034 else
10035 {
10036 result = eCSR_ROAM_RESULT_FAILURE;
Arif Hussaina7c8e412013-11-20 11:06:42 -080010037 smsLog(pMac, LOGE, "CSR: Roam Completion setkey "
10038 "command failed(%d) PeerMac "MAC_ADDRESS_STR,
10039 pRsp->statusCode, MAC_ADDR_ARRAY(pRsp->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070010040 }
10041 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10042 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -070010043 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
10044 // can go ahead and initiate the TSPEC if any are pending
10045 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010046#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070010047 //Send Adjacent AP repot to new AP.
10048 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
10049 pSession->isPrevApInfoValid &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010050 pSession->connectedProfile.isESEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070010051 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010052#ifdef FEATURE_WLAN_ESE_UPLOAD
10053 csrSendEseAdjacentApRepInd(pMac, pSession);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010054#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010055 csrEseSendAdjacentApRepMsg(pMac, pSession);
Jeff Johnson295189b2012-06-20 16:38:30 -070010056#endif
10057 pSession->isPrevApInfoValid = FALSE;
10058 }
10059#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010060 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10061 {
10062 csrReleaseCommandSetKey( pMac, pCommand );
10063 }
10064 }
10065 else
10066 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010067 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010068 }
10069 }
10070 else
10071 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010072 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010073 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010074 smeProcessPendingQueue( pMac );
10075 }
10076 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010077 case eWNI_SME_REMOVEKEY_RSP:
10078 {
10079 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
10080 tListElem *pEntry;
10081 tSmeCmd *pCommand;
10082
10083 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10084 if ( pEntry )
10085 {
10086 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10087 if ( eSmeCommandRemoveKey == pCommand->command )
10088 {
10089 sessionId = pCommand->sessionId;
10090 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010091
10092 if(!pSession)
10093 {
10094 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10095 return;
10096 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010097#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10098 {
10099 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053010100 vos_mem_set(&removeKeyEvent,
10101 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010102 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
10103 removeKeyEvent.encryptionModeMulticast =
10104 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10105 removeKeyEvent.encryptionModeUnicast =
10106 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010107 vos_mem_copy( removeKeyEvent.bssid,
10108 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010109 removeKeyEvent.authMode =
10110 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -070010111 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010112 {
10113 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10114 }
10115 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
10116 }
10117#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -070010118 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010119 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010120 vos_mem_copy(&roamInfo.peerMac, &pRsp->peerMacAddr,
10121 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010122 result = eCSR_ROAM_RESULT_NONE;
10123 pRoamInfo = &roamInfo;
10124 }
10125 else
10126 {
10127 result = eCSR_ROAM_RESULT_FAILURE;
10128 }
10129 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10130 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
10131 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10132 {
10133 csrReleaseCommandRemoveKey( pMac, pCommand );
10134 }
10135 }
10136 else
10137 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010138 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010139 }
10140 }
10141 else
10142 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010143 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010144 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010145 smeProcessPendingQueue( pMac );
10146 }
10147 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010148 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010149 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010150 csrRoamStatsRspProcessor( pMac, pSirMsg );
10151 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010152#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080010153 case eWNI_SME_GET_ROAM_RSSI_RSP:
10154 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
10155 csrRoamRssiRspProcessor( pMac, pSirMsg );
10156 break;
10157#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010158#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010159 case eWNI_SME_GET_TSM_STATS_RSP:
10160 smsLog( pMac, LOG2, FL("TSM Stats rsp from PE"));
10161 csrTsmStatsRspProcessor( pMac, pSirMsg );
10162 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010163#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -070010164 case eWNI_SME_GET_RSSI_REQ:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010165 smsLog( pMac, LOG2, FL("GetRssiReq from self"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010166 csrUpdateRssi( pMac, pSirMsg );
10167 break;
10168
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053010169 case eWNI_SME_GET_SNR_REQ:
10170 smsLog( pMac, LOG2, FL("GetSnrReq from self"));
10171 csrUpdateSnr(pMac, pSirMsg);
10172 break;
10173
Jeff Johnson295189b2012-06-20 16:38:30 -070010174#ifdef WLAN_FEATURE_VOWIFI_11R
10175 case eWNI_SME_FT_PRE_AUTH_RSP:
10176 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
10177 break;
10178#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010179 case eWNI_SME_MAX_ASSOC_EXCEEDED:
10180 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010181 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 -070010182 sessionId = pSmeMaxAssocInd->sessionId;
10183 roamInfo.sessionId = sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053010184 vos_mem_copy(&roamInfo.peerMac, pSmeMaxAssocInd->peerMac,
10185 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010186 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
10187 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
10188 break;
10189
10190 case eWNI_SME_BTAMP_LOG_LINK_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010191 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010192 btampEstablishLogLinkHdlr( pSirMsg );
10193 break;
Jeff Johnsone7245742012-09-05 17:12:55 -070010194 case eWNI_SME_RSSI_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010195 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread"));
Jeff Johnsone7245742012-09-05 17:12:55 -070010196 csrRoamRssiIndHdlr( pMac, pSirMsg );
10197 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010198#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
10199 case eWNI_SME_CANDIDATE_FOUND_IND:
10200 smsLog( pMac, LOG2, FL("Candidate found indication from PE"));
10201 csrNeighborRoamCandidateFoundIndHdlr( pMac, pSirMsg );
10202 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070010203 case eWNI_SME_HANDOFF_REQ:
10204 smsLog( pMac, LOG2, FL("Handoff Req from self"));
10205 csrNeighborRoamHandoffReqHdlr( pMac, pSirMsg );
10206 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010207#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010208
10209 default:
10210 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010211 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -070010212}
10213
Jeff Johnson295189b2012-06-20 16:38:30 -070010214void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
10215 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
10216{
10217 if(pSession)
10218 {
10219 if(pSession->bRefAssocStartCnt)
10220 {
10221 pSession->bRefAssocStartCnt--;
10222 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
10223 //Need to call association_completion because there is an assoc_start pending.
10224 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
10225 eCSR_ROAM_ASSOCIATION_COMPLETION,
10226 eCSR_ROAM_RESULT_FAILURE);
10227 }
10228 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
10229 }
10230 else
10231 {
10232 smsLog(pMac, LOGW, FL(" pSession is NULL"));
10233 }
10234}
10235
10236
10237eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
10238{
10239 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010240 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
10241 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
10242 {
10243 status = csrScanRequestLostLink1( pMac, sessionId );
10244 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010245 return(status);
10246}
10247
Jeff Johnson295189b2012-06-20 16:38:30 -070010248//return a boolean to indicate whether roaming completed or continue.
10249tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
10250 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
10251{
10252 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
10253 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
10254 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10255 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010256 if(!pSession)
10257 {
10258 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10259 return eANI_BOOLEAN_FALSE;
10260 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010261 //Check whether time is up
10262 if(pSession->fCancelRoaming || fForce ||
10263 ((curTime - pSession->roamingStartTime) > roamTime) ||
10264 eCsrReassocRoaming == pSession->roamingReason ||
10265 eCsrDynamicRoaming == pSession->roamingReason)
10266 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010267 smsLog(pMac, LOGW, FL(" indicates roaming completion"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010268 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
10269 {
10270 //roaming is cancelled, tell HDD to indicate disconnect
10271 //Because LIM overload deauth_ind for both deauth frame and missed beacon
10272 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
10273 //to be eSIR_BEACON_MISSED
10274 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
10275 {
10276 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10277 }
10278 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
10279 {
10280 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
10281 }
10282 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
10283 {
10284 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
10285 }
10286 else
10287 {
10288 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10289 }
10290 }
10291 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10292 pSession->roamingReason = eCsrNotRoaming;
10293 }
10294 else
10295 {
10296 pSession->roamResult = roamResult;
10297 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
10298 {
10299 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10300 pSession->roamingReason = eCsrNotRoaming;
10301 }
10302 else
10303 {
10304 fCompleted = eANI_BOOLEAN_FALSE;
10305 }
10306 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010307 return(fCompleted);
10308}
10309
Jeff Johnson295189b2012-06-20 16:38:30 -070010310void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
10311{
10312 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010313
10314 if(!pSession)
10315 {
10316 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10317 return;
10318 }
10319
Jeff Johnson295189b2012-06-20 16:38:30 -070010320 if(CSR_IS_ROAMING(pSession))
10321 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010322 smsLog(pMac, LOGW, " Cancelling roaming");
Jeff Johnson295189b2012-06-20 16:38:30 -070010323 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
10324 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
10325 {
10326 //No need to do anything in here because the handler takes care of it
10327 }
10328 else
10329 {
10330 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
10331 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
10332 //Roaming is stopped after here
10333 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
10334 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053010335 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010336 csrRoamStopRoamingTimer(pMac, sessionId);
10337 }
10338 }
10339}
10340
Jeff Johnson295189b2012-06-20 16:38:30 -070010341void csrRoamRoamingTimerHandler(void *pv)
10342{
10343 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10344 tpAniSirGlobal pMac = pInfo->pMac;
10345 tANI_U32 sessionId = pInfo->sessionId;
10346 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010347
10348 if(!pSession)
10349 {
10350 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10351 return;
10352 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010353
10354 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
10355 {
10356 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
10357 {
10358 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
10359 pSession->roamingReason = eCsrNotRoaming;
10360 }
10361 }
10362}
10363
Jeff Johnson295189b2012-06-20 16:38:30 -070010364eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
10365{
10366 eHalStatus status;
10367 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010368
10369 if(!pSession)
10370 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010371 smsLog(pMac, LOGE, FL(" session %d not found"), sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -070010372 return eHAL_STATUS_FAILURE;
10373 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010374
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010375 smsLog(pMac, LOG1, " csrScanStartRoamingTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070010376 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010377 status = vos_timer_start(&pSession->hTimerRoaming, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010378
10379 return (status);
10380}
10381
Jeff Johnson295189b2012-06-20 16:38:30 -070010382eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
10383{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010384 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerRoaming));
Jeff Johnson295189b2012-06-20 16:38:30 -070010385}
10386
Jeff Johnson295189b2012-06-20 16:38:30 -070010387void csrRoamWaitForKeyTimeOutHandler(void *pv)
10388{
10389 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10390 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010391 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080010392 eHalStatus status = eHAL_STATUS_FAILURE;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010393
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010394 smsLog(pMac, LOGW, FL("WaitForKey timer expired in state=%s sub-state=%s"),
10395 macTraceGetNeighbourRoamState(
10396 pMac->roam.neighborRoamInfo.neighborRoamState),
10397 macTraceGetcsrRoamSubState(
10398 pMac->roam.curSubState[pInfo->sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010399
Jeff Johnson295189b2012-06-20 16:38:30 -070010400 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
10401 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010402#ifdef FEATURE_WLAN_LFR
10403 if (csrNeighborRoamIsHandoffInProgress(pMac))
10404 {
10405 /*
10406 * Enable heartbeat timer when hand-off is in progress
10407 * and Key Wait timer expired.
10408 */
10409 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010410 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010411 pMac->roam.configParam.HeartbeatThresh24);
10412 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10413 pMac->roam.configParam.HeartbeatThresh24,
10414 NULL, eANI_BOOLEAN_FALSE);
10415 }
10416#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010417 smsLog(pMac, LOGW, " SME pre-auth state timeout. ");
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010418
Jeff Johnson295189b2012-06-20 16:38:30 -070010419 //Change the substate so command queue is unblocked.
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010420 if (CSR_ROAM_SESSION_MAX > pInfo->sessionId)
10421 {
10422 csrRoamSubstateChange(pMac, eCSR_ROAM_SUBSTATE_NONE,
10423 pInfo->sessionId);
10424 }
10425
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010426 if (pSession)
10427 {
10428 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
10429 {
10430 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10431 smeProcessPendingQueue(pMac);
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080010432 if( (pSession->connectedProfile.AuthType ==
10433 eCSR_AUTH_TYPE_SHARED_KEY) &&
10434 ( (pSession->connectedProfile.EncryptionType ==
10435 eCSR_ENCRYPT_TYPE_WEP40) ||
10436 (pSession->connectedProfile.EncryptionType ==
10437 eCSR_ENCRYPT_TYPE_WEP104) ))
10438 {
10439 status = sme_AcquireGlobalLock( &pMac->sme );
10440 if ( HAL_STATUS_SUCCESS( status ) )
10441 {
10442 csrRoamDisconnect( pMac, pInfo->sessionId,
10443 eCSR_DISCONNECT_REASON_UNSPECIFIED );
10444 sme_ReleaseGlobalLock( &pMac->sme );
10445 }
10446 }
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010447 }
10448 else
10449 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010450 smsLog(pMac, LOGW, "%s: could not post link up",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010451 __func__);
10452 }
10453 }
10454 else
10455 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010456 smsLog(pMac, LOGW, "%s: session not found", __func__);
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010457 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010458 }
10459
10460}
10461
Jeff Johnson295189b2012-06-20 16:38:30 -070010462eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
10463{
10464 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010465#ifdef FEATURE_WLAN_LFR
10466 if (csrNeighborRoamIsHandoffInProgress(pMac))
10467 {
10468 /* Disable heartbeat timer when hand-off is in progress */
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010469 smsLog(pMac, LOG2, FL("disabling HB timer in state=%s sub-state=%s"),
10470 macTraceGetNeighbourRoamState(
10471 pMac->roam.neighborRoamInfo.neighborRoamState),
10472 macTraceGetcsrRoamSubState(
10473 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]
10474 ));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010475 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
10476 }
10477#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010478 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010479 status = vos_timer_start(&pMac->roam.hTimerWaitForKey, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010480
10481 return (status);
10482}
10483
Jeff Johnson295189b2012-06-20 16:38:30 -070010484eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
10485{
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010486 smsLog(pMac, LOG2, FL("WaitForKey timer stopped in state=%s sub-state=%s"),
10487 macTraceGetNeighbourRoamState(
10488 pMac->roam.neighborRoamInfo.neighborRoamState),
10489 macTraceGetcsrRoamSubState(
10490 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010491#ifdef FEATURE_WLAN_LFR
10492 if (csrNeighborRoamIsHandoffInProgress(pMac))
10493 {
10494 /*
10495 * Enable heartbeat timer when hand-off is in progress
10496 * and Key Wait timer got stopped for some reason
10497 */
10498 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010499 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010500 pMac->roam.configParam.HeartbeatThresh24);
10501 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10502 pMac->roam.configParam.HeartbeatThresh24,
10503 NULL, eANI_BOOLEAN_FALSE);
10504 }
10505#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010506 return (vos_timer_stop(&pMac->roam.hTimerWaitForKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070010507}
10508
Jeff Johnson295189b2012-06-20 16:38:30 -070010509void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
10510 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
10511{
10512 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
10513 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010514 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
10515 /* To silence the KW tool Null chaeck is added */
10516 if(!pSession)
10517 {
10518 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10519 return;
10520 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010521
10522 if(pCommand)
10523 {
10524 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010525 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070010526 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010527 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
10528 {
10529 //if success, force roaming completion
10530 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
10531 }
10532 else
10533 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010534 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010535 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d"), roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -070010536 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
10537 }
10538}
10539
Jeff Johnson295189b2012-06-20 16:38:30 -070010540eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
10541{
10542 eHalStatus status = eHAL_STATUS_SUCCESS;
10543 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
10544 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
10545 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
10546 tCsrRoamInfo *pRoamInfo = NULL;
10547 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010548 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -070010549 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010550 /* To silence the KW tool Null chaeck is added */
10551 if(!pSession)
10552 {
10553 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10554 return eHAL_STATUS_FAILURE;
10555 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010556 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010557 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -070010558 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
10559 if ( eWNI_SME_DISASSOC_IND == type )
10560 {
10561 result = eCSR_ROAM_RESULT_DISASSOC_IND;
10562 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
10563 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010564 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010565 }
10566 else if ( eWNI_SME_DEAUTH_IND == type )
10567 {
10568 result = eCSR_ROAM_RESULT_DEAUTH_IND;
10569 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
10570 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Madan Mohan Koyyalamudi6a808932012-11-06 16:05:54 -080010571 /* Convert into proper reason code */
10572 pSession->joinFailStatusCode.reasonCode =
10573 (pDeauthIndMsg->reasonCode == eSIR_BEACON_MISSED) ?
Agarwal Ashish838f1f32013-03-11 20:54:52 +053010574 0 : pDeauthIndMsg->reasonCode;
10575 /* cfg layer expects 0 as reason code if
10576 the driver dosent know the reason code
10577 eSIR_BEACON_MISSED is defined as locally */
Jeff Johnson295189b2012-06-20 16:38:30 -070010578 }
10579 else
10580 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010581 smsLog(pMac, LOGW, FL("gets an unknown type (%d)"), type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010582 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010583 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070010584 }
10585
10586 // call profile lost link routine here
Jeff Johnson295189b2012-06-20 16:38:30 -070010587 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -070010588 {
10589 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_LOSTLINK_DETECTED, result);
10590 }
10591
10592 if ( eWNI_SME_DISASSOC_IND == type )
10593 {
10594 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
10595 }
10596 else if ( eWNI_SME_DEAUTH_IND == type )
10597 {
10598 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
10599 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010600 if(!HAL_STATUS_SUCCESS(status))
10601 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010602 //If fail to send confirmation to PE, not to trigger roaming
10603 fToRoam = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010604 }
10605
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010606 //prepare to tell HDD to disconnect
Kiet Lam64c1b492013-07-12 13:56:44 +053010607 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010608 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10609 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010610 if( eWNI_SME_DISASSOC_IND == type)
10611 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010612 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010613 vos_mem_copy(roamInfo.peerMac, pDisassocIndMsg->peerMacAddr,
10614 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010615 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
10616 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010617 else if( eWNI_SME_DEAUTH_IND == type )
10618 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010619 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010620 vos_mem_copy(roamInfo.peerMac, pDeauthIndMsg->peerMacAddr,
10621 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010622 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
10623 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010624 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)"), roamInfo.staId);
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010625
10626 /* See if we can possibly roam. If so, start the roaming process and notify HDD
10627 that we are roaming. But if we cannot possibly roam, or if we are unable to
10628 currently roam, then notify HDD of the lost link */
Jeff Johnson295189b2012-06-20 16:38:30 -070010629 if(fToRoam)
10630 {
10631 //Only remove the connected BSS in infrastructure mode
10632 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10633 //Not to do anying for lostlink with WDS
10634 if( pMac->roam.configParam.nRoamingTime )
10635 {
10636 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
10637 ( eWNI_SME_DEAUTH_IND == type ) ?
10638 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
10639 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010640 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010641 //For IBSS, we need to give some more info to HDD
10642 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
10643 {
10644 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
10645 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10646 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
10647 }
10648 else
10649 {
10650 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
10651 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010652 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010653 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
10654 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
10655 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10656 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
10657 }
10658 else
10659 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010660 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010661 fToRoam = eANI_BOOLEAN_FALSE;
10662 }
10663 }
10664 else
10665 {
10666 //We are told not to roam, indicate lostlink
10667 fToRoam = eANI_BOOLEAN_FALSE;
10668 }
10669 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010670 if(!fToRoam)
10671 {
Madan Mohan Koyyalamudiaf854cf2012-10-30 17:56:25 -070010672 //Tell HDD about the lost link
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010673 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010674 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010675 /* Don't call csrRoamCallCallback for GO/SoftAp case as this indication
10676 * was already given as part of eWNI_SME_DISASSOC_IND msg handling in
10677 * csrRoamCheckForLinkStatusChange API.
10678 */
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010679 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
10680 }
10681
10682 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -070010683 Still enable idle scan for polling in case concurrent sessions are running */
10684 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
10685 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010686 csrScanStartIdleScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010687 }
10688 }
10689
10690 return (status);
10691}
10692
Jeff Johnson295189b2012-06-20 16:38:30 -070010693eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
10694{
10695 eHalStatus status = eHAL_STATUS_SUCCESS;
10696 tListElem *pEntry = NULL;
10697 tSmeCmd *pCommand = NULL;
10698 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010699
10700 if(!pSession)
10701 {
10702 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10703 return eHAL_STATUS_FAILURE;
10704 }
10705
Jeff Johnson295189b2012-06-20 16:38:30 -070010706 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010707 //Only remove the connected BSS in infrastructure mode
10708 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10709 if(pMac->roam.configParam.nRoamingTime)
10710 {
10711 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
10712 {
10713 //before starting the lost link logic release the roam command for handoff
10714 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
10715 if(pEntry)
10716 {
10717 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
10718 }
10719 if(pCommand)
10720 {
10721 if (( eSmeCommandRoam == pCommand->command ) &&
10722 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
10723 {
10724 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10725 {
10726 csrReleaseCommandRoam( pMac, pCommand );
10727 }
10728 }
10729 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010730 smsLog( pMac, LOGW, "Lost link roaming started ...");
Jeff Johnson295189b2012-06-20 16:38:30 -070010731 }
10732 }
10733 else
10734 {
10735 //We are told not to roam, indicate lostlink
10736 status = eHAL_STATUS_FAILURE;
10737 }
10738
10739 return (status);
10740}
Jeff Johnson295189b2012-06-20 16:38:30 -070010741void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
10742{
10743 tListElem *pEntry;
10744 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070010745 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10746 if ( pEntry )
10747 {
10748 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10749 if ( eSmeCommandWmStatusChange == pCommand->command )
10750 {
10751 // Nothing to process in a Lost Link completion.... It just kicks off a
10752 // roaming sequence.
10753 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10754 {
10755 csrReleaseCommandWmStatusChange( pMac, pCommand );
10756 }
10757 else
10758 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010759 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command");
Jeff Johnson295189b2012-06-20 16:38:30 -070010760 }
10761
10762 }
10763 else
10764 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010765 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010766 }
10767 }
10768 else
10769 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010770 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010771 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010772 smeProcessPendingQueue( pMac );
10773}
10774
Jeff Johnson295189b2012-06-20 16:38:30 -070010775void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
10776{
10777 eHalStatus status = eHAL_STATUS_FAILURE;
10778 tSirSmeRsp *pSirSmeMsg;
10779 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010780
10781 if(!pSession)
10782 {
10783 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
10784 return;
10785 }
10786
Jeff Johnson295189b2012-06-20 16:38:30 -070010787 switch ( pCommand->u.wmStatusChangeCmd.Type )
10788 {
10789 case eCsrDisassociated:
10790 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
10791 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
10792 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010793 case eCsrDeauthenticated:
10794 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
10795 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
10796 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010797 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010798 smsLog(pMac, LOGW, FL("gets an unknown command %d"), pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010799 break;
10800 }
10801 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
10802 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
10803 {
10804 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
10805 {
10806 //This is not good
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010807 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010808 }
10809 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010810 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
10811 // command here since there is nothing else to do.
10812 csrRoamWmStatusChangeComplete( pMac );
10813}
10814
Jeff Johnson295189b2012-06-20 16:38:30 -070010815//This function returns band and mode information.
10816//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
10817//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -070010818static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10819 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -070010820{
Jeff Johnson295189b2012-06-20 16:38:30 -070010821 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
10822 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
10823 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070010824 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -070010825
Jeff Johnson295189b2012-06-20 16:38:30 -070010826 //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 -070010827 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
10828 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
10829 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
10830 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -070010831 {
10832 switch( pMac->roam.configParam.uCfgDot11Mode )
10833 {
10834 case eCSR_CFG_DOT11_MODE_11A:
10835 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10836 eBand = eCSR_BAND_5G;
10837 break;
10838 case eCSR_CFG_DOT11_MODE_11B:
10839 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10840 eBand = eCSR_BAND_24;
10841 break;
10842 case eCSR_CFG_DOT11_MODE_11G:
10843 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10844 eBand = eCSR_BAND_24;
10845 break;
10846 case eCSR_CFG_DOT11_MODE_11N:
10847 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010848 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10849 break;
10850#ifdef WLAN_FEATURE_11AC
10851 case eCSR_CFG_DOT11_MODE_11AC:
10852 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10853 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010854 /* If the operating channel is in 2.4 GHz band, check for
10855 * INI item to disable VHT operation in 2.4 GHz band
10856 */
10857 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10858 !pMac->roam.configParam.enableVhtFor24GHz)
10859 {
10860 /* Disable 11AC operation */
10861 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10862 }
10863 else
10864 {
10865 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10866 }
10867 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010868 }
10869 else
10870 {
10871 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10872 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10873 }
10874 break;
10875 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
10876 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10877 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010878 /* If the operating channel is in 2.4 GHz band, check for
10879 * INI item to disable VHT operation in 2.4 GHz band
10880 */
10881 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10882 !pMac->roam.configParam.enableVhtFor24GHz)
10883 {
10884 /* Disable 11AC operation */
10885 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10886 }
10887 else
10888 {
10889 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
10890 }
10891 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010892 }
10893 else
10894 {
10895 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10896 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10897 }
10898 break;
10899#endif
10900 case eCSR_CFG_DOT11_MODE_AUTO:
10901 eBand = pMac->roam.configParam.eBand;
10902 if (eCSR_BAND_24 == eBand)
10903 {
10904 // WiFi tests require IBSS networks to start in 11b mode
10905 // without any change to the default parameter settings
10906 // on the adapter. We use ACU to start an IBSS through
10907 // creation of a startIBSS profile. This startIBSS profile
10908 // has Auto MACProtocol and the adapter property setting
10909 // for dot11Mode is also AUTO. So in this case, let's
10910 // start the IBSS network in 11b mode instead of 11g mode.
10911 // So this is for Auto=profile->MacProtocol && Auto=Global.
10912 // dot11Mode && profile->channel is < 14, then start the IBSS
10913 // in b mode.
10914 //
10915 // Note: we used to have this start as an 11g IBSS for best
10916 // performance... now to specify that the user will have to
10917 // set the do11Mode in the property page to 11g to force it.
10918 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10919 }
10920 else
10921 {
10922#ifdef WLAN_FEATURE_11AC
10923 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10924 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010925 /* If the operating channel is in 2.4 GHz band, check for
10926 * INI item to disable VHT operation in 2.4 GHz band
10927 */
10928 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10929 !pMac->roam.configParam.enableVhtFor24GHz)
10930 {
10931 /* Disable 11AC operation */
10932 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10933 }
10934 else
10935 {
10936 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10937 }
10938 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010939 }
10940 else
10941 {
10942 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10943 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10944 }
10945#else
10946 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10947 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10948#endif
10949 }
10950 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010951 default:
10952 // Global dot11 Mode setting is 11a/b/g.
10953 // use the channel number to determine the Mode setting.
10954 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10955 {
10956 eBand = pMac->roam.configParam.eBand;
10957 if(eCSR_BAND_24 == eBand)
10958 {
10959 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
10960 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10961 }
10962 else
10963 {
10964 //prefer 5GHz
10965 eBand = eCSR_BAND_5G;
10966 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10967 }
10968 }
10969 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10970 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070010971 // WiFi tests require IBSS networks to start in 11b mode
10972 // without any change to the default parameter settings
10973 // on the adapter. We use ACU to start an IBSS through
10974 // creation of a startIBSS profile. This startIBSS profile
10975 // has Auto MACProtocol and the adapter property setting
10976 // for dot11Mode is also AUTO. So in this case, let's
10977 // start the IBSS network in 11b mode instead of 11g mode.
10978 // So this is for Auto=profile->MacProtocol && Auto=Global.
10979 // dot11Mode && profile->channel is < 14, then start the IBSS
10980 // in b mode.
Jeff Johnson295189b2012-06-20 16:38:30 -070010981 //
Ravi Joshia96ceb42013-05-20 18:52:39 -070010982 // Note: we used to have this start as an 11g IBSS for best
10983 // performance... now to specify that the user will have to
10984 // set the do11Mode in the property page to 11g to force it.
Jeff Johnson295189b2012-06-20 16:38:30 -070010985 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10986 eBand = eCSR_BAND_24;
10987 }
10988 else
10989 {
10990 // else, it's a 5.0GHz channel. Set mode to 11a.
10991 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10992 eBand = eCSR_BAND_5G;
10993 }
10994 break;
10995 }//switch
10996 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
10997 else
10998 {
10999 //dot11 mode is set, lets pick the band
11000 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
11001 {
11002 // channel is Auto also.
11003 eBand = pMac->roam.configParam.eBand;
11004 if(eCSR_BAND_ALL == eBand)
11005 {
11006 //prefer 5GHz
11007 eBand = eCSR_BAND_5G;
11008 }
11009 }
11010 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11011 {
11012 eBand = eCSR_BAND_24;
11013 }
11014 else
11015 {
11016 eBand = eCSR_BAND_5G;
11017 }
Ravi Joshia96ceb42013-05-20 18:52:39 -070011018 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011019 if(pBand)
11020 {
11021 *pBand = eBand;
11022 }
11023
11024 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011025 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -070011026 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11027 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011028
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080011029 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
11030 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 -070011031 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011032#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011033 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011034#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011035 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
11036 {
11037 //We cannot do 11n here
11038 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11039 {
11040 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
11041 }
11042 else
11043 {
11044 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11045 }
11046 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011047 return( cfgDot11Mode );
11048}
11049
Jeff Johnson295189b2012-06-20 16:38:30 -070011050eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
11051{
11052 eHalStatus status;
11053 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011054
11055 if(!pSession)
11056 {
11057 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11058 return eHAL_STATUS_FAILURE;
11059 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011060
11061#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11062 {
11063 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011064 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11065 if(pIbssLog)
11066 {
11067 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
11068 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11069 }
11070 }
11071#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011072 // Set the roaming substate to 'stop Bss request'...
11073 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
11074
11075 // attempt to stop the Bss (reason code is ignored...)
11076 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080011077 if(!HAL_STATUS_SUCCESS(status))
11078 {
11079 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
11080 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011081 return (status);
11082}
11083
Jeff Johnson295189b2012-06-20 16:38:30 -070011084//pNumChan is a caller allocated space with the sizeof pChannels
11085eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
11086{
11087
11088 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
11089 (tANI_U8 *)pChannels,
11090 pNumChan));
11091}
11092
Kiran4a17ebe2013-01-31 10:43:43 -080011093tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
11094{
11095 tANI_U32 cfgLength = 0;
11096 tANI_U16 cfgId = 0;
11097 tPowerdBm maxTxPwr = 0;
11098 tANI_U8 *pCountryInfo = NULL;
11099 eHalStatus status;
11100 tANI_U8 count = 0;
11101 tANI_U8 firstChannel;
11102 tANI_U8 maxChannels;
11103
11104 if (CSR_IS_CHANNEL_5GHZ(channel))
11105 {
11106 cfgId = WNI_CFG_MAX_TX_POWER_5;
11107 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
11108 }
11109 else if (CSR_IS_CHANNEL_24GHZ(channel))
11110 {
11111 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
11112 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
11113 }
11114 else
11115 return maxTxPwr;
11116
Kiet Lam64c1b492013-07-12 13:56:44 +053011117 pCountryInfo = vos_mem_malloc(cfgLength);
11118 if ( NULL == pCountryInfo )
11119 status = eHAL_STATUS_FAILURE;
11120 else
11121 status = eHAL_STATUS_SUCCESS;
Kiran4a17ebe2013-01-31 10:43:43 -080011122 if (status != eHAL_STATUS_SUCCESS)
11123 {
11124 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiet Lam64c1b492013-07-12 13:56:44 +053011125 FL("%s: failed to allocate memory, status = %d"),
Kiran4a17ebe2013-01-31 10:43:43 -080011126 __FUNCTION__, status);
11127 goto error;
11128 }
11129 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
11130 if (status != eHAL_STATUS_SUCCESS)
11131 {
11132 goto error;
11133 }
11134 /* Identify the channel and maxtxpower */
11135 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
11136 {
11137 firstChannel = pCountryInfo[count++];
11138 maxChannels = pCountryInfo[count++];
11139 maxTxPwr = pCountryInfo[count++];
11140
11141 if ((channel >= firstChannel) &&
11142 (channel < (firstChannel + maxChannels)))
11143 {
11144 break;
11145 }
11146 }
11147
11148error:
11149 if (NULL != pCountryInfo)
Kiet Lam64c1b492013-07-12 13:56:44 +053011150 vos_mem_free(pCountryInfo);
Kiran4a17ebe2013-01-31 10:43:43 -080011151
11152 return maxTxPwr;
11153}
11154
11155
Jeff Johnson295189b2012-06-20 16:38:30 -070011156tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
11157{
11158 tANI_BOOLEAN fValid = FALSE;
11159 tANI_U32 idxValidChannels;
11160 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11161
11162 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
11163 {
11164 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
11165 {
11166 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
11167 {
11168 fValid = TRUE;
11169 break;
11170 }
11171 }
11172 }
11173 pMac->roam.numValidChannels = len;
11174 return fValid;
11175}
11176
Jeff Johnson295189b2012-06-20 16:38:30 -070011177tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
11178{
11179 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
11180 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011181 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
11182 {
11183 if(channel == pMac->scan.base40MHzChannels.channelList[i])
11184 {
11185 fValid = eANI_BOOLEAN_TRUE;
11186 break;
11187 }
11188 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011189 return (fValid);
11190}
11191
Jeff Johnson295189b2012-06-20 16:38:30 -070011192//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070011193 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011194{
Jeff Johnsone7245742012-09-05 17:12:55 -070011195 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011196 tANI_U8 centerChn;
11197 tANI_U32 ChannelBondingMode;
Sandeep Puligilla60342762014-01-30 21:05:37 +053011198
Jeff Johnson295189b2012-06-20 16:38:30 -070011199 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
11200 {
11201 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
11202 }
11203 else
11204 {
11205 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
11206 }
11207 //Figure what the other side's CB mode
11208 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
11209 {
11210 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
11211 {
Agrawal Ashishf187d512014-04-03 17:01:52 +053011212 // In Case WPA2 and TKIP is the only one cipher suite in Pairwise.
11213 if ((pIes->RSN.present && (pIes->RSN.pwise_cipher_suite_count == 1) &&
11214 !memcmp(&(pIes->RSN.pwise_cipher_suites[0][0]),
11215 "\x00\x0f\xac\x02",4))
11216 //In Case WPA1 and TKIP is the only one cipher suite in Unicast.
11217 ||(pIes->WPA.present && (pIes->WPA.unicast_cipher_count == 1) &&
11218 !memcmp(&(pIes->WPA.unicast_ciphers[0][0]),
11219 "\x00\x50\xf2\x02",4)))
11220
Leela Venkata Kiran Kumar Reddy Chirala10c5a2e2013-12-18 14:41:28 -080011221 {
11222 smsLog(pMac, LOGW, " No channel bonding in TKIP mode ");
11223 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11224 }
11225
11226 else if(pIes->HTInfo.present)
Jeff Johnson295189b2012-06-20 16:38:30 -070011227 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011228 /* This is called during INFRA STA/CLIENT and should use the merged value of
11229 * supported channel width and recommended tx width as per standard
11230 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011231 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070011232 pIes->HTCaps.supportedChannelWidthSet,
11233 pIes->HTInfo.recommendedTxWidthSet,
11234 pIes->HTInfo.secondaryChannelOffset);
11235
11236 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
11237 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070011238 else
Jeff Johnsone7245742012-09-05 17:12:55 -070011239 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11240 switch (eRet) {
11241 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
11242 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
11243 break;
11244 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
11245 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
11246 break;
11247 case PHY_SINGLE_CHANNEL_CENTERED:
11248 default:
11249 centerChn = primaryChn;
11250 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011251 }
Jeff Johnsone7245742012-09-05 17:12:55 -070011252 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070011253 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011254 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Abhishek Singh25144bb2014-05-01 16:03:21 +053011255 eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011256 }
11257 }
11258 }
11259 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011260 return eRet;
11261}
Jeff Johnson295189b2012-06-20 16:38:30 -070011262tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
11263{
11264 tANI_BOOLEAN fFound = FALSE;
11265 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011266 for( idx = 0; idx < pCipherList->numEntries; idx++ )
11267 {
11268 if( pCipherList->encryptionType[idx] == encryptionType )
11269 {
11270 fFound = TRUE;
11271 break;
11272 }
11273 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011274 return fFound;
11275}
Jeff Johnson295189b2012-06-20 16:38:30 -070011276tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
11277{
11278 tANI_BOOLEAN fFound = FALSE;
11279 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011280 for( idx = 0; idx < pAuthList->numEntries; idx++ )
11281 {
11282 if( pAuthList->authType[idx] == authType )
11283 {
11284 fFound = TRUE;
11285 break;
11286 }
11287 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011288 return fFound;
11289}
Jeff Johnson295189b2012-06-20 16:38:30 -070011290tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
11291{
11292 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11293 tCsrScanResultFilter *pScanFilter = NULL;
11294 eHalStatus status = eHAL_STATUS_SUCCESS;
11295
11296 if(pProfile1 && pProfile2)
11297 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011298 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
11299 if ( NULL == pScanFilter )
11300 status = eHAL_STATUS_FAILURE;
11301 else
11302 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011303 if(HAL_STATUS_SUCCESS(status))
11304 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011305 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011306 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
11307 if(HAL_STATUS_SUCCESS(status))
11308 {
11309 fCheck = eANI_BOOLEAN_FALSE;
11310 do
11311 {
11312 tANI_U32 i;
11313 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
11314 {
11315 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
11316 pScanFilter->SSIDs.SSIDList[i].SSID.length,
11317 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
11318 if ( fCheck ) break;
11319 }
11320 if(!fCheck)
11321 {
11322 break;
11323 }
11324 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
11325 || pProfile2->BSSType != pProfile1->BSSType
11326 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
11327 )
11328 {
11329 fCheck = eANI_BOOLEAN_FALSE;
11330 break;
11331 }
11332#ifdef WLAN_FEATURE_VOWIFI_11R
11333 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
11334 {
11335 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
11336 {
11337 fCheck = eANI_BOOLEAN_FALSE;
11338 break;
11339 }
11340 }
11341#endif
11342 //Match found
11343 fCheck = eANI_BOOLEAN_TRUE;
11344 }while(0);
11345 csrFreeScanFilter(pMac, pScanFilter);
11346 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011347 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011348 }
11349 }
11350
11351 return (fCheck);
11352}
11353
Jeff Johnson295189b2012-06-20 16:38:30 -070011354tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
11355{
11356 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11357 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011358 do
11359 {
11360 //Only check for static WEP
11361 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
11362 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
11363 {
11364 fCheck = eANI_BOOLEAN_TRUE;
11365 break;
11366 }
11367 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
11368 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
11369 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
11370 {
11371 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053011372 if (!vos_mem_compare(&pConnProfile->Keys.KeyMaterial[i],
11373 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
Jeff Johnson295189b2012-06-20 16:38:30 -070011374 {
11375 break;
11376 }
11377 }
11378 if( i == CSR_MAX_NUM_KEY)
11379 {
11380 fCheck = eANI_BOOLEAN_TRUE;
11381 }
11382 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011383 return (fCheck);
11384}
11385
Jeff Johnson295189b2012-06-20 16:38:30 -070011386//IBSS
11387
Jeff Johnson295189b2012-06-20 16:38:30 -070011388tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
11389{
11390 tANI_U8 channel = 0;
11391 tANI_U32 idx;
11392 tANI_U32 idxValidChannels;
11393 tANI_BOOLEAN fFound = FALSE;
11394 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11395
11396 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
11397 {
11398 channel = pMac->roam.configParam.AdHocChannel5G;
11399 if(!csrRoamIsChannelValid(pMac, channel))
11400 {
11401 channel = 0;
11402 }
11403 }
11404 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11405 {
11406 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
11407 {
11408 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11409 {
11410 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11411 {
11412 fFound = TRUE;
11413 channel = csrStartIbssChannels50[ idx ];
11414 }
11415 }
11416 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011417 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
11418 if (!fFound)
11419 {
11420 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
11421 {
11422 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idx ]) ) // the max channel# in 11g is 14
11423 {
11424 channel = csrStartIbssChannels50[ idx ];
11425 break;
11426 }
11427 }
11428 }
11429 }//if
11430
11431 return( channel );
11432}
11433
Jeff Johnson295189b2012-06-20 16:38:30 -070011434tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
11435{
11436 tANI_U8 channel = 1;
11437 tANI_U32 idx;
11438 tANI_U32 idxValidChannels;
11439 tANI_BOOLEAN fFound = FALSE;
11440 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11441
11442 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
11443 {
11444 channel = pMac->roam.configParam.AdHocChannel24;
11445 if(!csrRoamIsChannelValid(pMac, channel))
11446 {
11447 channel = 0;
11448 }
11449 }
11450
11451 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11452 {
11453 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
11454 {
11455 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11456 {
11457 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11458 {
11459 fFound = TRUE;
11460 channel = csrStartIbssChannels24[ idx ];
11461 }
11462 }
11463 }
11464 }
11465
11466 return( channel );
11467}
11468
Jeff Johnson295189b2012-06-20 16:38:30 -070011469static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
11470 tCsrRoamStartBssParams *pParam )
11471{
11472 eCsrCfgDot11Mode cfgDot11Mode;
11473 eCsrBand eBand;
11474 tANI_U8 channel = 0;
11475 tSirNwType nwType;
11476 tANI_U8 operationChannel = 0;
11477
11478 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
11479 {
11480 operationChannel = pProfile->ChannelInfo.ChannelList[0];
11481 }
11482
Jeff Johnson295189b2012-06-20 16:38:30 -070011483 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070011484
Jeff Johnson295189b2012-06-20 16:38:30 -070011485 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11486 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
11487 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
11488 )
11489 {
11490 /* This should never happen */
11491 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011492 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070011493 pProfile->csrPersona);
11494 VOS_ASSERT(0);
11495 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011496 switch( cfgDot11Mode )
11497 {
11498 case eCSR_CFG_DOT11_MODE_11G:
11499 nwType = eSIR_11G_NW_TYPE;
11500 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011501 case eCSR_CFG_DOT11_MODE_11B:
11502 nwType = eSIR_11B_NW_TYPE;
11503 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011504 case eCSR_CFG_DOT11_MODE_11A:
11505 nwType = eSIR_11A_NW_TYPE;
11506 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011507 default:
11508 case eCSR_CFG_DOT11_MODE_11N:
11509 case eCSR_CFG_DOT11_MODE_TAURUS:
11510 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
11511 if(eCSR_BAND_24 == eBand)
11512 {
11513 nwType = eSIR_11G_NW_TYPE;
11514 }
11515 else
11516 {
11517 nwType = eSIR_11A_NW_TYPE;
11518 }
11519 break;
11520 }
11521
11522 pParam->extendedRateSet.numRates = 0;
11523
11524 switch ( nwType )
11525 {
11526 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011527 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011528 case eSIR_11A_NW_TYPE:
11529
11530 pParam->operationalRateSet.numRates = 8;
11531
11532 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11533 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11534 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11535 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11536 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11537 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11538 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11539 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11540
11541 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11542 {
11543 channel = csrRoamGetIbssStartChannelNumber50( pMac );
11544 if( 0 == channel &&
11545 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
11546 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
11547 )
11548 {
11549 //We could not find a 5G channel by auto pick, let's try 2.4G channels
11550 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
11551 nwType = eSIR_11B_NW_TYPE;
11552 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11553 pParam->operationalRateSet.numRates = 4;
11554 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11555 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11556 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11557 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11558 }
11559 }
11560 else
11561 {
11562 channel = operationChannel;
11563 }
11564 break;
11565
11566 case eSIR_11B_NW_TYPE:
11567 pParam->operationalRateSet.numRates = 4;
11568 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11569 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11570 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11571 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070011572 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11573 {
11574 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11575 }
11576 else
11577 {
11578 channel = operationChannel;
11579 }
11580
11581 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011582 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070011583 /* For P2P Client and P2P GO, disable 11b rates */
11584 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11585 (pProfile->csrPersona == VOS_P2P_GO_MODE)
11586 )
11587 {
11588 pParam->operationalRateSet.numRates = 8;
11589
11590 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11591 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11592 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11593 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11594 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11595 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11596 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11597 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11598 }
11599 else
Jeff Johnson295189b2012-06-20 16:38:30 -070011600 {
11601 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070011602 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11603 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11604 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11605 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11606
11607 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070011608 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
11609 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
11610 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
11611 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
11612 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
11613 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
11614 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
11615 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
11616 }
11617
11618 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11619 {
11620 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11621 }
11622 else
11623 {
11624 channel = operationChannel;
11625 }
11626
11627 break;
11628 }
11629 pParam->operationChn = channel;
11630 pParam->sirNwType = nwType;
11631}
11632
Jeff Johnson295189b2012-06-20 16:38:30 -070011633static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
11634 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
11635{
11636
11637 if( pParam )
11638 {
11639 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070011640 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011641 pParam->operationChn = pBssDesc->channelId;
Kiet Lam64c1b492013-07-12 13:56:44 +053011642 vos_mem_copy(&pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011643
11644 if( pIes )
11645 {
11646 if(pIes->SuppRates.present)
11647 {
11648 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
11649 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
11650 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011651 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 -070011652 pIes->SuppRates.num_rates);
11653 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
11654 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011655 vos_mem_copy(pParam->operationalRateSet.rate, pIes->SuppRates.rates,
11656 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
Jeff Johnson295189b2012-06-20 16:38:30 -070011657 }
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011658 if (pIes->ExtSuppRates.present)
11659 {
11660 pParam->extendedRateSet.numRates = pIes->ExtSuppRates.num_rates;
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053011661 if(pIes->ExtSuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011662 {
11663 smsLog(pMac, LOGE, FL("num_rates :%d is more than \
11664 SIR_MAC_RATESET_EID_MAX, resetting to \
11665 SIR_MAC_RATESET_EID_MAX"),
11666 pIes->ExtSuppRates.num_rates);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053011667 pIes->ExtSuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011668 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053011669 vos_mem_copy(pParam->extendedRateSet.rate,
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011670 pIes->ExtSuppRates.rates,
11671 sizeof(*pIes->ExtSuppRates.rates) * pIes->ExtSuppRates.num_rates);
11672 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011673 if( pIes->SSID.present )
11674 {
11675 pParam->ssId.length = pIes->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +053011676 vos_mem_copy(pParam->ssId.ssId, pIes->SSID.ssid,
11677 pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011678 }
11679 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070011680 }
11681 else
11682 {
11683 pParam->ssId.length = 0;
11684 pParam->operationalRateSet.numRates = 0;
11685 }
11686 }
11687}
11688
Jeff Johnson295189b2012-06-20 16:38:30 -070011689static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
11690{
11691 tANI_U8 MaxRate = 0;
11692 tANI_U32 i;
11693 tANI_U8 *pRate;
11694
11695 pRate = pSirRateSet->rate;
11696 for ( i = 0; i < pSirRateSet->numRates; i++ )
11697 {
11698 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
11699 }
11700
11701 // Save the max rate in the connected state information...
11702
11703 // modify LastRates variable as well
11704
11705 return;
11706}
11707
Jeff Johnson295189b2012-06-20 16:38:30 -070011708eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
11709 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
11710{
11711 eHalStatus status = eHAL_STATUS_SUCCESS;
11712 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070011713 // Set the roaming substate to 'Start BSS attempt'...
11714 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011715#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11716 //Need to figure out whether we need to log WDS???
11717 if( CSR_IS_IBSS( pProfile ) )
11718 {
11719 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011720 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11721 if(pIbssLog)
11722 {
11723 if(pBssDesc)
11724 {
11725 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
Kiet Lam64c1b492013-07-12 13:56:44 +053011726 vos_mem_copy(pIbssLog->bssid, pBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070011727 }
11728 else
11729 {
11730 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
11731 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011732 vos_mem_copy(pIbssLog->ssid, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011733 if(pProfile->ChannelInfo.numOfChannels == 0)
11734 {
11735 pIbssLog->channelSetting = AUTO_PICK;
11736 }
11737 else
11738 {
11739 pIbssLog->channelSetting = SPECIFIED;
11740 }
11741 pIbssLog->operatingChannel = pParam->operationChn;
11742 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11743 }
11744 }
11745#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
11746 //Put RSN information in for Starting BSS
11747 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
11748 pParam->pRSNIE = pProfile->pRSNReqIE;
11749
Jeff Johnson295189b2012-06-20 16:38:30 -070011750 pParam->privacy = pProfile->privacy;
11751 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
11752 pParam->authType = pProfile->csr80211AuthType;
11753 pParam->beaconInterval = pProfile->beaconInterval;
11754 pParam->dtimPeriod = pProfile->dtimPeriod;
11755 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
11756 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
11757 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
11758 {
11759 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
11760 {
11761 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
11762 }
11763 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011764 pParam->protEnabled = pProfile->protEnabled;
11765 pParam->obssProtEnabled = pProfile->obssProtEnabled;
11766 pParam->ht_protection = pProfile->cfg_protection;
11767 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080011768
Jeff Johnson295189b2012-06-20 16:38:30 -070011769 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
11770 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070011771 pParam->bssPersona = pProfile->csrPersona;
Chet Lanctot8cecea22014-02-11 19:09:36 -080011772
11773#ifdef WLAN_FEATURE_11W
11774 pParam->mfpCapable = (0 != pProfile->MFPCapable);
11775 pParam->mfpRequired = (0 != pProfile->MFPRequired);
11776#endif
11777
Jeff Johnson295189b2012-06-20 16:38:30 -070011778 // When starting an IBSS, start on the channel from the Profile.
11779 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070011780 return (status);
11781}
11782
Jeff Johnson295189b2012-06-20 16:38:30 -070011783static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070011784 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011785{
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011786 tANI_U8 Channel;
Jeff Johnsone7245742012-09-05 17:12:55 -070011787 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011788 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011789
11790 if(!pSession)
11791 {
11792 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11793 return;
11794 }
11795
Jeff Johnson295189b2012-06-20 16:38:30 -070011796 if( pBssDesc )
11797 {
11798 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
11799 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
11800 //The following code has to be do after that.
11801 //For WDS station, use selfMac as the self BSSID
11802 if( CSR_IS_WDS_STA( pProfile ) )
11803 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011804 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
11805 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011806 }
11807 }
11808 else
11809 {
11810 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070011811 //Use the first SSID
11812 if(pProfile->SSIDs.numOfSSIDs)
11813 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011814 vos_mem_copy(&pSession->bssParams.ssId, pProfile->SSIDs.SSIDList,
11815 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011816 }
11817 //For WDS station, use selfMac as the self BSSID
11818 if( CSR_IS_WDS_STA( pProfile ) )
11819 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011820 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
11821 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011822 }
11823 //Use the first BSSID
11824 else if( pProfile->BSSIDs.numOfBSSIDs )
11825 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011826 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid,
11827 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011828 }
11829 else
11830 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011831 vos_mem_set(&pSession->bssParams.bssid, sizeof(tCsrBssid), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011832 }
11833 }
11834 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070011835 //Set operating channel in pProfile which will be used
11836 //in csrRoamSetBssConfigCfg() to determine channel bonding
11837 //mode and will be configured in CFG later
11838 pProfile->operationChannel = Channel;
11839
11840 if(Channel == 0)
11841 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053011842 smsLog(pMac, LOGE, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070011843 }
11844 else
11845 {
11846
11847 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011848 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS( pProfile ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011849 {
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011850 if(CSR_IS_CHANNEL_24GHZ(Channel) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011851 {
Sandeep Puligillae3f239f2014-04-17 02:11:46 +053011852 /* TODO- SAP: HT40 Support in SAP 2.4Ghz mode is not enabled.
11853 so channel bonding in 2.4Ghz is configured as 20MHZ
11854 irrespective of the 'channelBondingMode24GHz' Parameter */
11855 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -070011856 }
11857 else
11858 {
11859 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
11860 }
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011861 smsLog(pMac, LOG1, "## cbMode %d", cbMode);
Jeff Johnsone7245742012-09-05 17:12:55 -070011862 pBssConfig->cbMode = cbMode;
11863 pSession->bssParams.cbMode = cbMode;
11864 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011865 }
11866}
11867
Jeff Johnson295189b2012-06-20 16:38:30 -070011868static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
11869 tANI_BOOLEAN *pfSameIbss )
11870{
11871 eHalStatus status = eHAL_STATUS_SUCCESS;
11872 tANI_BOOLEAN fSameIbss = FALSE;
11873
11874 if ( csrIsConnStateIbss( pMac, sessionId ) )
11875 {
11876 // Check if any profile parameter has changed ? If any profile parameter
11877 // has changed then stop old BSS and start a new one with new parameters
11878 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
11879 {
11880 fSameIbss = TRUE;
11881 }
11882 else
11883 {
11884 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
11885 }
11886 }
11887 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
11888 {
11889 // Disassociate from the connected Infrastructure network...
11890 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
11891 }
11892 else
11893 {
11894 tBssConfigParam *pBssConfig;
11895
Kiet Lam64c1b492013-07-12 13:56:44 +053011896 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
11897 if ( NULL == pBssConfig )
11898 status = eHAL_STATUS_FAILURE;
11899 else
11900 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011901 if(HAL_STATUS_SUCCESS(status))
11902 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011903 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011904 // there is no Bss description before we start an IBSS so we need to adopt
11905 // all Bss configuration parameters from the Profile.
11906 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
11907 if(HAL_STATUS_SUCCESS(status))
11908 {
11909 //save dotMode
11910 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
11911 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070011912 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053011913 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
11914 NULL, pBssConfig,
11915 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011916 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011917
11918 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -070011919 }//Allocate memory
11920 }
11921
11922 if(pfSameIbss)
11923 {
11924 *pfSameIbss = fSameIbss;
11925 }
11926 return( status );
11927}
11928
Jeff Johnson295189b2012-06-20 16:38:30 -070011929static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
11930 tSirSmeNewBssInfo *pNewBss )
11931{
11932 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011933
11934 if(!pSession)
11935 {
11936 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11937 return;
11938 }
11939
Jeff Johnson295189b2012-06-20 16:38:30 -070011940 if( pNewBss )
11941 {
11942 // Set the operating channel.
11943 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
11944 // move the BSSId from the BSS description into the connected state information.
Kiet Lam64c1b492013-07-12 13:56:44 +053011945 vos_mem_copy(&pSession->connectedProfile.bssid, &(pNewBss->bssId),
11946 sizeof( tCsrBssid ));
Jeff Johnson295189b2012-06-20 16:38:30 -070011947 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011948 return;
11949}
11950
Jeff Johnson295189b2012-06-20 16:38:30 -070011951#ifdef FEATURE_WLAN_WAPI
11952eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
11953 tANI_U32 numItems )
11954{
11955 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11956 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011957 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11958 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011959 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011960 return status;
11961 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011962 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011963 pSession = CSR_GET_SESSION( pMac, sessionId );
11964 if(numItems <= CSR_MAX_BKID_ALLOWED)
11965 {
11966 status = eHAL_STATUS_SUCCESS;
11967 //numItems may be 0 to clear the cache
11968 pSession->NumBkidCache = (tANI_U16)numItems;
11969 if(numItems && pBKIDCache)
11970 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011971 vos_mem_copy(pSession->BkidCacheInfo, pBKIDCache,
11972 sizeof(tBkidCacheInfo) * numItems);
11973 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011974 }
11975 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011976 return (status);
11977}
Jeff Johnson295189b2012-06-20 16:38:30 -070011978eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
11979 tBkidCacheInfo *pBkidCache)
11980{
11981 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11982 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011983 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11984 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011985 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011986 return status;
11987 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011988 pSession = CSR_GET_SESSION( pMac, sessionId );
11989 if(pNum && pBkidCache)
11990 {
11991 if(pSession->NumBkidCache == 0)
11992 {
11993 *pNum = 0;
11994 status = eHAL_STATUS_SUCCESS;
11995 }
11996 else if(*pNum >= pSession->NumBkidCache)
11997 {
11998 if(pSession->NumBkidCache > CSR_MAX_PMKID_ALLOWED)
11999 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012000 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 -070012001 pSession->NumBkidCache);
12002 pSession->NumBkidCache = CSR_MAX_PMKID_ALLOWED;
12003 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012004 vos_mem_copy(pBkidCache, pSession->BkidCacheInfo,
12005 sizeof(tBkidCacheInfo) * pSession->NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012006 *pNum = pSession->NumBkidCache;
12007 status = eHAL_STATUS_SUCCESS;
12008 }
12009 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012010 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070012011}
Jeff Johnson295189b2012-06-20 16:38:30 -070012012tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
12013{
12014 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012015}
12016#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012017eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
12018 tPmkidCacheInfo *pPMKIDCache, tANI_U32 numItems )
12019{
12020 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12021 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012022
12023 if(!pSession)
12024 {
12025 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12026 return eHAL_STATUS_FAILURE;
12027 }
12028
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012029 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070012030 if(numItems <= CSR_MAX_PMKID_ALLOWED)
12031 {
12032#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12033 {
12034 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053012035 vos_mem_set(&secEvent,
12036 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012037 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
12038 secEvent.encryptionModeMulticast =
12039 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
12040 secEvent.encryptionModeUnicast =
12041 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053012042 vos_mem_copy(secEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070012043 secEvent.authMode =
12044 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
12045 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
12046 }
12047#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070012048 status = eHAL_STATUS_SUCCESS;
12049 //numItems may be 0 to clear the cache
12050 pSession->NumPmkidCache = (tANI_U16)numItems;
12051 if(numItems && pPMKIDCache)
12052 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012053 vos_mem_copy(pSession->PmkidCacheInfo, pPMKIDCache,
12054 sizeof(tPmkidCacheInfo) * numItems);
12055 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012056 }
12057 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012058 return (status);
12059}
12060
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012061eHalStatus csrRoamDelPMKIDfromCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
12062 tANI_U8 *pBSSId )
12063{
12064 eHalStatus status = eHAL_STATUS_FAILURE;
12065 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12066 tANI_BOOLEAN fMatchFound = FALSE;
12067 tANI_U32 Index;
12068 if(!pSession)
12069 {
12070 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12071 return eHAL_STATUS_FAILURE;
12072 }
12073 do
12074 {
12075 for( Index=0; Index < pSession->NumPmkidCache; Index++ )
12076 {
Arif Hussaina7c8e412013-11-20 11:06:42 -080012077 smsLog(pMac, LOGW, "Delete PMKID for "
12078 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pBSSId));
Kiet Lamf2f201e2013-11-16 21:24:16 +053012079 if( vos_mem_compare( pBSSId, pSession->PmkidCacheInfo[Index].BSSID, sizeof(tCsrBssid) ) )
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012080 {
12081 fMatchFound = TRUE;
12082 break;
12083 }
12084 }
12085 if( !fMatchFound ) break;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053012086 vos_mem_set(pSession->PmkidCacheInfo[Index].BSSID, sizeof(tCsrBssid), 0);
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012087 status = eHAL_STATUS_SUCCESS;
12088 }
12089 while( 0 );
12090 smsLog(pMac, LOGW, "csrDelPMKID called return match = %d Status = %d",
12091 fMatchFound, status);
12092 return status;
12093}
Jeff Johnson295189b2012-06-20 16:38:30 -070012094tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
12095{
12096 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
12097}
12098
Jeff Johnson295189b2012-06-20 16:38:30 -070012099eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
12100{
12101 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12102 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012103
12104 if(!pSession)
12105 {
12106 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12107 return eHAL_STATUS_FAILURE;
12108 }
12109
Jeff Johnson295189b2012-06-20 16:38:30 -070012110 if(pNum && pPmkidCache)
12111 {
12112 if(pSession->NumPmkidCache == 0)
12113 {
12114 *pNum = 0;
12115 status = eHAL_STATUS_SUCCESS;
12116 }
12117 else if(*pNum >= pSession->NumPmkidCache)
12118 {
12119 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
12120 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012121 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 -070012122 pSession->NumPmkidCache);
12123 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
12124 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012125 vos_mem_copy(pPmkidCache, pSession->PmkidCacheInfo,
12126 sizeof(tPmkidCacheInfo) * pSession->NumPmkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012127 *pNum = pSession->NumPmkidCache;
12128 status = eHAL_STATUS_SUCCESS;
12129 }
12130 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012131 return (status);
12132}
12133
Jeff Johnson295189b2012-06-20 16:38:30 -070012134eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12135{
12136 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12137 tANI_U32 len;
12138 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012139
12140 if(!pSession)
12141 {
12142 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12143 return eHAL_STATUS_FAILURE;
12144 }
12145
Jeff Johnson295189b2012-06-20 16:38:30 -070012146 if(pLen)
12147 {
12148 len = *pLen;
12149 *pLen = pSession->nWpaRsnReqIeLength;
12150 if(pBuf)
12151 {
12152 if(len >= pSession->nWpaRsnReqIeLength)
12153 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012154 vos_mem_copy(pBuf, pSession->pWpaRsnReqIE,
12155 pSession->nWpaRsnReqIeLength);
12156 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012157 }
12158 }
12159 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012160 return (status);
12161}
12162
Jeff Johnson295189b2012-06-20 16:38:30 -070012163eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12164{
12165 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12166 tANI_U32 len;
12167 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012168
12169 if(!pSession)
12170 {
12171 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12172 return eHAL_STATUS_FAILURE;
12173 }
12174
Jeff Johnson295189b2012-06-20 16:38:30 -070012175 if(pLen)
12176 {
12177 len = *pLen;
12178 *pLen = pSession->nWpaRsnRspIeLength;
12179 if(pBuf)
12180 {
12181 if(len >= pSession->nWpaRsnRspIeLength)
12182 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012183 vos_mem_copy(pBuf, pSession->pWpaRsnRspIE,
12184 pSession->nWpaRsnRspIeLength);
12185 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012186 }
12187 }
12188 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012189 return (status);
12190}
Jeff Johnson295189b2012-06-20 16:38:30 -070012191#ifdef FEATURE_WLAN_WAPI
12192eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12193{
12194 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12195 tANI_U32 len;
12196 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012197
12198 if(!pSession)
12199 {
12200 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12201 return eHAL_STATUS_FAILURE;
12202 }
12203
Jeff Johnson295189b2012-06-20 16:38:30 -070012204 if(pLen)
12205 {
12206 len = *pLen;
12207 *pLen = pSession->nWapiReqIeLength;
12208 if(pBuf)
12209 {
12210 if(len >= pSession->nWapiReqIeLength)
12211 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012212 vos_mem_copy(pBuf, pSession->pWapiReqIE,
12213 pSession->nWapiReqIeLength);
12214 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012215 }
12216 }
12217 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012218 return (status);
12219}
Jeff Johnson295189b2012-06-20 16:38:30 -070012220eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12221{
12222 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12223 tANI_U32 len;
12224 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012225
12226 if(!pSession)
12227 {
12228 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12229 return eHAL_STATUS_FAILURE;
12230 }
12231
Jeff Johnson295189b2012-06-20 16:38:30 -070012232 if(pLen)
12233 {
12234 len = *pLen;
12235 *pLen = pSession->nWapiRspIeLength;
12236 if(pBuf)
12237 {
12238 if(len >= pSession->nWapiRspIeLength)
12239 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012240 vos_mem_copy(pBuf, pSession->pWapiRspIE,
12241 pSession->nWapiRspIeLength);
12242 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012243 }
12244 }
12245 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012246 return (status);
12247}
12248#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012249eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
12250{
12251 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
12252 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012253
12254 if(!pSession)
12255 {
12256 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12257 return (retStatus);
12258 }
12259
Jeff Johnson295189b2012-06-20 16:38:30 -070012260 if(CSR_IS_ROAMING(pSession))
12261 {
12262 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
12263 pSession->fRoaming = eANI_BOOLEAN_FALSE;
12264 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012265 return (retStatus);
12266}
12267
Jeff Johnson295189b2012-06-20 16:38:30 -070012268//This function remove the connected BSS from te cached scan result
12269eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
12270 tCsrRoamConnectedProfile *pConnProfile)
12271{
12272 eHalStatus status = eHAL_STATUS_FAILURE;
12273 tCsrScanResultFilter *pScanFilter = NULL;
12274 tListElem *pEntry;
12275 tCsrScanResult *pResult;
12276 tDot11fBeaconIEs *pIes;
12277 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070012278 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
12279 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
12280 {
12281 do
12282 {
12283 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
Kiet Lam64c1b492013-07-12 13:56:44 +053012284 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
12285 if ( NULL == pScanFilter )
12286 status = eHAL_STATUS_FAILURE;
12287 else
12288 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012289 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012290 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
12291 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
12292 if ( NULL == pScanFilter->BSSIDs.bssid )
12293 status = eHAL_STATUS_FAILURE;
12294 else
12295 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012296 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012297 vos_mem_copy(pScanFilter->BSSIDs.bssid, &pConnProfile->bssid,
12298 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012299 pScanFilter->BSSIDs.numOfBSSIDs = 1;
12300 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
12301 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012302 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
12303 if ( NULL == pScanFilter->SSIDs.SSIDList )
12304 status = eHAL_STATUS_FAILURE;
12305 else
12306 status = eHAL_STATUS_SUCCESS;
12307 if (!HAL_STATUS_SUCCESS(status)) break;
12308 vos_mem_copy(&pScanFilter->SSIDs.SSIDList[0].SSID,
12309 &pConnProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012310 }
12311 pScanFilter->authType.numEntries = 1;
12312 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
12313 pScanFilter->BSSType = pConnProfile->BSSType;
12314 pScanFilter->EncryptionType.numEntries = 1;
12315 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
12316 pScanFilter->mcEncryptionType.numEntries = 1;
12317 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
12318 //We ignore the channel for now, BSSID should be enough
12319 pScanFilter->ChannelInfo.numOfChannels = 0;
12320 //Also ignore the following fields
12321 pScanFilter->uapsd_mask = 0;
12322 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070012323 pScanFilter->bOSENAssociation = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012324 pScanFilter->countryCode[0] = 0;
12325 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012326 csrLLLock(&pMac->scan.scanResultList);
12327 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
12328 while( pEntry )
12329 {
12330 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
12331 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
12332 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
12333 pScanFilter, NULL, NULL, NULL, &pIes);
12334 //Release the IEs allocated by csrMatchBSS is needed
12335 if( !pResult->Result.pvIes )
12336 {
12337 //need to free the IEs since it is allocated by csrMatchBSS
Kiet Lam64c1b492013-07-12 13:56:44 +053012338 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012339 }
12340 if(fMatch)
12341 {
12342 //We found the one
12343 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
12344 {
12345 //Free the memory
12346 csrFreeScanResultEntry( pMac, pResult );
12347 }
12348 break;
12349 }
12350 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
12351 }//while
12352 csrLLUnlock(&pMac->scan.scanResultList);
12353 }while(0);
12354 if(pScanFilter)
12355 {
12356 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +053012357 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012358 }
12359 }
12360 return (status);
12361}
12362
Jeff Johnson295189b2012-06-20 16:38:30 -070012363//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070012364eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
12365{
12366 eHalStatus status = eHAL_STATUS_SUCCESS;
12367 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012368 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
12369 {
12370 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
12371 {
12372 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
12373 {
12374 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012375 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012376 status = eHAL_STATUS_CSR_WRONG_STATE;
12377 break;
12378 }
12379 if( csrIsConnStateInfra( pMac, sessionId ) )
12380 {
12381 if( chnId &&
12382 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
12383 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012384 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070012385 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
12386 status = eHAL_STATUS_CSR_WRONG_STATE;
12387 break;
12388 }
12389 }
12390 }
12391 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012392 return ( status );
12393}
12394
Jeff Johnson295189b2012-06-20 16:38:30 -070012395static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
12396{
12397 eHalStatus status = eHAL_STATUS_SUCCESS;
12398 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12399 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012400
12401 if(!pSession)
12402 {
12403 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12404 return eHAL_STATUS_FAILURE;
12405 }
12406
Jeff Johnson295189b2012-06-20 16:38:30 -070012407 if ( csrIsConnStateIbss( pMac, sessionId ) )
12408 {
12409 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
12410 }
12411 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
12412 {
12413 // Disassociate from the connected Infrastructure network...
12414 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
12415 }
12416 else
12417 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012418 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
12419 //Otherwise we need to add code to handle the
12420 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
12421 //send stop_bss to PE, before we can continue.
12422 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012423 vos_mem_set(&bssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012424 /* Assume HDD provide bssid in profile */
Kiet Lam64c1b492013-07-12 13:56:44 +053012425 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0],
12426 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012427 // there is no Bss description before we start an WDS so we need
12428 // to adopt all Bss configuration parameters from the Profile.
12429 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
12430 if(HAL_STATUS_SUCCESS(status))
12431 {
12432 //Save profile for late use
12433 csrFreeRoamProfile( pMac, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +053012434 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
12435 if (pSession->pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -070012436 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012437 vos_mem_set(pSession->pCurRoamProfile,
12438 sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012439 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
12440 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012441 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070012442 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012443 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
12444 NULL, &bssConfig,
12445 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012446 }
12447 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012448
Jeff Johnson295189b2012-06-20 16:38:30 -070012449 return( status );
12450}
12451
Jeff Johnson295189b2012-06-20 16:38:30 -070012452////////////////////Mail box
12453
Jeff Johnson295189b2012-06-20 16:38:30 -070012454//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
12455//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012456static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
12457 tSirBssDescription *pBssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -070012458 tANI_U8 *pBuf, tANI_U8 uapsdMask)
12459{
12460 tCsrChannelSet channelGroup;
12461 tSirMacCapabilityInfo *pAP_capabilityInfo;
12462 tAniBool fTmp;
12463 tANI_BOOLEAN found = FALSE;
12464 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012465 tANI_S8 pwrLimit = 0;
12466 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070012467 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
12468 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
12469 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
12470 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070012471 // 802.11h
12472 //We can do this because it is in HOST CPU order for now.
12473 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080012474 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
12475 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
12476 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012477 fTmp = (tAniBool)pal_cpu_to_be32(1);
12478 }
12479 else
12480 fTmp = (tAniBool)0;
12481
12482 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
Kiet Lam64c1b492013-07-12 13:56:44 +053012483 vos_mem_copy(pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool));
Jeff Johnson295189b2012-06-20 16:38:30 -070012484 pBuf += sizeof(tAniBool);
12485 *pBuf++ = MIN_STA_PWR_CAP_DBM; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012486 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070012487 // This is required for 11k test VoWiFi Ent: Test 2.
12488 // We need the power capabilities for Assoc Req.
12489 // This macro is provided by the halPhyCfg.h. We pick our
12490 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080012491 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
12492 if (0 != pwrLimit)
12493 {
12494 *pBuf++ = pwrLimit;
12495 }
12496 else
12497 {
12498 *pBuf++ = MAX_STA_PWR_CAP_DBM;
12499 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012500 size = sizeof(pMac->roam.validChannelList);
12501 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
12502 {
12503 *pBuf++ = (tANI_U8)size; //tSirSupChnl->numChnl
12504 for ( i = 0; i < size; i++)
12505 {
12506 *pBuf++ = pMac->roam.validChannelList[ i ]; //tSirSupChnl->channelList[ i ]
12507
12508 }
12509 }
12510 else
12511 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012512 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012513 *pBuf++ = 0; //tSirSupChnl->numChnl
12514 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012515 //Check whether it is ok to enter UAPSD
12516#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12517 if( btcIsReadyForUapsd(pMac) )
12518#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12519 {
12520 *pBuf++ = uapsdMask;
12521 }
12522#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12523 else
12524 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012525 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070012526 *pBuf++ = 0;
12527 }
12528#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12529
Jeff Johnson295189b2012-06-20 16:38:30 -070012530 // move the entire BssDescription into the join request.
Kiet Lam64c1b492013-07-12 13:56:44 +053012531 vos_mem_copy(pBuf, pBssDescription,
12532 pBssDescription->length + sizeof( pBssDescription->length ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012533 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
12534}
12535
Jeff Johnson295189b2012-06-20 16:38:30 -070012536/*
12537 * The communication between HDD and LIM is thru mailbox (MB).
12538 * Both sides will access the data structure "tSirSmeJoinReq".
12539 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
12540 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
12541 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
12542 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
12543 */
12544eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012545 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012546{
12547 eHalStatus status = eHAL_STATUS_SUCCESS;
12548 tSirSmeJoinReq *pMsg;
12549 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012550 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070012551 tANI_U16 msgLen, wTmp, ieLen;
12552 tSirMacRateSet OpRateSet;
12553 tSirMacRateSet ExRateSet;
12554 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12555 tANI_U32 dwTmp;
12556 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012557 tANI_U32 ucDot11Mode = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012558
12559 if(!pSession)
12560 {
12561 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12562 return eHAL_STATUS_FAILURE;
12563 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012564 /* To satisfy klockworks */
12565 if (NULL == pBssDescription)
12566 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012567 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012568 return eHAL_STATUS_FAILURE;
12569 }
12570
Jeff Johnson295189b2012-06-20 16:38:30 -070012571 do {
12572 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
12573 pSession->joinFailStatusCode.reasonCode = 0;
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -070012574 memcpy (&pSession->joinFailStatusCode.bssId, &pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012575 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
12576 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
12577 // IE fields, but the length field in the bssDescription needs to be interpreted to
12578 // determine length of the IE fields.
12579 //
12580 // So, take the size of the JoinReq, subtract the size of the bssDescription and
12581 // add in the length from the bssDescription (then add the size of the 'length' field
12582 // itself because that is NOT included in the length field).
12583 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
12584 pBssDescription->length + sizeof( pBssDescription->length ) +
12585 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 +053012586 pMsg = vos_mem_malloc(msgLen);
12587 if (NULL == pMsg)
12588 status = eHAL_STATUS_FAILURE;
12589 else
12590 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012591 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012592 vos_mem_set(pMsg, msgLen , 0);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012593 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012594 pMsg->length = pal_cpu_to_be16(msgLen);
12595 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012596 // sessionId
12597 *pBuf = (tANI_U8)sessionId;
12598 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012599 // transactionId
12600 *pBuf = 0;
12601 *( pBuf + 1 ) = 0;
12602 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012603 // ssId
12604 if( pIes->SSID.present && pIes->SSID.num_ssid )
12605 {
12606 // ssId len
12607 *pBuf = pIes->SSID.num_ssid;
12608 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053012609 vos_mem_copy(pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -070012610 pBuf += pIes->SSID.num_ssid;
12611 }
12612 else
12613 {
12614 *pBuf = 0;
12615 pBuf++;
12616 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012617 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053012618 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
12619 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012620 pBuf += sizeof(tSirMacAddr);
12621 // bsstype
12622 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
12623 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
Kiet Lam64c1b492013-07-12 13:56:44 +053012624 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070012625 pBuf += sizeof(tSirBssType);
12626 // dot11mode
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012627 ucDot11Mode = csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
12628 if (pBssDescription->channelId <= 14 &&
12629 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
12630 WNI_CFG_DOT11_MODE_11AC == ucDot11Mode)
12631 {
12632 //Need to disable VHT operation in 2.4 GHz band
12633 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
12634 }
12635 *pBuf = (tANI_U8)ucDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -070012636 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012637 //Persona
12638 *pBuf = (tANI_U8)pProfile->csrPersona;
12639 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070012640 //CBMode
12641 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
12642 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012643
12644 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -070012645 FL("CSR PERSONA=%d CSR CbMode %d"), pProfile->csrPersona, pSession->bssParams.cbMode);
12646
Jeff Johnson295189b2012-06-20 16:38:30 -070012647 // uapsdPerAcBitmask
12648 *pBuf = pProfile->uapsd_mask;
12649 pBuf++;
12650
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012651
12652
Jeff Johnson295189b2012-06-20 16:38:30 -070012653 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012654 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012655 {
12656 // OperationalRateSet
12657 if (OpRateSet.numRates) {
12658 *pBuf++ = OpRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012659 vos_mem_copy(pBuf, OpRateSet.rate, OpRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012660 pBuf += OpRateSet.numRates;
12661 } else *pBuf++ = 0;
12662 // ExtendedRateSet
12663 if (ExRateSet.numRates) {
12664 *pBuf++ = ExRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012665 vos_mem_copy(pBuf, ExRateSet.rate, ExRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012666 pBuf += ExRateSet.numRates;
12667 } else *pBuf++ = 0;
12668 }
12669 else
12670 {
12671 *pBuf++ = 0;
12672 *pBuf++ = 0;
12673 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012674 // rsnIE
12675 if ( csrIsProfileWpa( pProfile ) )
12676 {
12677 // Insert the Wpa IE into the join request
12678 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
12679 (tCsrWpaIe *)( wpaRsnIE ) );
12680 }
12681 else if( csrIsProfileRSN( pProfile ) )
12682 {
12683 // Insert the RSN IE into the join request
12684 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12685 (tCsrRSNIe *)( wpaRsnIE ) );
12686 }
12687#ifdef FEATURE_WLAN_WAPI
12688 else if( csrIsProfileWapi( pProfile ) )
12689 {
12690 // Insert the WAPI IE into the join request
12691 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12692 (tCsrWapiIe *)( wpaRsnIE ) );
12693 }
12694#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012695 else
12696 {
12697 ieLen = 0;
12698 }
12699 //remember the IE for future use
12700 if( ieLen )
12701 {
12702 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
12703 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012704 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 -070012705 ieLen = DOT11F_IE_RSN_MAX_LEN;
12706 }
12707#ifdef FEATURE_WLAN_WAPI
12708 if( csrIsProfileWapi( pProfile ) )
12709 {
12710 //Check whether we need to allocate more memory
12711 if(ieLen > pSession->nWapiReqIeLength)
12712 {
12713 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
12714 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012715 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012716 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012717 pSession->pWapiReqIE = vos_mem_malloc(ieLen);
12718 if (NULL == pSession->pWapiReqIE)
12719 status = eHAL_STATUS_FAILURE;
12720 else
12721 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012722 if(!HAL_STATUS_SUCCESS(status)) break;
12723 }
12724 pSession->nWapiReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012725 vos_mem_copy(pSession->pWapiReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012726 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012727 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012728 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012729 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012730 pBuf += ieLen;
12731 }
12732 else//should be WPA/WPA2 otherwise
12733#endif /* FEATURE_WLAN_WAPI */
12734 {
12735 //Check whether we need to allocate more memory
12736 if(ieLen > pSession->nWpaRsnReqIeLength)
12737 {
12738 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
12739 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012740 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012741 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012742 pSession->pWpaRsnReqIE = vos_mem_malloc(ieLen);
12743 if (NULL == pSession->pWpaRsnReqIE)
12744 status = eHAL_STATUS_FAILURE;
12745 else
12746 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012747 if(!HAL_STATUS_SUCCESS(status)) break;
12748 }
12749 pSession->nWpaRsnReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012750 vos_mem_copy(pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012751 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012752 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012753 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012754 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012755 pBuf += ieLen;
12756 }
12757 }
12758 else
12759 {
12760 //free whatever old info
12761 pSession->nWpaRsnReqIeLength = 0;
12762 if(pSession->pWpaRsnReqIE)
12763 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012764 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012765 pSession->pWpaRsnReqIE = NULL;
12766 }
12767#ifdef FEATURE_WLAN_WAPI
12768 pSession->nWapiReqIeLength = 0;
12769 if(pSession->pWapiReqIE)
12770 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012771 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012772 pSession->pWapiReqIE = NULL;
12773 }
12774#endif /* FEATURE_WLAN_WAPI */
12775 //length is two bytes
12776 *pBuf = 0;
12777 *(pBuf + 1) = 0;
12778 pBuf += 2;
12779 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012780#ifdef FEATURE_WLAN_ESE
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012781 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012782 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012783 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070012784 //length is two bytes
12785 *pBuf = 0;
12786 *(pBuf + 1) = 0;
12787 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012788 }
12789 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012790 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012791 // cckmIE
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012792 if( csrIsProfileESE( pProfile ) )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012793 {
12794 // Insert the CCKM IE into the join request
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012795#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070012796 ieLen = pSession->suppCckmIeInfo.cckmIeLen;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080012797 vos_mem_copy((void *) (wpaRsnIE),
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070012798 pSession->suppCckmIeInfo.cckmIe, ieLen);
12799#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012800 ieLen = csrConstructEseCckmIe( pMac,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012801 pSession,
12802 pProfile,
12803 pBssDescription,
12804 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070012805 pSession->nWpaRsnReqIeLength,
12806 (void *)( wpaRsnIE ) );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012807#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012808 }
12809 else
12810 {
12811 ieLen = 0;
12812 }
12813 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
12814 if( ieLen )
12815 {
12816 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
12817 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012818 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012819 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012820 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012821 pBuf += ieLen;
12822 }
12823 else
12824 {
12825 //Indicate you have no CCKM IE
12826 //length is two bytes
12827 *pBuf = 0;
12828 *(pBuf + 1) = 0;
12829 pBuf += 2;
12830 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012831 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012832#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -070012833 // addIEScan
Agarwal Ashish4f616132013-12-30 23:32:50 +053012834 if (pProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070012835 {
12836 ieLen = pProfile->nAddIEScanLength;
Agarwal Ashish4f616132013-12-30 23:32:50 +053012837 memset(pSession->addIEScan, 0 , pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070012838 pSession->nAddIEScanLength = ieLen;
Agarwal Ashish4f616132013-12-30 23:32:50 +053012839 vos_mem_copy(pSession->addIEScan, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012840 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012841 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012842 pBuf += sizeof(tANI_U16);
Agarwal Ashish4f616132013-12-30 23:32:50 +053012843 vos_mem_copy(pBuf, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012844 pBuf += ieLen;
12845 }
12846 else
12847 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053012848 memset(pSession->addIEScan, 0, pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070012849 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012850 *pBuf = 0;
12851 *(pBuf + 1) = 0;
12852 pBuf += 2;
12853 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012854 // addIEAssoc
12855 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
12856 {
12857 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070012858 if(ieLen > pSession->nAddIEAssocLength)
12859 {
12860 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
Kiet Lam64c1b492013-07-12 13:56:44 +053012861 {
12862 vos_mem_free(pSession->pAddIEAssoc);
12863 }
12864 pSession->pAddIEAssoc = vos_mem_malloc(ieLen);
12865 if (NULL == pSession->pAddIEAssoc)
12866 status = eHAL_STATUS_FAILURE;
12867 else
12868 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012869 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012870 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012871 pSession->nAddIEAssocLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012872 vos_mem_copy(pSession->pAddIEAssoc, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012873 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012874 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012875 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012876 vos_mem_copy(pBuf, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012877 pBuf += ieLen;
12878 }
12879 else
12880 {
12881 pSession->nAddIEAssocLength = 0;
12882 if(pSession->pAddIEAssoc)
12883 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012884 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070012885 pSession->pAddIEAssoc = NULL;
12886 }
12887 *pBuf = 0;
12888 *(pBuf + 1) = 0;
12889 pBuf += 2;
12890 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012891
12892 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012893 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012894 //Unmask any AC in reassoc that is ACM-set
12895 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
12896 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012897 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012898 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
12899 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012900#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012901 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012902#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012903 }
12904 else
12905 {
12906 uapsd_mask = 0;
12907 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012908 }
12909 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012910
Jeff Johnson295189b2012-06-20 16:38:30 -070012911 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012912 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012913 pBuf += sizeof(tANI_U32);
12914
Jeff Johnson295189b2012-06-20 16:38:30 -070012915 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012916 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012917 pBuf += sizeof(tANI_U32);
Chet Lanctot186b5732013-03-18 10:26:30 -070012918#ifdef WLAN_FEATURE_11W
12919 //MgmtEncryption
12920 if (pProfile->MFPEnabled)
12921 {
12922 dwTmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
12923 }
12924 else
12925 {
12926 dwTmp = pal_cpu_to_be32(eSIR_ED_NONE);
12927 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012928 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Chet Lanctot186b5732013-03-18 10:26:30 -070012929 pBuf += sizeof(tANI_U32);
12930#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012931#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012932 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053012933 if (csrIsProfile11r( pProfile )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012934#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala09dd66b2013-04-01 17:13:01 +053012935 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012936 (pIes->ESEVersion.present) && (pMac->roam.configParam.isEseIniFeatureEnabled))
Saurabh Gupta775073c2013-02-14 13:31:36 +053012937#endif
12938 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012939 {
12940 // is11Rconnection;
12941 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012942 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool)) ;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012943 pBuf += sizeof(tAniBool);
12944 }
12945 else
12946 {
12947 // is11Rconnection;
12948 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012949 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012950 pBuf += sizeof(tAniBool);
12951 }
12952#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012953#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012954
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012955 // isESEFeatureIniEnabled
12956 if (TRUE == pMac->roam.configParam.isEseIniFeatureEnabled)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012957 {
12958 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012959 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012960 pBuf += sizeof(tAniBool);
12961 }
12962 else
12963 {
12964 dwTmp = pal_cpu_to_be32(FALSE);
Srinivas Girigowda18112782013-11-27 12:21:19 -080012965 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012966 pBuf += sizeof(tAniBool);
12967 }
12968
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012969 /* A profile can not be both ESE and 11R. But an 802.11R AP
12970 * may be advertising support for ESE as well. So if we are
12971 * associating Open or explicitly ESE then we will get ESE.
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012972 * If we are associating explictly 11R only then we will get
12973 * 11R.
12974 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012975 if ((csrIsProfileESE(pProfile) ||
12976 ((pIes->ESEVersion.present)
Sandeep Puligilla798d6f22014-04-24 23:30:36 +053012977 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012978 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012979 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012980 // isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012981 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012982 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012983 pBuf += sizeof(tAniBool);
12984 }
12985 else
12986 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012987 //isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012988 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012989 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012990 pBuf += sizeof(tAniBool);
12991 }
12992
12993 if (eWNI_SME_JOIN_REQ == messageType)
12994 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012995 tESETspecInfo eseTspec;
12996 // ESE-Tspec IEs in the ASSOC request is presently not supported
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012997 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012998 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
12999 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
13000 pBuf += sizeof(tESETspecInfo);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013001 }
13002 else if (eWNI_SME_REASSOC_REQ == messageType)
13003 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013004 if ((csrIsProfileESE(pProfile) ||
13005 ((pIes->ESEVersion.present)
Sandeep Puligilla798d6f22014-04-24 23:30:36 +053013006 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013007 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070013008 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013009 tESETspecInfo eseTspec;
13010 // ESE Tspec information
13011 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13012 eseTspec.numTspecs = sme_QosESERetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &eseTspec.tspec[0]);
13013 *pBuf = eseTspec.numTspecs;
Jeff Johnson295189b2012-06-20 16:38:30 -070013014 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013015 // Copy the TSPEC information only if present
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013016 if (eseTspec.numTspecs) {
13017 vos_mem_copy(pBuf, (void*)&eseTspec.tspec[0],
13018 (eseTspec.numTspecs*sizeof(tTspecInfo)));
Jeff Johnson295189b2012-06-20 16:38:30 -070013019 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013020 pBuf += sizeof(eseTspec.tspec);
Jeff Johnson295189b2012-06-20 16:38:30 -070013021 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013022 else
Jeff Johnson295189b2012-06-20 16:38:30 -070013023 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013024 tESETspecInfo eseTspec;
13025 // ESE-Tspec IEs in the ASSOC request is presently not supported
Jeff Johnson295189b2012-06-20 16:38:30 -070013026 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013027 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13028 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
13029 pBuf += sizeof(tESETspecInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070013030 }
13031 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013032#endif // FEATURE_WLAN_ESE
13033#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070013034 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013035 if (pMac->roam.configParam.isFastTransitionEnabled
13036#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053013037 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013038#endif
13039 )
Jeff Johnson295189b2012-06-20 16:38:30 -070013040 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013041 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013042 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013043 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070013044 }
13045 else
13046 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013047 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013048 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013049 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070013050 }
13051#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070013052#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053013053 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070013054 {
13055 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013056 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013057 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013058 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070013059 }
13060 else
13061 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013062 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013063 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013064 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070013065 }
13066#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013067
13068 // txLdpcIniFeatureEnabled
13069 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
13070 pBuf++;
13071
Kiran4a17ebe2013-01-31 10:43:43 -080013072 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
13073 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
13074 {
13075 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
13076 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
13077 csrApplyPower2Current(pMac);
13078 }
13079
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080013080#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080013081 // txBFIniFeatureEnabled
13082 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
13083 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080013084
13085 // txBFCsnValue
13086 *pBuf = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
13087 pBuf++;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080013088#endif
krunal soni5afa96c2013-09-06 22:19:02 -070013089 *pBuf = (tANI_U8)pMac->roam.configParam.isAmsduSupportInAMPDU;
13090 pBuf++;
13091
Sandeep Puligillaaea98a22013-12-04 13:36:32 +053013092 // WME
13093 if(pMac->roam.roamSession[sessionId].fWMMConnection)
13094 {
13095 //WME enabled
13096 dwTmp = pal_cpu_to_be32(TRUE);
13097 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13098 pBuf += sizeof(tAniBool);
13099 }
13100 else
13101 {
13102 dwTmp = pal_cpu_to_be32(FALSE);
13103 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13104 pBuf += sizeof(tAniBool);
13105 }
13106
13107 // QOS
13108 if(pMac->roam.roamSession[sessionId].fQOSConnection)
13109 {
13110 //QOS enabled
13111 dwTmp = pal_cpu_to_be32(TRUE);
13112 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13113 pBuf += sizeof(tAniBool);
13114 }
13115 else
13116 {
13117 dwTmp = pal_cpu_to_be32(FALSE);
13118 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13119 pBuf += sizeof(tAniBool);
13120 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013121 //BssDesc
13122 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
13123 (tANI_U8)pProfile->uapsd_mask);
krunal soni5afa96c2013-09-06 22:19:02 -070013124
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013125 status = palSendMBMessage(pMac->hHdd, pMsg );
13126 if(!HAL_STATUS_SUCCESS(status))
13127 {
13128 break;
13129 }
13130 else
13131 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013132#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013133 if (eWNI_SME_JOIN_REQ == messageType)
13134 {
13135 //Tush-QoS: notify QoS module that join happening
13136 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
13137 }
13138 else if (eWNI_SME_REASSOC_REQ == messageType)
13139 {
13140 //Tush-QoS: notify QoS module that reassoc happening
13141 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
13142 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013143#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013144 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013145 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013146 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013147}
13148
Jeff Johnson295189b2012-06-20 16:38:30 -070013149//
13150eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13151{
13152 eHalStatus status = eHAL_STATUS_SUCCESS;
13153 tSirSmeDisassocReq *pMsg;
13154 tANI_U8 *pBuf;
13155 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013156 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13157 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13158 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013159 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013160 pMsg = vos_mem_malloc(sizeof(tSirSmeDisassocReq));
13161 if (NULL == pMsg)
13162 status = eHAL_STATUS_FAILURE;
13163 else
13164 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013165 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013166 vos_mem_set(pMsg, sizeof( tSirSmeDisassocReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013167 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
13168 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013169 pBuf = &pMsg->sessionId;
13170 // sessionId
13171 *pBuf++ = (tANI_U8)sessionId;
13172 // transactionId
13173 *pBuf = 0;
13174 *( pBuf + 1 ) = 0;
13175 pBuf += sizeof(tANI_U16);
13176
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053013177 if ( (pSession->pCurRoamProfile != NULL) &&
13178 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
13179 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013180 {
13181 // Set the bssid address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013182 vos_mem_copy((tSirMacAddr *)pBuf, pSession->selfMacAddr,
13183 sizeof( tSirMacAddr ));
13184 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013185 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070013186 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013187 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
13188 //perMacAddr is passed as bssId for softAP
13189 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013190 pBuf = pBuf + sizeof ( tSirMacAddr );
13191 }
13192 else
13193 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013194 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013195 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
13196 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013197 pBuf = pBuf + sizeof ( tSirMacAddr );
Kiet Lam64c1b492013-07-12 13:56:44 +053013198 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ));
13199 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013200 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070013201 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013202 if(!HAL_STATUS_SUCCESS(status))
13203 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013204 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013205 break;
13206 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013207 // reasonCode
13208 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013209 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
13210 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013211 if(!HAL_STATUS_SUCCESS(status))
13212 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013213 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013214 break;
13215 }
13216 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013217 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
13218 Here we should not send the disassoc over the air to the AP */
13219 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
13220#ifdef WLAN_FEATURE_VOWIFI_11R
13221 && csrRoamIs11rAssoc(pMac)
13222#endif
13223 )
13224 {
13225 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
13226 }
13227 pBuf += sizeof(tANI_U8);
13228 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013229 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013230 return( status );
13231}
Jeff Johnson295189b2012-06-20 16:38:30 -070013232eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
13233{
13234 eHalStatus status = eHAL_STATUS_SUCCESS;
13235 tSirSmeTkipCntrMeasReq *pMsg;
13236 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013237 do
13238 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013239 pMsg = vos_mem_malloc(sizeof( tSirSmeTkipCntrMeasReq ));
13240 if ( NULL == pMsg )
13241 status = eHAL_STATUS_FAILURE;
13242 else
13243 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013244 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013245 vos_mem_set(pMsg, sizeof( tSirSmeTkipCntrMeasReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013246 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
13247 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013248 pBuf = &pMsg->sessionId;
13249 // sessionId
13250 *pBuf++ = (tANI_U8)sessionId;
13251 // transactionId
13252 *pBuf = 0;
13253 *( pBuf + 1 ) = 0;
13254 pBuf += sizeof(tANI_U16);
13255 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053013256 vos_mem_copy(pMsg->bssId, bssId, sizeof( tSirMacAddr ));
13257 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013258 pBuf = pBuf + sizeof ( tSirMacAddr );
13259 // bEnable
13260 *pBuf = (tANI_BOOLEAN)bEnable;
13261 if(!HAL_STATUS_SUCCESS(status))
13262 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013263 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013264 break;
13265 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013266 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013267 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013268 return( status );
13269}
Jeff Johnson295189b2012-06-20 16:38:30 -070013270eHalStatus
13271csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
13272 VOS_MODULE_ID modId, tSirMacAddr bssId,
13273 void *pUsrContext, void *pfnSapEventCallback,
13274 tANI_U8 *pAssocStasBuf )
13275{
13276 eHalStatus status = eHAL_STATUS_SUCCESS;
13277 tSirSmeGetAssocSTAsReq *pMsg;
13278 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
13279 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013280 do
13281 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013282 pMsg = vos_mem_malloc(sizeof( tSirSmeGetAssocSTAsReq ));
13283 if ( NULL == pMsg )
13284 status = eHAL_STATUS_FAILURE;
13285 else
13286 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013287 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013288 vos_mem_set(pMsg, sizeof( tSirSmeGetAssocSTAsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013289 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013290 pBuf = (tANI_U8 *)&pMsg->bssId;
13291 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013292 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013293 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013294 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013295 // modId
13296 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013297 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013298 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013299 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080013300 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void *));
13301 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013302 // pfnSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080013303 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void*));
13304 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013305 // pAssocStasBuf
krunal soni4f802b22014-02-11 17:01:13 -080013306 vos_mem_copy(pBuf, pAssocStasBuf, sizeof(void*));
13307 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013308 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013309 status = palSendMBMessage( pMac->hHdd, pMsg );
13310 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013311 return( status );
13312 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013313eHalStatus
13314csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
13315 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
13316 {
13317 eHalStatus status = eHAL_STATUS_SUCCESS;
13318 tSirSmeGetWPSPBCSessionsReq *pMsg;
13319 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
krunal soni4f802b22014-02-11 17:01:13 -080013320
Jeff Johnson295189b2012-06-20 16:38:30 -070013321 do
13322 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013323 pMsg = vos_mem_malloc(sizeof(tSirSmeGetWPSPBCSessionsReq));
13324 if ( NULL == pMsg )
13325 status = eHAL_STATUS_FAILURE;
13326 else
13327 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013328 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013329 vos_mem_set(pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013330 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013331 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
lukez3c809222013-05-03 10:23:02 -070013332 VOS_ASSERT(pBuf);
13333
Jeff Johnson295189b2012-06-20 16:38:30 -070013334 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013335 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080013336 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void*));
13337 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070013338 // pSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080013339 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void *));
13340 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070013341 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013342 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013343 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013344 // MAC Address of STA in WPS session
Kiet Lam64c1b492013-07-12 13:56:44 +053013345 vos_mem_copy((tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
Jeff Johnson295189b2012-06-20 16:38:30 -070013346 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070013347 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013348 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013349 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013350 return( status );
13351}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013352
13353eHalStatus
13354csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
13355{
13356 tpSirChangeBIParams pMsg;
13357 tANI_U16 len = 0;
13358 eHalStatus status = eHAL_STATUS_SUCCESS;
13359 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13360
13361 if(!pSession)
13362 {
13363 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13364 return eHAL_STATUS_FAILURE;
13365 }
13366
13367 //NO need to update the Beacon Params if update beacon parameter flag is not set
13368 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
13369 return eHAL_STATUS_SUCCESS;
13370
13371 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
13372
13373 /* Create the message and send to lim */
13374 len = sizeof(tSirChangeBIParams);
Kiet Lam64c1b492013-07-12 13:56:44 +053013375 pMsg = vos_mem_malloc(len);
13376 if ( NULL == pMsg )
13377 status = eHAL_STATUS_FAILURE;
13378 else
13379 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013380 if(HAL_STATUS_SUCCESS(status))
13381 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013382 vos_mem_set(pMsg, sizeof(tSirChangeBIParams), 0);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013383 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
13384 pMsg->length = len;
13385
13386 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013387 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
13388 sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -080013389 smsLog( pMac, LOG1, FL("CSR Attempting to change BI for Bssid= "MAC_ADDRESS_STR),
13390 MAC_ADDR_ARRAY(pMsg->bssId));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013391 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013392 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013393 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
13394 status = palSendMBMessage(pMac->hHdd, pMsg);
13395 }
13396 return status;
13397}
13398
Jeff Johnson295189b2012-06-20 16:38:30 -070013399eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13400{
13401 eHalStatus status = eHAL_STATUS_SUCCESS;
13402 tSirSmeDeauthReq *pMsg;
13403 tANI_U8 *pBuf;
13404 tANI_U16 wTmp;
13405 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13406 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13407 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013408 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013409 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthReq ));
13410 if ( NULL == pMsg )
13411 status = eHAL_STATUS_FAILURE;
13412 else
13413 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013414 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013415 vos_mem_set(pMsg, sizeof( tSirSmeDeauthReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013416 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
13417 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
13418 //sessionId
13419 pBuf = &pMsg->sessionId;
13420 *pBuf++ = (tANI_U8)sessionId;
13421
13422 //tansactionId
13423 *pBuf = 0;
13424 *(pBuf + 1 ) = 0;
13425 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013426 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070013427 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070013428 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
13429 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013430 vos_mem_copy( (tSirMacAddr *)pBuf, pSession->selfMacAddr,
13431 sizeof( pMsg->peerMacAddr ) );
13432 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013433 pBuf = pBuf + sizeof(tSirMacAddr);
13434 }
13435 else
13436 {
13437 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013438 vos_mem_copy( (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13439 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013440 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013441 }
13442 if(!HAL_STATUS_SUCCESS(status))
13443 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013444 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013445 break;
13446 }
13447 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013448 vos_mem_copy( (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13449 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013450 pBuf = pBuf + sizeof(tSirMacAddr);
13451 if(!HAL_STATUS_SUCCESS(status))
13452 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013453 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013454 break;
13455 }
13456 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013457 vos_mem_copy( pBuf, &wTmp,sizeof( tANI_U16 ) );
13458 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013459 if(!HAL_STATUS_SUCCESS(status))
13460 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013461 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013462 break;
13463 }
13464 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013465 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013466 return( status );
13467}
13468
Jeff Johnson295189b2012-06-20 16:38:30 -070013469eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
13470{
13471 eHalStatus status = eHAL_STATUS_SUCCESS;
13472 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013473 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013474 pMsg = vos_mem_malloc(sizeof( tSirSmeDisassocCnf ));
13475 if ( NULL == pMsg )
13476 status = eHAL_STATUS_FAILURE;
13477 else
13478 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013479 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013480 vos_mem_set(pMsg, sizeof( tSirSmeDisassocCnf), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013481 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
13482 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13483 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013484 vos_mem_copy(pMsg->peerMacAddr, pDisassocInd->peerMacAddr,
13485 sizeof(pMsg->peerMacAddr));
13486 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013487 if(!HAL_STATUS_SUCCESS(status))
13488 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013489 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013490 break;
13491 }
13492//To test reconn
Kiet Lam64c1b492013-07-12 13:56:44 +053013493 vos_mem_copy(pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
13494 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013495 if(!HAL_STATUS_SUCCESS(status))
13496 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013497 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013498 break;
13499 }
13500//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070013501 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013502 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013503 return( status );
13504}
13505
Jeff Johnson295189b2012-06-20 16:38:30 -070013506eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
13507{
13508 eHalStatus status = eHAL_STATUS_SUCCESS;
13509 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013510 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013511 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthCnf ));
13512 if ( NULL == pMsg )
13513 status = eHAL_STATUS_FAILURE;
13514 else
13515 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013516 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013517 vos_mem_set(pMsg, sizeof( tSirSmeDeauthCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013518 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
13519 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13520 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013521 vos_mem_copy(pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
13522 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013523 if(!HAL_STATUS_SUCCESS(status))
13524 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013525 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013526 break;
13527 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013528 vos_mem_copy(pMsg->peerMacAddr, pDeauthInd->peerMacAddr,
13529 sizeof(pMsg->peerMacAddr));
13530 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013531 if(!HAL_STATUS_SUCCESS(status))
13532 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013533 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013534 break;
13535 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013536 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013537 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013538 return( status );
13539}
Jeff Johnson295189b2012-06-20 16:38:30 -070013540eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
13541{
13542 eHalStatus status = eHAL_STATUS_SUCCESS;
13543 tSirSmeAssocCnf *pMsg;
13544 tANI_U8 *pBuf;
13545 tSirResultCodes statusCode;
13546 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013547 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013548 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocCnf ));
13549 if ( NULL == pMsg )
13550 status = eHAL_STATUS_FAILURE;
13551 else
13552 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013553 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013554 vos_mem_set(pMsg, sizeof( tSirSmeAssocCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013555 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
13556 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013557 pBuf = (tANI_U8 *)&pMsg->statusCode;
13558 if(HAL_STATUS_SUCCESS(Halstatus))
13559 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13560 else
13561 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053013562 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes));
Jeff Johnson295189b2012-06-20 16:38:30 -070013563 pBuf += sizeof(tSirResultCodes);
13564 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013565 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13566 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013567 pBuf += sizeof (tSirMacAddr);
13568 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013569 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13570 sizeof(tSirMacAddr));
13571 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013572 pBuf += sizeof (tSirMacAddr);
13573 // aid
13574 wTmp = pal_cpu_to_be16(pAssocInd->aid);
Kiet Lam64c1b492013-07-12 13:56:44 +053013575 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013576 pBuf += sizeof (tANI_U16);
13577 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013578 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13579 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013580 pBuf += sizeof (tSirMacAddr);
13581 // alternateChannelId
13582 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070013583 status = palSendMBMessage( pMac->hHdd, pMsg );
13584 if(!HAL_STATUS_SUCCESS(status))
13585 {
13586 //pMsg is freed by palSendMBMessage
13587 break;
13588 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013589 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013590 return( status );
13591}
Jeff Johnson295189b2012-06-20 16:38:30 -070013592eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
13593 tpSirSmeAssocInd pAssocInd,
13594 eHalStatus Halstatus,
13595 tANI_U8 sessionId)
13596{
13597 tSirMsgQ msgQ;
Jeff Johnson295189b2012-06-20 16:38:30 -070013598 tSirSmeAssocIndToUpperLayerCnf *pMsg;
13599 tANI_U8 *pBuf;
13600 tSirResultCodes statusCode;
13601 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013602 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013603 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocIndToUpperLayerCnf ));
13604 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13605 vos_mem_set(pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ), 0);
Jeff Johnsone7245742012-09-05 17:12:55 -070013606
Jeff Johnson295189b2012-06-20 16:38:30 -070013607 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
13608 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
13609
13610 pMsg->sessionId = sessionId;
13611
13612 pBuf = (tANI_U8 *)&pMsg->statusCode;
13613 if(HAL_STATUS_SUCCESS(Halstatus))
13614 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13615 else
13616 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053013617 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes)) ;
Jeff Johnson295189b2012-06-20 16:38:30 -070013618 pBuf += sizeof(tSirResultCodes);
13619 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013620 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013621 pBuf += sizeof (tSirMacAddr);
13622 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013623 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13624 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013625 pBuf += sizeof (tSirMacAddr);
13626 // StaId
13627 wTmp = pal_cpu_to_be16(pAssocInd->staId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013628 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013629 pBuf += sizeof (tANI_U16);
13630 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013631 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013632 pBuf += sizeof (tSirMacAddr);
13633 // alternateChannelId
13634 *pBuf = 11;
13635 pBuf += sizeof (tANI_U8);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013636 // Instead of copying roam Info, we just copy only WmmEnabled, RsnIE information
Jeff Johnson295189b2012-06-20 16:38:30 -070013637 //Wmm
13638 *pBuf = pAssocInd->wmmEnabledSta;
13639 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013640 //RSN IE
Kiet Lam64c1b492013-07-12 13:56:44 +053013641 vos_mem_copy((tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070013642 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070013643 //Additional IE
Kiet Lam64c1b492013-07-12 13:56:44 +053013644 vos_mem_copy((void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
Jeff Johnson295189b2012-06-20 16:38:30 -070013645 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070013646 //reassocReq
13647 *pBuf = pAssocInd->reassocReq;
13648 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013649 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
13650 msgQ.bodyptr = pMsg;
13651 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013652 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013653 } while( 0 );
Kiet Lam64c1b492013-07-12 13:56:44 +053013654 return( eHAL_STATUS_SUCCESS );
Jeff Johnson295189b2012-06-20 16:38:30 -070013655}
Jeff Johnson295189b2012-06-20 16:38:30 -070013656
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013657eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -070013658 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
13659 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
13660 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
13661 tANI_U8 *pKeyRsc )
13662{
13663 tSirSmeSetContextReq *pMsg;
13664 tANI_U16 msgLen;
13665 eHalStatus status = eHAL_STATUS_FAILURE;
13666 tAniEdType tmpEdType;
13667 tAniKeyDirection tmpDirection;
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +053013668 tANI_U8 *pBuf = NULL;
13669 tANI_U8 *p = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013670 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013671 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070013672 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013673 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
13674 // key set. Since we only support upto one key, we always allocate memory for 1 key
13675 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
13676 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
13677 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
13678 ( sizeof( pMsg->keyMaterial.key ) );
13679
Kiet Lam64c1b492013-07-12 13:56:44 +053013680 pMsg = vos_mem_malloc(msgLen);
13681 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13682 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013683 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
13684 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013685 //sessionId
13686 pBuf = &pMsg->sessionId;
13687 *pBuf = (tANI_U8)sessionId;
13688 pBuf++;
13689 // transactionId
13690 *pBuf = 0;
13691 *(pBuf + 1) = 0;
13692 pBuf += sizeof(tANI_U16);
13693 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013694 vos_mem_copy(pBuf, (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013695
13696 pBuf += sizeof(tSirMacAddr);
13697
13698 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013699 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
13700 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013701
13702 pBuf += sizeof(tSirMacAddr);
13703
13704 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013705 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
13706 // in the tSirKeyMaterial keyMaterial; field).
13707 //
13708 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
13709 // shorter than this max size. Is LIM interpreting this ok ?
13710 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 -070013711 // set pMsg->keyMaterial.edType
13712 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013713 vos_mem_copy(p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013714 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070013715 // set the pMsg->keyMaterial.numKeys field
13716 *p = numKeys;
13717 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070013718 // set pSirKey->keyId = keyId;
13719 *p = keyId;
13720 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013721 // set pSirKey->unicast = (tANI_U8)fUnicast;
13722 *p = (tANI_U8)fUnicast;
13723 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070013724 // set pSirKey->keyDirection = aniKeyDirection;
13725 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
Kiet Lam64c1b492013-07-12 13:56:44 +053013726 vos_mem_copy(p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection));
Jeff Johnson295189b2012-06-20 16:38:30 -070013727 p += sizeof(tAniKeyDirection);
13728 // pSirKey->keyRsc = ;;
Kiet Lam64c1b492013-07-12 13:56:44 +053013729 vos_mem_copy(p, pKeyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -070013730 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070013731 // set pSirKey->paeRole
13732 *p = paeRole; // 0 is Supplicant
13733 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013734 // set pSirKey->keyLength = keyLength;
13735 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013736 if ( keyLength && pKey )
13737 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013738 vos_mem_copy(p, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013739 if(keyLength == 16)
13740 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013741 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 -070013742 keyId, edType, pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
13743 pKey[5], pKey[6], pKey[7], pKey[8],
13744 pKey[9], pKey[10], pKey[11], pKey[12], pKey[13], pKey[14], pKey[15]);
13745 }
13746 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013747 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013748 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013749 return( status );
13750}
13751
Jeff Johnson295189b2012-06-20 16:38:30 -070013752eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
13753 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
13754{
13755 eHalStatus status;
13756 tSirSmeStartBssReq *pMsg;
13757 tANI_U8 *pBuf = NULL;
13758 tANI_U8 *wTmpBuf = NULL;
13759 tANI_U16 msgLen, wTmp;
13760 tANI_U32 dwTmp;
13761 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070013762 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070013763 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070013764 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013765
13766 if(!pSession)
13767 {
13768 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13769 return eHAL_STATUS_FAILURE;
13770 }
13771
Jeff Johnson295189b2012-06-20 16:38:30 -070013772 do {
13773 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
13774 pSession->joinFailStatusCode.reasonCode = 0;
13775 msgLen = sizeof(tSirSmeStartBssReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053013776 pMsg = vos_mem_malloc(msgLen);
13777 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13778 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013779 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013780 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013781 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013782 //sessionId
13783 *pBuf = (tANI_U8)sessionId;
13784 pBuf++;
13785 // transactionId
13786 *pBuf = 0;
13787 *(pBuf + 1) = 0;
13788 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013789 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053013790 vos_mem_copy(pBuf, pParam->bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013791 pBuf += sizeof(tSirMacAddr);
13792 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013793 vos_mem_copy(pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013794 pBuf += sizeof(tSirMacAddr);
13795 // beaconInterval
13796 if( pBssDesc && pBssDesc->beaconInterval )
13797 {
13798 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
13799 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013800 else if(pParam->beaconInterval)
13801 {
13802 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
13803 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013804 else
13805 {
13806 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
13807 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -070013808 if(csrIsconcurrentsessionValid (pMac, sessionId,
13809 pParam->bssPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -070013810 == eHAL_STATUS_SUCCESS )
13811 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013812 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070013813 pParam->bssPersona);
13814 //Update the beacon Interval
13815 pParam->beaconInterval = wTmp;
13816 }
13817 else
13818 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013819 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070013820 status = eHAL_STATUS_FAILURE;
Kiet Lam64c1b492013-07-12 13:56:44 +053013821 vos_mem_free(pMsg);
Jeff Johnsone7245742012-09-05 17:12:55 -070013822 return status;
13823 }
13824
Kiet Lam64c1b492013-07-12 13:56:44 +053013825 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013826 pBuf += sizeof(tANI_U16);
13827 // dot11mode
13828 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
13829 pBuf += 1;
13830 // bssType
13831 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013832 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013833 pBuf += sizeof(tSirBssType);
13834 // ssId
13835 if( pParam->ssId.length )
13836 {
13837 // ssId len
13838 *pBuf = pParam->ssId.length;
13839 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053013840 vos_mem_copy(pBuf, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070013841 pBuf += pParam->ssId.length;
13842 }
13843 else
13844 {
13845 *pBuf = 0;
13846 pBuf++;
13847 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013848 // set the channel Id
13849 *pBuf = pParam->operationChn;
13850 pBuf++;
13851 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070013852 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013853 vos_mem_copy(pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState));
Jeff Johnsone7245742012-09-05 17:12:55 -070013854 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070013855
Jeff Johnson295189b2012-06-20 16:38:30 -070013856 // Set privacy
13857 *pBuf = pParam->privacy;
13858 pBuf++;
13859
13860 //Set Uapsd
13861 *pBuf = pParam->ApUapsdEnable;
13862 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013863 //Set SSID hidden
13864 *pBuf = pParam->ssidHidden;
13865 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013866 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
13867 pBuf++;
13868
13869 //Ht protection Enable/Disable
13870 *pBuf = (tANI_U8)pParam->protEnabled;
13871 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013872 //Enable Beacons to Receive for OBSS protection Enable/Disable
13873 *pBuf = (tANI_U8)pParam->obssProtEnabled;
13874 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013875 //set cfg related to protection
13876 wTmp = pal_cpu_to_be16( pParam->ht_protection );
Kiet Lam64c1b492013-07-12 13:56:44 +053013877 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013878 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013879 // Set Auth type
13880 authType = pal_cpu_to_be32(pParam->authType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013881 vos_mem_copy(pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013882 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013883 // Set DTIM
13884 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
Kiet Lam64c1b492013-07-12 13:56:44 +053013885 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013886 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013887 // Set wps_state
13888 *pBuf = pParam->wps_state;
13889 pBuf++;
krunal sonie9002db2013-11-25 14:24:17 -080013890 // set isCoalesingInIBSSAllowed
13891 *pBuf = pMac->isCoalesingInIBSSAllowed;
13892 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013893 //Persona
13894 *pBuf = (tANI_U8)pParam->bssPersona;
13895 pBuf++;
13896
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080013897 //txLdpcIniFeatureEnabled
13898 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
13899 pBuf++;
krunal soni4f087d22013-07-29 16:32:26 -070013900
Chet Lanctot8cecea22014-02-11 19:09:36 -080013901#ifdef WLAN_FEATURE_11W
13902 // Set MFP capable/required
13903 *pBuf = (tANI_U8)pParam->mfpCapable;
13904 pBuf++;
13905 *pBuf = (tANI_U8)pParam->mfpRequired;
13906 pBuf++;
13907#endif
13908
krunal soni4f087d22013-07-29 16:32:26 -070013909 // set RSN IE
Jeff Johnson295189b2012-06-20 16:38:30 -070013910 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
13911 {
13912 status = eHAL_STATUS_INVALID_PARAMETER;
Kiet Lam64c1b492013-07-12 13:56:44 +053013913 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013914 break;
13915 }
13916 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
Kiet Lam64c1b492013-07-12 13:56:44 +053013917 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013918 pBuf += sizeof(tANI_U16);
13919 if( wTmp )
13920 {
13921 wTmp = pParam->nRSNIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +053013922 vos_mem_copy(pBuf, pParam->pRSNIE, wTmp);
Jeff Johnson295189b2012-06-20 16:38:30 -070013923 pBuf += wTmp;
13924 }
13925 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013926 vos_mem_copy(pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013927 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070013928 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
13929 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053013930 vos_mem_copy(pBuf, pParam->operationalRateSet.rate,
13931 pParam->operationalRateSet.numRates );
Jeff Johnson295189b2012-06-20 16:38:30 -070013932 pBuf += pParam->operationalRateSet.numRates ;
13933 *pBuf++ = pParam->extendedRateSet.numRates;
13934 if(0 != pParam->extendedRateSet.numRates)
13935 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013936 vos_mem_copy(pBuf, pParam->extendedRateSet.rate,
13937 pParam->extendedRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070013938 pBuf += pParam->extendedRateSet.numRates;
13939 }
krunal sonie9002db2013-11-25 14:24:17 -080013940
Jeff Johnson295189b2012-06-20 16:38:30 -070013941 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
13942 pMsg->length = pal_cpu_to_be16(msgLen);
13943
13944 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013945 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013946 return( status );
13947}
13948
Jeff Johnson295189b2012-06-20 16:38:30 -070013949eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
13950{
13951 eHalStatus status = eHAL_STATUS_FAILURE;
13952 tSirSmeStopBssReq *pMsg;
13953 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13954 tANI_U8 *pBuf;
13955 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013956
13957 if(!pSession)
13958 {
13959 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13960 return eHAL_STATUS_FAILURE;
13961 }
13962
Jeff Johnson295189b2012-06-20 16:38:30 -070013963 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013964 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
13965 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13966 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013967 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13968 pBuf = &pMsg->sessionId;
13969 //sessionId
13970 *pBuf = (tANI_U8)sessionId;
13971 pBuf++;
13972 // transactionId
13973 *pBuf = 0;
13974 pBuf += sizeof(tANI_U16);
13975 //reason code
13976 *pBuf = 0;
13977 pBuf += sizeof(tSirResultCodes);
13978 // bssid
13979 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
13980 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
13981 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013982 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->selfMacAddr,
13983 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013984 }
13985 else
13986 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013987 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
13988 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013989 }
13990 pBuf += sizeof(tSirMacAddr);
13991 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
13992 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013993 status = palSendMBMessage( pMac->hHdd, pMsg );
13994#if 0
Kiet Lam64c1b492013-07-12 13:56:44 +053013995 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
13996 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13997 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013998 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13999 pMsg->reasonCode = 0;
14000 // bssid
14001 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
14002 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
14003 {
14004 pbBssid = (tANI_U8 *)&pSession->selfMacAddr;
14005 }
14006 else
14007 {
14008 pbBssid = (tANI_U8 *)&pSession->connectedProfile.bssid;
14009 }
Kiet Lam64c1b492013-07-12 13:56:44 +053014010 vos_mem_copy(&pMsg->bssId, pbBssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014011 pMsg->transactionId = 0;
14012 pMsg->sessionId = (tANI_U8)sessionId;
14013 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeStopBssReq ));
14014 status = palSendMBMessage( pMac->hHdd, pMsg );
14015#endif
14016 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014017 return( status );
14018}
14019
Jeff Johnson295189b2012-06-20 16:38:30 -070014020eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
14021 tCsrRoamModifyProfileFields *pModProfileFields,
14022 tANI_U32 *pRoamId, v_BOOL_t fForce)
14023{
Jeff Johnson295189b2012-06-20 16:38:30 -070014024 eHalStatus status = eHAL_STATUS_FAILURE;
14025 tANI_U32 roamId = 0;
14026 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014027 if((csrIsConnStateConnected(pMac, sessionId)) &&
Kiet Lam64c1b492013-07-12 13:56:44 +053014028 (fForce || (!vos_mem_compare( &pModProfileFields,
14029 &pSession->connectedProfile.modifyProfileFields,
14030 sizeof(tCsrRoamModifyProfileFields)))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070014031 {
14032 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
14033 if(pRoamId)
14034 {
14035 *pRoamId = roamId;
14036 }
14037
Jeff Johnson295189b2012-06-20 16:38:30 -070014038 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
14039 eCsrSmeIssuedReassocToSameAP, roamId,
14040 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014041 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014042 return status;
14043}
Jeff Johnson295189b2012-06-20 16:38:30 -070014044static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
14045{
14046 eHalStatus status = eHAL_STATUS_SUCCESS;
14047 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +053014048 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014049 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
14050 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
14051 return (status);
14052}
Jeff Johnson295189b2012-06-20 16:38:30 -070014053eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
14054{
14055 eHalStatus status = eHAL_STATUS_SUCCESS;
14056 tListElem *pEntry = NULL;
14057 tSmeCmd *pCommand = NULL;
14058 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014059 do
14060 {
14061 if(pMsg == NULL)
14062 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014063 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014064 status = eHAL_STATUS_FAILURE;
14065 break;
14066 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014067 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
14068 if(pEntry)
14069 {
14070 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14071 if(eSmeCommandAddStaSession == pCommand->command)
14072 {
14073 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014074 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014075 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070014076 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014077 //Remove this command out of the active list
14078 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
14079 {
14080 //Now put this command back on the avilable command list
14081 csrReleaseCommand(pMac, pCommand);
14082 }
14083 smeProcessPendingQueue( pMac );
14084 }
14085 else
14086 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014087 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 -070014088 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014089 status = eHAL_STATUS_FAILURE;
14090 break;
14091 }
14092 }
14093 else
14094 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014095 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 -070014096 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014097 status = eHAL_STATUS_FAILURE;
14098 break;
14099 }
14100 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014101 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014102}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014103eHalStatus csrSendMBAddSelfStaReqMsg(tpAniSirGlobal pMac,
14104 tAddStaForSessionCmd *pAddStaReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070014105{
14106 tSirSmeAddStaSelfReq *pMsg;
14107 tANI_U16 msgLen;
14108 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014109 do {
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014110 msgLen = sizeof(tSirSmeAddStaSelfReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053014111 pMsg = vos_mem_malloc(msgLen);
14112 if ( NULL == pMsg ) break;
14113 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014114 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
14115 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014116 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053014117 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr,
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014118 (tANI_U8 *)&pAddStaReq->selfMacAddr, sizeof(tSirMacAddr));
14119
14120 pMsg->currDeviceMode = pAddStaReq->currDeviceMode;
14121
Arif Hussain24bafea2013-11-15 15:10:03 -080014122 smsLog( pMac, LOG1, FL("selfMac="MAC_ADDRESS_STR),
14123 MAC_ADDR_ARRAY(pMsg->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014124 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014125 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014126 return( status );
14127}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014128eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac,
14129 tANI_U32 sessionId,
14130 tSirMacAddr sessionMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -070014131{
14132 eHalStatus status = eHAL_STATUS_SUCCESS;
14133 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014134 pCommand = csrGetCommandBuffer(pMac);
14135 if(NULL == pCommand)
14136 {
14137 status = eHAL_STATUS_RESOURCES;
14138 }
14139 else
14140 {
14141 pCommand->command = eSmeCommandAddStaSession;
14142 pCommand->sessionId = (tANI_U8)sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053014143 vos_mem_copy(pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr,
14144 sizeof( tSirMacAddr ) );
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014145 pCommand->u.addStaSessionCmd.currDeviceMode = pMac->sme.currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070014146 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
14147 if( !HAL_STATUS_SUCCESS( status ) )
14148 {
14149 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014150 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014151 }
14152 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014153 return (status);
14154}
Jeff Johnson295189b2012-06-20 16:38:30 -070014155eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14156{
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014157 return csrSendMBAddSelfStaReqMsg(pMac, &pCommand->u.addStaSessionCmd);
Jeff Johnson295189b2012-06-20 16:38:30 -070014158}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014159eHalStatus csrRoamOpenSession(tpAniSirGlobal pMac,
14160 csrRoamCompleteCallback callback,
14161 void *pContext, tANI_U8 *pSelfMacAddr,
14162 tANI_U8 *pbSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -070014163{
14164 eHalStatus status = eHAL_STATUS_SUCCESS;
14165 tANI_U32 i;
14166 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070014167 *pbSessionId = CSR_SESSION_ID_INVALID;
14168 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14169 {
14170 if( !CSR_IS_SESSION_VALID( pMac, i ) )
14171 {
14172 pSession = CSR_GET_SESSION( pMac, i );
14173 status = eHAL_STATUS_SUCCESS;
14174 pSession->sessionActive = eANI_BOOLEAN_TRUE;
14175 pSession->sessionId = (tANI_U8)i;
14176 pSession->callback = callback;
14177 pSession->pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053014178 vos_mem_copy(&pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070014179 *pbSessionId = (tANI_U8)i;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014180 status = vos_timer_init(&pSession->hTimerRoaming, VOS_TIMER_TYPE_SW,
14181 csrRoamRoamingTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070014182 &pSession->roamingTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014183 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014184 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014185 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014186 break;
14187 }
14188#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014189 status = vos_timer_init(&pSession->hTimerJoinRetry, VOS_TIMER_TYPE_SW,
14190 csrRoamJoinRetryTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070014191 &pSession->joinRetryTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014192 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014193 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014194 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014195 break;
14196 }
14197#endif
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014198 status = csrIssueAddStaForSessionReq (pMac, i, pSelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014199 break;
14200 }
14201 }
14202 if( CSR_ROAM_SESSION_MAX == i )
14203 {
14204 //No session is available
14205 status = eHAL_STATUS_RESOURCES;
14206 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014207 return ( status );
14208}
Jeff Johnson295189b2012-06-20 16:38:30 -070014209eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
14210{
14211 eHalStatus status = eHAL_STATUS_SUCCESS;
14212 tListElem *pEntry = NULL;
14213 tSmeCmd *pCommand = NULL;
14214 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014215 do
14216 {
14217 if(pMsg == NULL)
14218 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014219 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014220 status = eHAL_STATUS_FAILURE;
14221 break;
14222 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014223 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
14224 if(pEntry)
14225 {
14226 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14227 if(eSmeCommandDelStaSession == pCommand->command)
14228 {
14229 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070014230 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014231 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014232 //This session is done.
14233 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014234 if(pCommand->u.delStaSessionCmd.callback)
14235 {
14236
14237 status = sme_ReleaseGlobalLock( &pMac->sme );
14238 if ( HAL_STATUS_SUCCESS( status ) )
14239 {
14240 pCommand->u.delStaSessionCmd.callback(
14241 pCommand->u.delStaSessionCmd.pContext);
14242 status = sme_AcquireGlobalLock( &pMac->sme );
14243 if (! HAL_STATUS_SUCCESS( status ) )
14244 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014245 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014246 return status;
14247 }
14248 }
14249 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014250 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014251 }
14252 }
14253
14254 //Remove this command out of the active list
14255 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
14256 {
14257 //Now put this command back on the avilable command list
14258 csrReleaseCommand(pMac, pCommand);
14259 }
14260 smeProcessPendingQueue( pMac );
14261 }
14262 else
14263 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014264 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 -070014265 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014266 status = eHAL_STATUS_FAILURE;
14267 break;
14268 }
14269 }
14270 else
14271 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014272 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 -070014273 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014274 status = eHAL_STATUS_FAILURE;
14275 break;
14276 }
14277 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014278 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014279}
Jeff Johnson295189b2012-06-20 16:38:30 -070014280eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
14281{
14282 tSirSmeDelStaSelfReq *pMsg;
14283 tANI_U16 msgLen;
14284 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014285 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070014286 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
14287 sizeof( tSirBssType )*/;
Kiet Lam64c1b492013-07-12 13:56:44 +053014288 pMsg = vos_mem_malloc(msgLen);
14289 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14290 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014291 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
14292 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014293 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053014294 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr,
14295 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014296 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014297 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014298 return( status );
14299}
Jeff Johnson295189b2012-06-20 16:38:30 -070014300eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
14301 tSirMacAddr sessionMacAddr,
14302 csrRoamSessionCloseCallback callback,
14303 void *pContext)
14304{
14305 eHalStatus status = eHAL_STATUS_SUCCESS;
14306 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014307 pCommand = csrGetCommandBuffer(pMac);
14308 if(NULL == pCommand)
14309 {
14310 status = eHAL_STATUS_RESOURCES;
14311 }
14312 else
14313 {
14314 pCommand->command = eSmeCommandDelStaSession;
14315 pCommand->sessionId = (tANI_U8)sessionId;
14316 pCommand->u.delStaSessionCmd.callback = callback;
14317 pCommand->u.delStaSessionCmd.pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053014318 vos_mem_copy(pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr,
14319 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014320 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
14321 if( !HAL_STATUS_SUCCESS( status ) )
14322 {
14323 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014324 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014325 }
14326 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014327 return (status);
14328}
Jeff Johnson295189b2012-06-20 16:38:30 -070014329eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14330{
14331 return csrSendMBDelSelfStaReqMsg( pMac,
14332 pCommand->u.delStaSessionCmd.selfMacAddr );
14333}
Jeff Johnson295189b2012-06-20 16:38:30 -070014334static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
14335{
14336 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
14337 tListElem *pEntry, *pNext;
14338 tSmeCmd *pCommand;
14339 tDblLinkList localList;
14340
14341 vos_mem_zero(&localList, sizeof(tDblLinkList));
14342 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
14343 {
14344 smsLog(pMac, LOGE, FL(" failed to open list"));
14345 return;
14346 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014347 csrLLLock(pList);
14348 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
14349 while(pEntry != NULL)
14350 {
14351 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
14352 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14353 if(pCommand->sessionId == sessionId)
14354 {
14355 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
14356 {
14357 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
14358 }
14359 }
14360 pEntry = pNext;
14361 }
14362 csrLLUnlock(pList);
14363
14364 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
14365 {
14366 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14367 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
14368 }
14369 csrLLClose(&localList);
14370}
14371
Jeff Johnson295189b2012-06-20 16:38:30 -070014372void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
14373{
14374 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14375 {
14376 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014377 csrRoamStop(pMac, sessionId);
14378 csrFreeConnectBssDesc(pMac, sessionId);
14379 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
14380 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014381 vos_timer_destroy(&pSession->hTimerRoaming);
Jeff Johnson295189b2012-06-20 16:38:30 -070014382#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014383 vos_timer_destroy(&pSession->hTimerJoinRetry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014384#endif
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014385 purgeSmeSessionCmdList(pMac, sessionId, &pMac->sme.smeCmdPendingList);
14386 if (pMac->fScanOffload)
14387 {
14388 purgeSmeSessionCmdList(pMac, sessionId,
14389 &pMac->sme.smeScanCmdPendingList);
14390 }
14391
Jeff Johnson295189b2012-06-20 16:38:30 -070014392 purgeCsrSessionCmdList(pMac, sessionId);
14393 csrInitSession(pMac, sessionId);
14394 }
14395}
14396
Jeff Johnson295189b2012-06-20 16:38:30 -070014397eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
14398 tANI_BOOLEAN fSync,
14399 csrRoamSessionCloseCallback callback,
14400 void *pContext )
14401{
14402 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014403 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14404 {
14405 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14406 if(fSync)
14407 {
14408 csrCleanupSession(pMac, sessionId);
14409 }
14410 else
14411 {
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014412 purgeSmeSessionCmdList(pMac, sessionId,
14413 &pMac->sme.smeCmdPendingList);
14414 if (pMac->fScanOffload)
14415 {
14416 purgeSmeSessionCmdList(pMac, sessionId,
14417 &pMac->sme.smeScanCmdPendingList);
14418 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014419 purgeCsrSessionCmdList(pMac, sessionId);
14420 status = csrIssueDelStaForSessionReq( pMac, sessionId,
14421 pSession->selfMacAddr, callback, pContext);
14422 }
14423 }
14424 else
14425 {
14426 status = eHAL_STATUS_INVALID_PARAMETER;
14427 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014428 return ( status );
14429}
14430
Jeff Johnson295189b2012-06-20 16:38:30 -070014431static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
14432{
14433 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014434
14435 if(!pSession)
14436 {
14437 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14438 return;
14439 }
14440
Jeff Johnson295189b2012-06-20 16:38:30 -070014441 pSession->sessionActive = eANI_BOOLEAN_FALSE;
14442 pSession->sessionId = CSR_SESSION_ID_INVALID;
14443 pSession->callback = NULL;
14444 pSession->pContext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014445 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
14446 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
14447 csrFreeRoamProfile( pMac, sessionId );
14448 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
14449 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
14450 csrFreeConnectBssDesc(pMac, sessionId);
14451 csrScanEnable(pMac);
Kiet Lam64c1b492013-07-12 13:56:44 +053014452 vos_mem_set(&pSession->selfMacAddr, sizeof(tCsrBssid), 0);
14453 if (pSession->pWpaRsnReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014454 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014455 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014456 pSession->pWpaRsnReqIE = NULL;
14457 }
14458 pSession->nWpaRsnReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014459 if (pSession->pWpaRsnRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014460 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014461 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014462 pSession->pWpaRsnRspIE = NULL;
14463 }
14464 pSession->nWpaRsnRspIeLength = 0;
14465#ifdef FEATURE_WLAN_WAPI
Kiet Lam64c1b492013-07-12 13:56:44 +053014466 if (pSession->pWapiReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014467 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014468 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014469 pSession->pWapiReqIE = NULL;
14470 }
14471 pSession->nWapiReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014472 if (pSession->pWapiRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014473 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014474 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014475 pSession->pWapiRspIE = NULL;
14476 }
14477 pSession->nWapiRspIeLength = 0;
14478#endif /* FEATURE_WLAN_WAPI */
Agarwal Ashish4f616132013-12-30 23:32:50 +053014479 if (pSession->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070014480 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053014481 memset(pSession->addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH);
Jeff Johnson295189b2012-06-20 16:38:30 -070014482 }
14483 pSession->nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053014484
Kiet Lam64c1b492013-07-12 13:56:44 +053014485 if (pSession->pAddIEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070014486 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014487 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070014488 pSession->pAddIEAssoc = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053014489 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014490 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014491}
14492
Jeff Johnson295189b2012-06-20 16:38:30 -070014493eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
14494{
14495 eHalStatus status = eHAL_STATUS_FAILURE;
14496 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070014497 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14498 {
14499 if( CSR_IS_SESSION_VALID( pMac, i ) )
14500 {
14501 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
14502 {
14503 //Found it
14504 status = eHAL_STATUS_SUCCESS;
14505 *pSessionId = i;
14506 break;
14507 }
14508 }
14509 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014510 return( status );
14511}
14512
Jeff Johnson295189b2012-06-20 16:38:30 -070014513//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
14514//session because for IBSS, the bssid changes.
14515static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
14516{
14517 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
14518 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070014519 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14520 {
14521 if( CSR_IS_SESSION_VALID( pMac, i ) )
14522 {
14523 pSession = CSR_GET_SESSION( pMac, i );
14524 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
14525 {
14526 //Found it
14527 nRet = i;
14528 break;
14529 }
14530 }
14531 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014532 return (nRet);
14533}
Jeff Johnson295189b2012-06-20 16:38:30 -070014534static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
14535{
14536 /* Update the current BSS info in ho control block based on connected
14537 profile info from pmac global structure */
14538
Arif Hussain24bafea2013-11-15 15:10:03 -080014539 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= "MAC_ADDRESS_STR,
14540 MAC_ADDR_ARRAY(bssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070014541 /* Check for user misconfig of RSSI trigger threshold */
14542 pMac->roam.configParam.vccRssiThreshold =
14543 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
14544 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
14545 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070014546 /* Check for user misconfig of UL MAC Loss trigger threshold */
14547 pMac->roam.configParam.vccUlMacLossThreshold =
14548 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
14549 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014550#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14551 {
14552 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014553 /* Indicate the neighbor roal algorithm about the connect indication */
14554 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
14555 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
14556 }
14557#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014558}
14559
Jeff Johnson295189b2012-06-20 16:38:30 -070014560static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
14561{
14562 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014563
14564 if(!pSession)
14565 {
14566 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14567 return;
14568 }
14569
Jeff Johnson295189b2012-06-20 16:38:30 -070014570 //Only to handle the case for Handover on infra link
14571 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
14572 {
14573 return;
14574 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014575 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
14576 csrRoamDeregStatisticsReq(pMac);
14577 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14578#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14579 /* Indicate the neighbor roal algorithm about the disconnect indication */
14580 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
14581#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070014582
14583 //Remove this code once SLM_Sessionization is supported
14584 //BMPS_WORKAROUND_NOT_NEEDED
14585 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070014586 csrIsInfraApStarted( pMac ) &&
14587 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070014588 {
14589 pMac->roam.configParam.doBMPSWorkaround = 0;
14590 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014591}
14592
Jeff Johnson295189b2012-06-20 16:38:30 -070014593void csrRoamTlStatsTimerHandler(void *pv)
14594{
14595 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
14596 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014597 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14598
Jeff Johnsone7245742012-09-05 17:12:55 -070014599 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
14600
Jeff Johnson295189b2012-06-20 16:38:30 -070014601#if 0
14602 // TODO Persession .???
14603 //req TL for stats
14604 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
14605 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014606 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014607 }
14608 else
14609 {
14610 //save in SME
14611 csrRoamSaveStatsFromTl(pMac, tlStats);
14612 }
14613#endif
14614 if(!pMac->roam.tlStatsReqInfo.timerRunning)
14615 {
14616 if(pMac->roam.tlStatsReqInfo.periodicity)
14617 {
14618 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014619 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
14620 pMac->roam.tlStatsReqInfo.periodicity);
14621 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014622 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014623 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014624 return;
14625 }
14626 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
14627 }
14628 }
14629}
Jeff Johnson295189b2012-06-20 16:38:30 -070014630void csrRoamPeStatsTimerHandler(void *pv)
14631{
14632 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
14633 eHalStatus status;
14634 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
14635 VOS_STATUS vosStatus;
14636 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070014637 pPeStatsReqListEntry->timerRunning = FALSE;
14638 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
14639 {
14640 // If we entered here, meaning the timer could not be successfully
14641 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
14642
14643 /* Destroy the timer */
14644 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
14645 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14646 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014647 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014648 }
14649
14650 // Free the entry
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014651 vos_mem_free(pPeStatsReqListEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014652 pPeStatsReqListEntry = NULL;
14653 }
14654 else
14655 {
14656 if(!pPeStatsReqListEntry->rspPending)
14657 {
14658 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
14659 pPeStatsReqListEntry->staId);
14660 if(!HAL_STATUS_SUCCESS(status))
14661 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014662 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014663 }
14664 else
14665 {
14666 pPeStatsReqListEntry->rspPending = TRUE;
14667 }
14668 }
14669
14670 //send down a req
14671 if(pPeStatsReqListEntry->periodicity &&
14672 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
14673 {
14674 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
14675 if(ePMC_FULL_POWER == powerState)
14676 {
14677 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
14678 {
14679 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
14680 }
14681 }
14682 else
14683 {
14684 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
14685 {
14686 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
14687 }
14688 }
14689 //start timer
14690 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
14691 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14692 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014693 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014694 return;
14695 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014696 pPeStatsReqListEntry->timerRunning = TRUE;
14697
14698 }
14699
14700 }
14701}
Jeff Johnson295189b2012-06-20 16:38:30 -070014702void csrRoamStatsClientTimerHandler(void *pv)
14703{
14704 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070014705 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
14706 {
14707#if 0
14708 // TODO Stats fix for multisession
14709 //start the timer
14710 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
14711
14712 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14713 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014714 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014715 }
14716#endif
14717 }
14718#if 0
14719 //send up the stats report
14720 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
14721 pStaEntry->staId, pStaEntry->pContext);
14722#endif
14723}
14724
14725
14726
Jeff Johnson295189b2012-06-20 16:38:30 -070014727eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
14728{
14729 tAniGetPEStatsReq *pMsg;
14730 eHalStatus status = eHAL_STATUS_SUCCESS;
Kiet Lam64c1b492013-07-12 13:56:44 +053014731 pMsg = vos_mem_malloc(sizeof(tAniGetPEStatsReq));
14732 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070014733 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053014734 smsLog(pMac, LOGE, FL( "Failed to allocate mem for stats req "));
Kiet Lam64c1b492013-07-12 13:56:44 +053014735 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014736 }
14737 // need to initiate a stats request to PE
14738 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_STATISTICS_REQ);
14739 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
14740 pMsg->staId = staId;
14741 pMsg->statsMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070014742 status = palSendMBMessage(pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070014743 if(!HAL_STATUS_SUCCESS(status))
14744 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053014745 smsLog(pMac, LOG1, FL("Failed to send down the stats req "));
Jeff Johnson295189b2012-06-20 16:38:30 -070014746 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014747 return status;
14748}
Jeff Johnson295189b2012-06-20 16:38:30 -070014749void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
14750{
14751 tAniGetPEStatsRsp *pSmeStatsRsp;
14752 eHalStatus status = eHAL_STATUS_FAILURE;
14753 tListElem *pEntry = NULL;
14754 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
14755 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
14756 tANI_U32 tempMask = 0;
14757 tANI_U8 counter = 0;
14758 tANI_U8 *pStats = NULL;
14759 tANI_U32 length = 0;
14760 v_PVOID_t pvosGCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014761 v_S7_t rssi = 0, snr = 0;
14762 tANI_U32 *pRssi = NULL, *pSnr = NULL;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014763 tANI_U32 linkCapacity;
Jeff Johnson295189b2012-06-20 16:38:30 -070014764 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
14765 if(pSmeStatsRsp->rc)
14766 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014767 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014768 goto post_update;
14769 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014770 tempMask = pSmeStatsRsp->statsMask;
14771 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070014772 /* subtract all statistics from this length, and after processing the entire
14773 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
14774 * in this 'stats' message.
14775 */
14776 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070014777 //new stats info from PE, fill up the stats strucutres in PMAC
14778 while(tempMask)
14779 {
14780 if(tempMask & 1)
14781 {
14782 switch(counter)
14783 {
14784 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014785 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014786 vos_mem_copy((tANI_U8 *)&pMac->roam.summaryStatsInfo,
14787 pStats, sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014788 pStats += sizeof(tCsrSummaryStatsInfo);
14789 length -= sizeof(tCsrSummaryStatsInfo);
14790 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014791 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014792 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014793 vos_mem_copy((tANI_U8 *)&pMac->roam.classAStatsInfo,
14794 pStats, sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014795 pStats += sizeof(tCsrGlobalClassAStatsInfo);
14796 length -= sizeof(tCsrGlobalClassAStatsInfo);
14797 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014798 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014799 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014800 vos_mem_copy((tANI_U8 *)&pMac->roam.classBStatsInfo,
14801 pStats, sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014802 pStats += sizeof(tCsrGlobalClassBStatsInfo);
14803 length -= sizeof(tCsrGlobalClassBStatsInfo);
14804 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014805 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014806 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014807 vos_mem_copy((tANI_U8 *)&pMac->roam.classCStatsInfo,
14808 pStats, sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014809 pStats += sizeof(tCsrGlobalClassCStatsInfo);
14810 length -= sizeof(tCsrGlobalClassCStatsInfo);
14811 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014812 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014813 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014814 if( CSR_MAX_STA > pSmeStatsRsp->staId )
14815 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014816 vos_mem_copy((tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
14817 pStats, sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014818 }
14819 else
14820 {
14821 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014822 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014823 VOS_ASSERT( 0 );
14824 }
14825 if(!HAL_STATUS_SUCCESS(status))
14826 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014827 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014828 }
14829 pStats += sizeof(tCsrPerStaStatsInfo);
14830 length -= sizeof(tCsrPerStaStatsInfo);
14831 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014832 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014833 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014834 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014835 }
14836 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014837 tempMask >>=1;
14838 counter++;
14839 }
14840 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
14841 if (length != 0)
14842 {
14843 pRssi = (tANI_U32*)pStats;
14844 rssi = (v_S7_t)*pRssi;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014845 pStats += sizeof(tANI_U32);
14846 length -= sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070014847 }
14848 else
14849 {
14850 /* If riva is not sending rssi, continue to use the hack */
14851 rssi = RSSI_HACK_BMPS;
14852 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014853
Jeff Johnson295189b2012-06-20 16:38:30 -070014854 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014855
14856 if (length != 0)
14857 {
14858 linkCapacity = *(tANI_U32*)pStats;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014859 pStats += sizeof(tANI_U32);
14860 length -= sizeof(tANI_U32);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014861 }
14862 else
14863 {
14864 linkCapacity = 0;
14865 }
14866
14867 WDA_UpdateLinkCapacity(pvosGCtx, pSmeStatsRsp->staId, linkCapacity);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014868
14869 if (length != 0)
14870 {
14871 pSnr = (tANI_U32*)pStats;
14872 snr = (v_S7_t)*pSnr;
14873 }
14874 else
14875 {
14876 snr = SNR_HACK_BMPS;
14877 }
14878
14879 WDA_UpdateSnrBmps(pvosGCtx, pSmeStatsRsp->staId, snr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014880post_update:
14881 //make sure to update the pe stats req list
14882 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
14883 if(pEntry)
14884 {
14885 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
14886 pPeStaEntry->rspPending = FALSE;
14887
14888 }
14889 //check the one timer cases
14890 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
14891 if(pEntry)
14892 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014893 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014894 if(pTempStaEntry->timerExpired)
14895 {
14896 //send up the stats report
14897 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
14898 pTempStaEntry->staId, pTempStaEntry->pContext);
14899 //also remove from the client list
14900 csrRoamRemoveStatListEntry(pMac, pEntry);
14901 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014902 }
14903 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014904}
Jeff Johnson295189b2012-06-20 16:38:30 -070014905tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14906{
14907 tListElem *pEntry = NULL;
14908 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014909 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014910 if(!pEntry)
14911 {
14912 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014913 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070014914 return NULL;
14915 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014916 while( pEntry )
14917 {
14918 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014919 if(pTempStaEntry->statsMask == statsMask)
14920 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014921 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014922 break;
14923 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014924 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
14925 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014926 return pEntry;
14927}
14928
Jeff Johnson295189b2012-06-20 16:38:30 -070014929tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
14930 tANI_BOOLEAN update)
14931{
14932 tListElem *pEntry;
14933 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014934 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014935 if(!pEntry)
14936 {
14937 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014938 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014939 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014940 return NULL;
14941 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014942 while( pEntry )
14943 {
14944 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014945 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
14946 (pTempStaEntry->statsMask == pStaEntry->statsMask))
14947 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014948 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014949 if(update)
14950 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014951 pTempStaEntry->periodicity = pStaEntry->periodicity;
14952 pTempStaEntry->callback = pStaEntry->callback;
14953 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070014954 }
14955 break;
14956 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014957 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14958 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014959 return pEntry;
14960}
Jeff Johnson295189b2012-06-20 16:38:30 -070014961tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14962{
14963 tListElem *pEntry;
14964 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014965 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014966 if(!pEntry)
14967 {
14968 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014969 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014970 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014971 return NULL;
14972 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014973 while( pEntry )
14974 {
14975 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014976 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
14977 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014978 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014979 break;
14980 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014981 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14982 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014983 return pEntry;
14984}
Jeff Johnson295189b2012-06-20 16:38:30 -070014985eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
14986 csrRoamLinkQualityIndCallback callback,
14987 void *pContext)
14988{
14989 pMac->roam.linkQualityIndInfo.callback = callback;
14990 pMac->roam.linkQualityIndInfo.context = pContext;
14991 if( NULL == callback )
14992 {
14993 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
14994 }
14995 else
14996 {
14997 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070014998 /* do we need to invoke the callback to notify client of initial value ?? */
14999 }
15000 return eHAL_STATUS_SUCCESS;
15001}
Jeff Johnson295189b2012-06-20 16:38:30 -070015002void csrRoamVccTrigger(tpAniSirGlobal pMac)
15003{
15004 eCsrRoamLinkQualityInd newVccLinkQuality;
15005 tANI_U32 ul_mac_loss = 0;
15006 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070015007 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
15008 /*-------------------------------------------------------------------------
15009 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070015010 Check for a change in link quality and notify client if necessary
15011 -------------------------------------------------------------------------*/
15012 ul_mac_loss_trigger_threshold =
15013 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070015014 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015015 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015016 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070015017 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
15018 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015019 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070015020 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
15021 }
15022 else
15023 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015024 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070015025 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
15026 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015027 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
15028 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070015029 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
15030 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015031 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070015032 if(NULL != pMac->roam.linkQualityIndInfo.callback)
15033 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015034 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015035 newVccLinkQuality );
15036
15037 /* we now invoke the callback once to notify client of initial value */
15038 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
15039 pMac->roam.linkQualityIndInfo.context );
15040 //event: EVENT_WLAN_VCC
15041 }
15042 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015043 pMac->roam.vccLinkQuality = newVccLinkQuality;
15044
Jeff Johnson295189b2012-06-20 16:38:30 -070015045}
Jeff Johnson295189b2012-06-20 16:38:30 -070015046VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
15047 v_U8_t rssiNotification,
15048 void * context)
15049{
15050 tpAniSirGlobal pMac = PMAC_STRUCT( context );
15051 eCsrRoamLinkQualityInd newVccLinkQuality;
15052 // TODO : Session info unavailable
15053 tANI_U32 sessionId = 0;
15054 VOS_STATUS status = VOS_STATUS_SUCCESS;
15055 /*-------------------------------------------------------------------------
15056 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070015057 Check for a change in link quality and notify client if necessary
15058 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015059 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015060 pMac->roam.configParam.vccRssiThreshold);
15061 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
15062 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015063 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070015064 return VOS_STATUS_SUCCESS;
15065 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015066 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
15067 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015068 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070015069 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
15070 }
15071 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
15072 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015073 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070015074 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
15075 }
15076 else
15077 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015078 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070015079 //Set to this so the code below won't do anything
15080 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070015081 VOS_ASSERT(0);
15082 }
15083
Jeff Johnson295189b2012-06-20 16:38:30 -070015084 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
15085 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015086 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070015087 if(NULL != pMac->roam.linkQualityIndInfo.callback)
15088 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015089 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015090 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070015091 /* we now invoke the callback once to notify client of initial value */
15092 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
15093 pMac->roam.linkQualityIndInfo.context );
15094 //event: EVENT_WLAN_VCC
15095 }
15096 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015097 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070015098 return status;
15099}
Jeff Johnson295189b2012-06-20 16:38:30 -070015100tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
15101 tDblLinkList *pStaList,
15102 tCsrStatsClientReqInfo *pStaEntry)
15103{
15104 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015105 //if same entity requested for same set of stats with different periodicity &
15106 // callback update it
15107 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
15108 {
15109
Kiet Lam64c1b492013-07-12 13:56:44 +053015110 pNewStaEntry = vos_mem_malloc(sizeof(tCsrStatsClientReqInfo));
15111 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015112 {
15113 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015114 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070015115 return NULL;
15116 }
15117
Jeff Johnson295189b2012-06-20 16:38:30 -070015118 pNewStaEntry->callback = pStaEntry->callback;
15119 pNewStaEntry->pContext = pStaEntry->pContext;
15120 pNewStaEntry->periodicity = pStaEntry->periodicity;
15121 pNewStaEntry->requesterId = pStaEntry->requesterId;
15122 pNewStaEntry->statsMask = pStaEntry->statsMask;
15123 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
15124 pNewStaEntry->pMac = pStaEntry->pMac;
15125 pNewStaEntry->staId = pStaEntry->staId;
15126 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
15127
15128 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
15129 }
15130 return pNewStaEntry;
15131}
15132
Jeff Johnson295189b2012-06-20 16:38:30 -070015133tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
15134 tDblLinkList *pStaList,
15135 tCsrPeStatsReqInfo *pStaEntry)
15136{
15137 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053015138 pNewStaEntry = vos_mem_malloc(sizeof(tCsrPeStatsReqInfo));
15139 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015140 {
15141 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015142 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070015143 return NULL;
15144 }
15145
Jeff Johnson295189b2012-06-20 16:38:30 -070015146 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
15147 pNewStaEntry->numClient = pStaEntry->numClient;
15148 pNewStaEntry->periodicity = pStaEntry->periodicity;
15149 pNewStaEntry->statsMask = pStaEntry->statsMask;
15150 pNewStaEntry->pMac = pStaEntry->pMac;
15151 pNewStaEntry->staId = pStaEntry->staId;
15152 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
15153 pNewStaEntry->rspPending = pStaEntry->rspPending;
15154
15155 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015156 return pNewStaEntry;
15157}
Jeff Johnson295189b2012-06-20 16:38:30 -070015158eHalStatus csrGetRssi(tpAniSirGlobal pMac,
15159 tCsrRssiCallback callback,
15160 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
15161{
15162 eHalStatus status = eHAL_STATUS_SUCCESS;
15163 vos_msg_t msg;
15164 tANI_U32 sessionId;
15165
15166 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015167 smsLog(pMac, LOG2, FL("called"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015168 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
15169 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070015170 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015171 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053015172 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015173 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015174 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
15175
15176 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
15177 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
15178 pMsg->sessionId = sessionId;
15179 pMsg->staId = staId;
15180 pMsg->rssiCallback = callback;
15181 pMsg->pDevContext = pContext;
15182 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070015183 msg.type = eWNI_SME_GET_RSSI_REQ;
15184 msg.bodyptr = pMsg;
15185 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015186 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
15187 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015188 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053015189 vos_mem_free((void *)pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015190 status = eHAL_STATUS_FAILURE;
15191 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015192 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015193 return status;
15194}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015195
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015196eHalStatus csrGetSnr(tpAniSirGlobal pMac,
15197 tCsrSnrCallback callback,
15198 tANI_U8 staId, tCsrBssid bssId,
15199 void *pContext)
15200{
15201 eHalStatus status = eHAL_STATUS_SUCCESS;
15202 vos_msg_t msg;
15203 tANI_U32 sessionId;
15204
15205 tAniGetSnrReq *pMsg;
15206
15207 smsLog(pMac, LOG2, FL("called"));
15208
15209 pMsg =(tAniGetSnrReq *)vos_mem_malloc(sizeof(tAniGetSnrReq));
15210 if (NULL == pMsg )
15211 {
15212 smsLog(pMac, LOGE, "%s: failed to allocate mem for req",__func__);
15213 return status;
15214 }
15215
15216 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
15217
15218 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_SNR_REQ);
15219 pMsg->msgLen = (tANI_U16)sizeof(tAniGetSnrReq);
15220 pMsg->sessionId = sessionId;
15221 pMsg->staId = staId;
15222 pMsg->snrCallback = callback;
15223 pMsg->pDevContext = pContext;
15224 msg.type = eWNI_SME_GET_SNR_REQ;
15225 msg.bodyptr = pMsg;
15226 msg.reserved = 0;
15227
15228 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
15229 {
15230 smsLog(pMac, LOGE, "%s failed to post msg to self", __func__);
15231 vos_mem_free((v_VOID_t *)pMsg);
15232 status = eHAL_STATUS_FAILURE;
15233 }
15234
15235 smsLog(pMac, LOG2, FL("returned"));
15236 return status;
15237}
15238
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015239#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015240eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
15241 tCsrRssiCallback callback,
15242 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
15243{
15244 eHalStatus status = eHAL_STATUS_SUCCESS;
15245 tAniGetRssiReq *pMsg;
15246
Kiet Lam64c1b492013-07-12 13:56:44 +053015247 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
15248 if ( NULL == pMsg )
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015249 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015250 smsLog(pMac, LOGE, FL("Failed to allocate mem for req"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015251 return eHAL_STATUS_FAILURE;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015252 }
15253 // need to initiate a stats request to PE
15254 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
15255 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
15256 pMsg->staId = staId;
15257 pMsg->rssiCallback = callback;
15258 pMsg->pDevContext = pContext;
15259 pMsg->pVosContext = pVosContext;
15260 status = palSendMBMessage(pMac->hHdd, pMsg );
15261 if(!HAL_STATUS_SUCCESS(status))
15262 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015263 smsLog(pMac, LOGE, FL(" Failed to send down get rssi req"));
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070015264 //pMsg is freed by palSendMBMessage
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015265 status = eHAL_STATUS_FAILURE;
15266 }
15267 return status;
15268}
15269#endif
15270
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015271
15272
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015273#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015274eHalStatus csrGetTsmStats(tpAniSirGlobal pMac,
15275 tCsrTsmStatsCallback callback,
15276 tANI_U8 staId,
15277 tCsrBssid bssId,
15278 void *pContext,
15279 void* pVosContext,
15280 tANI_U8 tid)
15281{
15282 eHalStatus status = eHAL_STATUS_SUCCESS;
15283 tAniGetTsmStatsReq *pMsg = NULL;
15284
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015285 pMsg = (tAniGetTsmStatsReq*)vos_mem_malloc(sizeof(tAniGetTsmStatsReq));
15286 if (NULL == pMsg)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015287 {
15288 smsLog(pMac, LOGE, "csrGetTsmStats: failed to allocate mem for req");
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015289 return eHAL_STATUS_FAILED_ALLOC;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015290 }
15291 // need to initiate a stats request to PE
15292 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_TSM_STATS_REQ);
15293 pMsg->msgLen = (tANI_U16)sizeof(tAniGetTsmStatsReq);
15294 pMsg->staId = staId;
15295 pMsg->tid = tid;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015296 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015297 pMsg->tsmStatsCallback = callback;
15298 pMsg->pDevContext = pContext;
15299 pMsg->pVosContext = pVosContext;
15300 status = palSendMBMessage(pMac->hHdd, pMsg );
15301 if(!HAL_STATUS_SUCCESS(status))
15302 {
15303 smsLog(pMac, LOG1, " csrGetTsmStats: failed to send down the rssi req");
15304 //pMsg is freed by palSendMBMessage
15305 status = eHAL_STATUS_FAILURE;
15306 }
15307 return status;
15308}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015309#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015310
15311
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053015312/* ---------------------------------------------------------------------------
15313 \fn csrGetTLSTAState
15314 \helper function to get teh TL STA State whenever the function is called.
15315
15316 \param staId - The staID to be passed to the TL
15317 to get the relevant TL STA State
15318 \return the state as tANI_U16
15319 ---------------------------------------------------------------------------*/
15320tANI_U16 csrGetTLSTAState(tpAniSirGlobal pMac, tANI_U8 staId)
15321{
15322 WLANTL_STAStateType tlSTAState;
15323 tlSTAState = WLANTL_STA_INIT;
15324
15325 //request TL for STA State
15326 if ( !VOS_IS_STATUS_SUCCESS(WLANTL_GetSTAState(pMac->roam.gVosContext, staId, &tlSTAState)) )
15327 {
15328 smsLog(pMac, LOGE, FL("csrGetTLSTAState:couldn't get the STA state from TL"));
15329 }
15330
15331 return tlSTAState;
15332}
15333
Jeff Johnson295189b2012-06-20 16:38:30 -070015334eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
15335 tANI_U32 statsMask,
15336 tCsrStatsCallback callback,
15337 tANI_U32 periodicity, tANI_BOOLEAN cache,
15338 tANI_U8 staId, void *pContext)
15339{
15340 tCsrStatsClientReqInfo staEntry;
15341 tCsrStatsClientReqInfo *pStaEntry = NULL;
15342 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
15343 tListElem *pEntry = NULL;
15344 tANI_BOOLEAN found = FALSE;
15345 eHalStatus status = eHAL_STATUS_SUCCESS;
15346 tANI_BOOLEAN insertInClientList = FALSE;
15347 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070015348 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070015349
15350 if( csrIsAllSessionDisconnected(pMac) )
15351 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015352 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070015353 return eHAL_STATUS_FAILURE;
15354 }
Hanumantha Reddy Pothula449aadf2014-02-07 13:53:35 +053015355
15356 if (csrNeighborMiddleOfRoaming((tHalHandle)pMac))
15357 {
15358 smsLog(pMac, LOG1, FL("in the middle of roaming states"));
15359 return eHAL_STATUS_FAILURE;
15360 }
15361
Jeff Johnson295189b2012-06-20 16:38:30 -070015362 if((!statsMask) && (!callback))
15363 {
15364 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015365 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070015366 return eHAL_STATUS_FAILURE;
15367 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015368 //for the search list method for deregister
15369 staEntry.requesterId = requesterId;
15370 staEntry.statsMask = statsMask;
15371 //requester wants to deregister or just an error
15372 if((statsMask) && (!callback))
15373 {
15374 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
15375 if(!pEntry)
15376 {
15377 //msg
15378 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015379 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015380 return eHAL_STATUS_FAILURE;
15381 }
15382 else
15383 {
15384 //clean up & return
15385 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070015386 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015387 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015388 pStaEntry->pPeStaEntry->numClient--;
15389 //check if we need to delete the entry from peStatsReqList too
15390 if(!pStaEntry->pPeStaEntry->numClient)
15391 {
15392 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
15393 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015394 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070015395
Jeff Johnson295189b2012-06-20 16:38:30 -070015396 //check if we need to stop the tl stats timer too
15397 pMac->roam.tlStatsReqInfo.numClient--;
15398 if(!pMac->roam.tlStatsReqInfo.numClient)
15399 {
15400 if(pMac->roam.tlStatsReqInfo.timerRunning)
15401 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015402 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
15403 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015404 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015405 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015406 return eHAL_STATUS_FAILURE;
15407 }
15408 }
15409 pMac->roam.tlStatsReqInfo.periodicity = 0;
15410 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
15411 }
15412 vos_timer_stop( &pStaEntry->timer );
Jeff Johnson295189b2012-06-20 16:38:30 -070015413 // Destroy the vos timer...
15414 vosStatus = vos_timer_destroy( &pStaEntry->timer );
15415 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15416 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015417 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to destroy Client req timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015418 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015419 csrRoamRemoveStatListEntry(pMac, pEntry);
15420 pStaEntry = NULL;
15421 return eHAL_STATUS_SUCCESS;
15422 }
15423 }
15424
15425 if(cache && !periodicity)
15426 {
15427 //return the cached stats
15428 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15429 }
15430 else
15431 {
15432 //add the request in the client req list
15433 staEntry.callback = callback;
15434 staEntry.pContext = pContext;
15435 staEntry.periodicity = periodicity;
15436 staEntry.pPeStaEntry = NULL;
15437 staEntry.staId = staId;
15438 staEntry.pMac = pMac;
15439 staEntry.timerExpired = FALSE;
15440
15441
Jeff Johnson295189b2012-06-20 16:38:30 -070015442 //if periodic report requested with non cached result from PE/TL
15443 if(periodicity)
15444 {
15445
15446 //if looking for stats from PE
15447 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15448 {
15449
15450 //check if same request made already & waiting for rsp
15451 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
15452 periodicity, &found, staId);
15453 if(!pPeStaEntry)
15454 {
15455 //bail out, maxed out on number of req for PE
15456 return eHAL_STATUS_FAILURE;
15457 }
15458 else
15459 {
15460 staEntry.pPeStaEntry = pPeStaEntry;
15461 }
15462
15463 }
15464 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
15465 if(statsMask & (1 << eCsrGlobalClassDStats))
15466 {
15467 if(cache && pMac->roam.tlStatsReqInfo.numClient)
15468 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015469 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015470 }
15471 else
15472 {
15473
15474 //update periodicity
15475 if(pMac->roam.tlStatsReqInfo.periodicity)
15476 {
15477 pMac->roam.tlStatsReqInfo.periodicity =
15478 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
15479 }
15480 else
15481 {
15482 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
15483 }
15484 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
15485 {
15486 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
15487 }
15488
15489 if(!pMac->roam.tlStatsReqInfo.timerRunning)
15490 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015491 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015492 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015493 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015494 //req TL for class D stats
15495 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
15496 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015497 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015498 }
15499 else
15500 {
15501 //save in SME
15502 csrRoamSaveStatsFromTl(pMac, pTlStats);
15503 }
15504 vos_mem_free(pTlStats);
15505 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015506 }
15507 else
15508 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015509 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015510 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015511
Jeff Johnson295189b2012-06-20 16:38:30 -070015512 if(pMac->roam.tlStatsReqInfo.periodicity)
15513 {
15514 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015515 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
15516 pMac->roam.tlStatsReqInfo.periodicity);
15517 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015518 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015519 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015520 return eHAL_STATUS_FAILURE;
15521 }
15522 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
15523 }
15524 }
15525 }
15526 pMac->roam.tlStatsReqInfo.numClient++;
15527 }
15528
15529 insertInClientList = TRUE;
15530 }
15531 //if one time report requested with non cached result from PE/TL
15532 else if(!cache && !periodicity)
15533 {
15534 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15535 {
15536 //send down a req
15537 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
15538 if(!HAL_STATUS_SUCCESS(status))
15539 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015540 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015541 }
15542 //so that when the stats rsp comes back from PE we respond to upper layer
15543 //right away
15544 staEntry.timerExpired = TRUE;
15545 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015546 }
15547 if(statsMask & (1 << eCsrGlobalClassDStats))
15548 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015549 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015550 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015551 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015552 //req TL for class D stats
15553 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
15554 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015555 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015556 }
15557 else
15558 {
15559 //save in SME
15560 csrRoamSaveStatsFromTl(pMac, pTlStats);
15561 }
15562 vos_mem_free(pTlStats);
15563 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015564 }
15565 else
15566 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015567 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015568 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015569
15570 }
15571 //if looking for stats from TL only
15572 if(!insertInClientList)
15573 {
15574 //return the stats
15575 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15576 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015577 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015578 if(insertInClientList)
15579 {
15580 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
15581 if(!pStaEntry)
15582 {
15583 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015584 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015585 return eHAL_STATUS_FAILURE;
15586 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015587 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070015588 //Init & start timer if needed
15589 if(periodicity)
15590 {
15591 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
15592 csrRoamStatsClientTimerHandler, pStaEntry );
15593 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15594 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015595 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015596 return eHAL_STATUS_FAILURE;
15597 }
15598 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
15599 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15600 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015601 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015602 return eHAL_STATUS_FAILURE;
15603 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015604 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015605 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015606 }
15607 return eHAL_STATUS_SUCCESS;
15608}
15609
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015610#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
15611
15612static tSirRetStatus
15613csrRoamScanOffloadPopulateMacHeader(tpAniSirGlobal pMac,
15614 tANI_U8* pBD,
15615 tANI_U8 type,
15616 tANI_U8 subType,
15617 tSirMacAddr peerAddr,
15618 tSirMacAddr selfMacAddr)
15619{
15620 tSirRetStatus statusCode = eSIR_SUCCESS;
15621 tpSirMacMgmtHdr pMacHdr;
15622
15623 /* Prepare MAC management header */
15624 pMacHdr = (tpSirMacMgmtHdr) (pBD);
15625
15626 /* Prepare FC */
15627 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
15628 pMacHdr->fc.type = type;
15629 pMacHdr->fc.subType = subType;
15630
15631 /* Prepare Address 1 */
Kiet Lam64c1b492013-07-12 13:56:44 +053015632 vos_mem_copy((tANI_U8 *) pMacHdr->da, (tANI_U8 *) peerAddr,
15633 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015634
15635 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
15636
15637 /* Prepare Address 3 */
Kiet Lam64c1b492013-07-12 13:56:44 +053015638 vos_mem_copy((tANI_U8 *) pMacHdr->bssId, (tANI_U8 *) peerAddr,
15639 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015640 return statusCode;
15641} /*** csrRoamScanOffloadPopulateMacHeader() ***/
15642
15643static tSirRetStatus
15644csrRoamScanOffloadPrepareProbeReqTemplate(tpAniSirGlobal pMac,
15645 tANI_U8 nChannelNum,
15646 tANI_U32 dot11mode,
15647 tSirMacAddr selfMacAddr,
15648 tANI_U8 *pFrame,
15649 tANI_U16 *pusLen)
15650{
15651 tDot11fProbeRequest pr;
15652 tANI_U32 nStatus, nBytes, nPayload;
15653 tSirRetStatus nSirStatus;
15654 /*Bcast tx*/
15655 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
15656 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
15657
15658
Kiet Lam64c1b492013-07-12 13:56:44 +053015659 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015660
15661 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
15662
15663 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
15664 {
15665 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
15666 }
15667
15668
15669 if (IS_DOT11_MODE_HT(dot11mode))
15670 {
15671 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
15672 }
15673
15674
15675 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
15676 if ( DOT11F_FAILED( nStatus ) )
15677 {
15678 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15679 "Failed to calculate the packed size f"
15680 "or a Probe Request (0x%08x).\n", nStatus );
15681
15682
15683 nPayload = sizeof( tDot11fProbeRequest );
15684 }
15685 else if ( DOT11F_WARNED( nStatus ) )
15686 {
15687 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15688 "There were warnings while calculating"
15689 "the packed size for a Probe Request ("
15690 "0x%08x).\n", nStatus );
15691 }
15692
15693 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
15694
15695 /* Prepare outgoing frame*/
Kiet Lam64c1b492013-07-12 13:56:44 +053015696 vos_mem_set(pFrame, nBytes , 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015697
15698
15699 nSirStatus = csrRoamScanOffloadPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015700 SIR_MAC_MGMT_PROBE_REQ, bssId,selfMacAddr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015701
15702 if ( eSIR_SUCCESS != nSirStatus )
15703 {
15704 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15705 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
15706 nSirStatus );
15707 return nSirStatus;
15708 }
15709
15710
15711 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
15712 sizeof( tSirMacMgmtHdr ),
15713 nPayload, &nPayload );
15714 if ( DOT11F_FAILED( nStatus ) )
15715 {
15716 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15717 "Failed to pack a Probe Request (0x%08x).\n", nStatus );
15718 return eSIR_FAILURE;
15719 }
15720 else if ( DOT11F_WARNED( nStatus ) )
15721 {
15722 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce8ad512013-10-30 12:34:42 -070015723 "There were warnings while packing a Probe Request (0x%08x).\n",
15724 nStatus );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015725 }
15726
15727 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
15728 return eSIR_SUCCESS;
15729}
15730
15731eHalStatus csrRoamOffloadScan(tpAniSirGlobal pMac, tANI_U8 command, tANI_U8 reason)
15732{
15733 vos_msg_t msg;
15734 tSirRoamOffloadScanReq *pRequestBuf;
15735 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
15736 tCsrRoamSession *pSession;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015737 tANI_U8 i,j,num_channels = 0, ucDot11Mode;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015738 tANI_U8 *ChannelList = NULL;
15739 tANI_U32 sessionId;
15740 eHalStatus status = eHAL_STATUS_SUCCESS;
15741 tpCsrChannelInfo currChannelListInfo;
Srinivas Girigowda56076852013-08-20 14:00:50 -070015742 tANI_U32 host_channels = 0;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015743 tANI_U8 ChannelCacheStr[128] = {0};
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015744 eCsrBand eBand;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015745 tSirBssDescription *pBssDesc = NULL;
15746 tDot11fBeaconIEs *pIes = NULL;
15747 tANI_U8 minRate = 0, dataRate;
Varun Reddy Yeturu52231ea2014-02-06 12:00:56 -080015748 tANI_U8 operationChannel = 0;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015749
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015750 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
15751
Srinivas Girigowda830bbd02013-06-13 19:44:16 -070015752 if (0 == csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015753 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015754 smsLog( pMac, LOGE,"isRoamOffloadScanEnabled not set");
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015755 return eHAL_STATUS_FAILURE;
15756 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015757
15758 if ((VOS_TRUE == bRoamScanOffloadStarted) && (ROAM_SCAN_OFFLOAD_START == command))
15759 {
15760 smsLog( pMac, LOGE,"Roam Scan Offload is already started");
15761 return eHAL_STATUS_FAILURE;
15762 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015763 status = csrRoamGetSessionIdFromBSSID(pMac,
15764 (tCsrBssid *)pNeighborRoamInfo->currAPbssid,
15765 &sessionId);
15766 /*The Dynamic Config Items Update may happen even if the state is in INIT.
15767 * It is important to ensure that the command is passed down to the FW only
15768 * if the Infra Station is in a connected state.A connected station could also be
15769 * in a PREAUTH or REASSOC states.So, consider not sending the command down in INIT state.
15770 * We also have to ensure that if there is a STOP command we always have to inform Riva,
15771 * irrespective of whichever state we are in.*/
15772 if ((pMac->roam.neighborRoamInfo.neighborRoamState == eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
15773 (command != ROAM_SCAN_OFFLOAD_STOP))
15774 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053015775 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
15776 FL("Scan Command not sent to FW with state = %s and cmd=%d\n"),
15777 macTraceGetNeighbourRoamState(
15778 pMac->roam.neighborRoamInfo.neighborRoamState), command);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015779 return eHAL_STATUS_FAILURE;
15780 }
15781
15782 if ( !HAL_STATUS_SUCCESS( status ) )
15783 {
15784 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to find the sessionId for Roam Offload scan request", __func__);
15785 return eHAL_STATUS_FAILURE;
15786 }
15787 pSession = CSR_GET_SESSION( pMac, sessionId );
krunal soni587bf012014-02-04 12:35:11 -080015788 if (NULL == pSession)
15789 {
15790 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15791 "%s:pSession is null", __func__);
15792 return eHAL_STATUS_FAILURE;
15793 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015794 pBssDesc = pSession->pConnectBssDesc;
15795 if (pBssDesc == NULL)
15796 {
15797 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: pBssDesc not found for current session", __func__);
15798 return eHAL_STATUS_FAILURE;
15799 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015800 pRequestBuf = vos_mem_malloc(sizeof(tSirRoamOffloadScanReq));
15801 if (NULL == pRequestBuf)
15802 {
15803 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to allocate memory for Roam Offload scan request", __func__);
15804 return eHAL_STATUS_FAILED_ALLOC;
15805 }
15806
Kiet Lam64c1b492013-07-12 13:56:44 +053015807 vos_mem_zero(pRequestBuf, sizeof(tSirRoamOffloadScanReq));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015808 /* If command is STOP, then pass down ScanOffloadEnabled as Zero.This will handle the case of
15809 * host driver reloads, but Riva still up and running*/
Mukul Sharma90506b42014-04-24 13:24:12 +053015810 pRequestBuf->Command = command;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015811 if(command == ROAM_SCAN_OFFLOAD_STOP)
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015812 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015813 pRequestBuf->RoamScanOffloadEnabled = 0;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015814 /*For a STOP Command, there is no need to
15815 * go through filling up all the below parameters
15816 * since they are not required for the STOP command*/
15817 goto send_roam_scan_offload_cmd;
15818 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015819 else
15820 pRequestBuf->RoamScanOffloadEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
Kiet Lam64c1b492013-07-12 13:56:44 +053015821 vos_mem_copy(pRequestBuf->ConnectedNetwork.currAPbssid,
15822 pNeighborRoamInfo->currAPbssid,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015823 sizeof(tCsrBssid));
15824 pRequestBuf->ConnectedNetwork.ssId.length =
15825 pMac->roam.roamSession[sessionId].connectedProfile.SSID.length;
15826 vos_mem_copy(pRequestBuf->ConnectedNetwork.ssId.ssId,
15827 pMac->roam.roamSession[sessionId].connectedProfile.SSID.ssId,
15828 pRequestBuf->ConnectedNetwork.ssId.length);
15829 pRequestBuf->ConnectedNetwork.authentication =
15830 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
15831 pRequestBuf->ConnectedNetwork.encryption =
15832 pMac->roam.roamSession[sessionId].connectedProfile.EncryptionType;
15833 pRequestBuf->ConnectedNetwork.mcencryption =
15834 pMac->roam.roamSession[sessionId].connectedProfile.mcEncryptionType;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015835 if (pNeighborRoamInfo->cfgParams.neighborLookupThreshold)
15836 {
15837 pRequestBuf->LookupThreshold =
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015838 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborLookupThreshold * (-1);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015839 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
15840 }
15841 else
15842 {
15843 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Calculate Adaptive Threshold");
15844 operationChannel = pSession->connectedProfile.operationChannel;
15845
15846 if (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
15847 {
15848 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15849 "%s: csrGetParsedBssDescriptionIEs failed", __func__);
15850 vos_mem_free(pRequestBuf);
15851 return eHAL_STATUS_FAILURE;
15852 }
Kaushik, Sushant5874d032014-02-20 17:22:36 +053015853 if(NULL == pIes)
15854 {
15855 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15856 "%s : pIes is Null", __func__);
15857 return eHAL_STATUS_FAILURE;
15858 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015859 if (pIes->SuppRates.present)
15860 {
15861 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Number \t Rate");
15862 /*Check for both basic rates and extended rates.*/
15863 for (i = 0; i < pIes->SuppRates.num_rates; i++)
15864 {
15865 /*Check if the Rate is Mandatory or Not*/
15866 if (csrRatesIsDot11RateSupported(pMac, pIes->SuppRates.rates[i])
15867 && (pIes->SuppRates.rates[i] & 0x80))
15868 {
15869 /*Retrieve the actual data rate*/
15870 dataRate = (pIes->SuppRates.rates[i] & 0x7F)/2;
15871 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
15872 if (minRate == 0)
15873 minRate = dataRate;
15874 else
15875 minRate = (minRate < dataRate) ? minRate:dataRate;
15876 }
15877 }
15878
15879 if (pIes->ExtSuppRates.present)
15880 {
15881 for (i = 0; i < pIes->ExtSuppRates.num_rates; i++)
15882 {
15883 /*Check if the Rate is Mandatory or Not*/
15884 if (csrRatesIsDot11RateSupported(pMac, pIes->ExtSuppRates.rates[i])
15885 && (pIes->ExtSuppRates.rates[i] & 0x80))
15886 {
15887 /*Retrieve the actual data rate*/
15888 dataRate = (pIes->ExtSuppRates.rates[i] & 0x7F)/2;
15889 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
15890 if (minRate == 0)
15891 minRate = dataRate;
15892 else
15893 minRate = (minRate < dataRate) ? minRate:dataRate;
15894 }
15895 }
15896 }
15897 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "MinRate = %d", minRate);
15898 }
15899 else
15900 {
15901 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15902 "%s: Supp Rates not present in pIes", __func__);
15903 vos_mem_free(pRequestBuf);
15904 return eHAL_STATUS_FAILURE;
15905 }
15906 if (NULL != pIes)
15907 {
15908 vos_mem_free(pIes);
15909 pIes = NULL;
15910 }
15911 switch (minRate)
15912 {
15913 case 1:
15914 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_1MBPS;
15915 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_1MBPS;
15916 break;
15917 case 2:
15918 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_2MBPS;
15919 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_2MBPS;
15920 break;
15921 case 5:
15922 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_5_5MBPS;
15923 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_5_5MBPS;
15924 break;
15925 case 6:
15926 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
15927 {
15928 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_2G;
15929 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_2G;
15930 }
15931 else
15932 {
15933 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_5G;
15934 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_5G;
15935 }
15936 break;
15937 case 11:
15938 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_11MBPS;
15939 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_11MBPS;
15940 break;
15941 case 12:
15942 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
15943 {
15944 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_2G;
15945 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_2G;
15946 }
15947 else
15948 {
15949 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_5G;
15950 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_5G;
15951 }
15952 break;
15953 case 24:
15954 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
15955 {
15956 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_2G;
15957 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_2G;
15958 }
15959 else
15960 {
15961 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_5G;
15962 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_5G;
15963 }
15964 break;
15965 default:
15966 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_DEFAULT;
15967 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
15968 break;
15969 }
15970 }
15971 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
15972 "Chnl=%d,MinRate=%d,RxSenThr=%d,LookupThr=%d",
15973 operationChannel, minRate,
15974 pRequestBuf->RxSensitivityThreshold,
15975 pRequestBuf->LookupThreshold);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015976 pRequestBuf->RoamRssiDiff =
15977 pMac->roam.configParam.RoamRssiDiff;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015978 pRequestBuf->StartScanReason = reason;
15979 pRequestBuf->NeighborScanTimerPeriod =
15980 pNeighborRoamInfo->cfgParams.neighborScanPeriod;
15981 pRequestBuf->NeighborRoamScanRefreshPeriod =
15982 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod;
15983 pRequestBuf->NeighborScanChannelMinTime =
15984 pNeighborRoamInfo->cfgParams.minChannelScanTime;
15985 pRequestBuf->NeighborScanChannelMaxTime =
15986 pNeighborRoamInfo->cfgParams.maxChannelScanTime;
15987 pRequestBuf->EmptyRefreshScanPeriod =
15988 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -080015989 /* MAWC feature */
15990 pRequestBuf->MAWCEnabled =
15991 pMac->roam.configParam.MAWCEnabled;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015992#ifdef FEATURE_WLAN_ESE
15993 pRequestBuf->IsESEEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015994#endif
15995 if (
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015996#ifdef FEATURE_WLAN_ESE
15997 ((pNeighborRoamInfo->isESEAssoc) &&
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015998 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived ==
15999 eANI_BOOLEAN_FALSE)) ||
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016000 (pNeighborRoamInfo->isESEAssoc == eANI_BOOLEAN_FALSE) ||
16001#endif // ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016002 currChannelListInfo->numOfChannels == 0)
16003 {
16004
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016005 /*Retrieve the Channel Cache either from ini or from the Occupied Channels list.
16006 * Give Preference to INI Channels.*/
16007 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
16008 {
16009 ChannelList = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
16010 /*The INI channels need to be filtered with respect to the current
16011 * band that is supported.*/
16012 eBand = pMac->roam.configParam.bandCapability;
16013 if ((eCSR_BAND_24 != eBand) && (eCSR_BAND_5G != eBand) && (eCSR_BAND_ALL != eBand))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016014 {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016015 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16016 "Invalid band, No operation carried out (Band %d)", eBand);
16017 vos_mem_free(pRequestBuf);
16018 return eHAL_STATUS_FAILURE;
16019 }
16020 for (i=0; i<pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels; i++)
16021 {
16022 if(((eCSR_BAND_24 == eBand) && CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
16023 ((eCSR_BAND_5G == eBand) && CSR_IS_CHANNEL_5GHZ(*ChannelList)) ||
16024 (eCSR_BAND_ALL == eBand))
16025 {
16026 if(!CSR_IS_CHANNEL_DFS(*ChannelList) &&
16027 csrRoamIsChannelValid(pMac, *ChannelList) &&
16028 *ChannelList && (num_channels < SIR_ROAM_MAX_CHANNELS))
16029 {
16030 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
16031 }
16032 }
16033 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016034 }
16035 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16036 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016037 }
16038 else
16039 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016040 ChannelList = pMac->scan.occupiedChannels.channelList;
16041 for(i=0; i<pMac->scan.occupiedChannels.numChannels; i++)
16042 {
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053016043 /*Allow DFS channels only if the DFS channel roam flag is enabled */
16044 if(((pMac->roam.configParam.allowDFSChannelRoam) ||
16045 (!CSR_IS_CHANNEL_DFS(*ChannelList))) &&
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016046 *ChannelList && (num_channels < SIR_ROAM_MAX_CHANNELS))
16047 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016048 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016049 }
16050 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016051 }
16052 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16053 /* If the profile changes as to what it was earlier, inform the FW through
16054 * FLUSH as ChannelCacheType in which case, the FW will flush the occupied channels
16055 * for the earlier profile and try to learn them afresh.*/
16056 if (reason == REASON_FLUSH_CHANNEL_LIST)
16057 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
16058 else {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016059 if (csrNeighborRoamIsNewConnectedProfile(pMac))
16060 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
16061 else
16062 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016063 }
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016064 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016065 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016066#ifdef FEATURE_WLAN_ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016067 else
16068 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016069 /* If ESE is enabled, and a neighbor Report is received,then
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016070 * Ignore the INI Channels or the Occupied Channel List. Consider
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016071 * the channels in the neighbor list sent by the ESE AP.*/
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016072 if (currChannelListInfo->numOfChannels != 0)
16073 {
16074 ChannelList = currChannelListInfo->ChannelList;
16075 for (i=0;i<currChannelListInfo->numOfChannels;i++)
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016076 {
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053016077 if(((pMac->roam.configParam.allowDFSChannelRoam) ||
16078 (!CSR_IS_CHANNEL_DFS(*ChannelList))) && *ChannelList)
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016079 {
16080 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
16081 }
16082 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016083 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016084 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16085 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
16086 }
16087 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016088#endif
Kaushik, Sushant5ed8ab62014-03-05 11:21:11 +053016089 for (i = 0, j = 0;j < (sizeof(ChannelCacheStr)/sizeof(ChannelCacheStr[0])) && i < pRequestBuf->ConnectedNetwork.ChannelCount; i++)
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016090 {
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053016091 if (j < sizeof(ChannelCacheStr))
16092 {
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016093 j += snprintf(ChannelCacheStr + j, sizeof(ChannelCacheStr) - j," %d",
16094 pRequestBuf->ConnectedNetwork.ChannelCache[i]);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053016095 }
16096 else
16097 {
16098 break;
16099 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016100 }
16101 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
16102 "ChnlCacheType:%d, No of Chnls:%d,Channels: %s",
16103 pRequestBuf->ChannelCacheType,
16104 pRequestBuf->ConnectedNetwork.ChannelCount,
16105 ChannelCacheStr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016106 num_channels = 0;
16107 ChannelList = NULL;
16108
16109 /* Maintain the Valid Channels List*/
Srinivas Girigowda56076852013-08-20 14:00:50 -070016110 host_channels = sizeof(pMac->roam.validChannelList);
16111 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &host_channels)))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016112 {
Srinivas Girigowda56076852013-08-20 14:00:50 -070016113 ChannelList = pMac->roam.validChannelList;
16114 pMac->roam.numValidChannels = host_channels;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016115 }
Srinivas Girigowda56076852013-08-20 14:00:50 -070016116 else
16117 {
16118 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16119 "%s:Failed to get the valid channel list", __func__);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -070016120 vos_mem_free(pRequestBuf);
Srinivas Girigowda56076852013-08-20 14:00:50 -070016121 return eHAL_STATUS_FAILURE;
16122 }
16123 for(i=0; i<pMac->roam.numValidChannels; i++)
16124 {
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053016125 if(((pMac->roam.configParam.allowDFSChannelRoam) ||
16126 (!CSR_IS_CHANNEL_DFS(*ChannelList))) && *ChannelList)
Srinivas Girigowda56076852013-08-20 14:00:50 -070016127 {
16128 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
16129 }
16130 ChannelList++;
16131 }
16132 pRequestBuf->ValidChannelCount = num_channels;
16133
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016134 pRequestBuf->MDID.mdiePresent =
16135 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent;
16136 pRequestBuf->MDID.mobilityDomain =
16137 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mobilityDomain;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016138 pRequestBuf->nProbes = pMac->roam.configParam.nProbes;
16139
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016140 pRequestBuf->HomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016141 /* Home Away Time should be at least equal to (MaxDwell time + (2*RFS)),
16142 * where RFS is the RF Switching time. It is twice RFS to consider the
16143 * time to go off channel and return to the home channel. */
16144 if (pRequestBuf->HomeAwayTime < (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)))
16145 {
16146 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
16147 "%s: Invalid config, Home away time(%d) is less than (twice RF switching time + channel max time)(%d)"
16148 " Hence enforcing home away time to disable (0)",
16149 __func__, pRequestBuf->HomeAwayTime,
16150 (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)));
16151 pRequestBuf->HomeAwayTime = 0;
16152 }
16153 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,"HomeAwayTime:%d",pRequestBuf->HomeAwayTime);
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070016154
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016155 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
16156 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
16157 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
16158 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_24G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
16159 pRequestBuf->p24GProbeTemplate, &pRequestBuf->us24GProbeTemplateLen);
16160
16161 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_5G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
16162 pRequestBuf->p5GProbeTemplate, &pRequestBuf->us5GProbeTemplateLen);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016163send_roam_scan_offload_cmd:
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016164 msg.type = WDA_ROAM_SCAN_OFFLOAD_REQ;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016165 msg.reserved = 0;
16166 msg.bodyptr = pRequestBuf;
16167 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
16168 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016169 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_ROAM_SCAN_OFFLOAD_REQ message to WDA", __func__);
16170 vos_mem_free(pRequestBuf);
16171 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016172 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016173 else
16174 {
16175 if (ROAM_SCAN_OFFLOAD_START == command)
16176 bRoamScanOffloadStarted = VOS_TRUE;
16177 else if (ROAM_SCAN_OFFLOAD_STOP == command)
16178 bRoamScanOffloadStarted = VOS_FALSE;
16179 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016180
16181 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Roam Scan Offload Command %d, Reason %d", command, reason);
16182 return status;
16183}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016184
16185eHalStatus csrRoamOffloadScanRspHdlr(tpAniSirGlobal pMac, tANI_U8 reason)
16186{
16187 switch(reason)
16188 {
16189 case 0:
16190 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with failure status");
16191 break;
16192 case REASON_OS_REQUESTED_ROAMING_NOW:
16193 csrNeighborRoamProceedWithHandoffReq(pMac);
16194 break;
16195 default:
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -070016196 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 -070016197 }
16198 return eHAL_STATUS_SUCCESS;
16199}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016200#endif
16201
Jeff Johnson295189b2012-06-20 16:38:30 -070016202tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
16203 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
16204{
16205 tANI_BOOLEAN found = FALSE;
16206 eHalStatus status = eHAL_STATUS_SUCCESS;
16207 tCsrPeStatsReqInfo staEntry;
16208 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
16209 tListElem *pStaEntry = NULL;
16210 VOS_STATUS vosStatus;
16211 tPmcPowerState powerState;
16212 *pFound = FALSE;
16213
16214 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
16215 if(pStaEntry)
16216 {
16217 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
16218 if(pTempStaEntry->periodicity)
16219 {
16220 pTempStaEntry->periodicity =
16221 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
16222 }
16223 else
16224 {
16225 pTempStaEntry->periodicity = periodicity;
16226 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016227 pTempStaEntry->numClient++;
16228 found = TRUE;
16229 }
16230 else
16231 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016232 vos_mem_set(&staEntry, sizeof(tCsrPeStatsReqInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016233 staEntry.numClient = 1;
16234 staEntry.periodicity = periodicity;
16235 staEntry.pMac = pMac;
16236 staEntry.rspPending = FALSE;
16237 staEntry.staId = staId;
16238 staEntry.statsMask = statsMask;
16239 staEntry.timerRunning = FALSE;
16240 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
16241 if(!pTempStaEntry)
16242 {
16243 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016244 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070016245 return NULL;
16246 }
16247 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016248 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
16249 if(ePMC_FULL_POWER == powerState)
16250 {
16251 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
16252 {
16253 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
16254 }
16255 }
16256 else
16257 {
16258 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
16259 {
16260 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
16261 }
16262 }
16263 if(!pTempStaEntry->timerRunning)
16264 {
16265 //send down a req in case of one time req, for periodic ones wait for timer to expire
16266 if(!pTempStaEntry->rspPending &&
16267 !pTempStaEntry->periodicity)
16268 {
16269 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
16270 if(!HAL_STATUS_SUCCESS(status))
16271 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016272 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016273 }
16274 else
16275 {
16276 pTempStaEntry->rspPending = TRUE;
16277 }
16278 }
16279 if(pTempStaEntry->periodicity)
16280 {
16281 if(!found)
16282 {
16283
16284 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
16285 csrRoamPeStatsTimerHandler, pTempStaEntry );
16286 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16287 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016288 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016289 return NULL;
16290 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016291 }
16292 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016293 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070016294 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
16295 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16296 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016297 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016298 return NULL;
16299 }
16300 pTempStaEntry->timerRunning = TRUE;
16301 }
16302 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016303 *pFound = found;
16304 return pTempStaEntry;
16305}
16306
Jeff Johnson295189b2012-06-20 16:38:30 -070016307/*
16308 pStaEntry is no longer invalid upon the return of this function.
16309*/
16310static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
16311{
16312 if(pEntry)
16313 {
16314 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
16315 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016316 vos_mem_free(GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070016317 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016318 }
16319 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016320
16321void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
16322{
16323 tListElem *pEntry;
16324 tCsrPeStatsReqInfo *pTempStaEntry;
16325 VOS_STATUS vosStatus;
16326 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016327 if(!pEntry)
16328 {
16329 //list empty
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016330 smsLog(pMac, LOGE, FL(" List empty, no stats req for PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016331 return;
16332 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016333 while( pEntry )
16334 {
16335 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016336 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
16337 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016338 smsLog(pMac, LOGW, FL("Match found"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016339 if(pTempStaEntry->timerRunning)
16340 {
16341 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
16342 /* If we are not able to stop the timer here, just remove
16343 * the entry from the linked list. Destroy the timer object
16344 * and free the memory in the timer CB
16345 */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016346 if ( vosStatus == VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -070016347 {
16348 /* the timer is successfully stopped */
16349 pTempStaEntry->timerRunning = FALSE;
16350
16351 /* Destroy the timer */
16352 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
16353 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16354 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016355 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016356 }
16357 }
16358 else
16359 {
16360 // the timer could not be stopped. Hence destroy and free the
16361 // memory for the PE stat entry in the timer CB.
16362 pTempStaEntry->timerStopFailed = TRUE;
16363 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016364 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016365
16366 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
16367 {
16368 // Only free the memory if we could stop the timer successfully
16369 if(!pTempStaEntry->timerStopFailed)
16370 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016371 vos_mem_free(pTempStaEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070016372 pTempStaEntry = NULL;
16373 }
16374 break;
16375 }
16376
16377 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
16378 }
16379 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016380 return;
16381}
16382
16383
Jeff Johnsone7245742012-09-05 17:12:55 -070016384void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070016385{
16386
Jeff Johnsone7245742012-09-05 17:12:55 -070016387 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
16388 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
16389 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
16390 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
16391 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
16392 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
16393 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070016394 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070016395 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
16396 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
16397 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
16398 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
16399 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
16400 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070016401 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070016402 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
16403 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070016404
16405}
16406
Jeff Johnson295189b2012-06-20 16:38:30 -070016407void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
16408 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
16409{
16410 tANI_U8 stats[500];
16411 tANI_U8 *pStats = NULL;
16412 tANI_U32 tempMask = 0;
16413 tANI_U8 counter = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016414 if(!callback)
16415 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016416 smsLog(pMac, LOGE, FL("Cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016417 return;
16418 }
16419 if(!statsMask)
16420 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016421 smsLog(pMac, LOGE, FL("Cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016422 return;
16423 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016424 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070016425 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070016426 while(tempMask)
16427 {
16428 if(tempMask & 1)
16429 {
16430 //new stats info from PE, fill up the stats strucutres in PMAC
16431 switch(counter)
16432 {
16433 case eCsrSummaryStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016434 smsLog( pMac, LOG2, FL("Summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016435 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
16436 sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016437 pStats += sizeof(tCsrSummaryStatsInfo);
16438 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016439 case eCsrGlobalClassAStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016440 smsLog( pMac, LOG2, FL("ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016441 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
16442 sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016443 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016444 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016445 case eCsrGlobalClassBStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016446 smsLog( pMac, LOG2, FL("ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016447 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
16448 sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016449 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016450 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016451 case eCsrGlobalClassCStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016452 smsLog( pMac, LOG2, FL("ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016453 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
16454 sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016455 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016456 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016457 case eCsrGlobalClassDStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016458 smsLog( pMac, LOG2, FL("ClassD stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016459 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
16460 sizeof(tCsrGlobalClassDStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016461 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016462 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016463 case eCsrPerStaStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016464 smsLog( pMac, LOG2, FL("PerSta stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016465 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
16466 sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016467 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016468 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016469 default:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016470 smsLog( pMac, LOGE, FL("Unknown stats type and counter %d"), counter);
Jeff Johnson295189b2012-06-20 16:38:30 -070016471 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016472 }
16473 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016474 tempMask >>=1;
16475 counter++;
16476 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016477 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070016478}
16479
Jeff Johnson295189b2012-06-20 16:38:30 -070016480eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
16481{
16482 tListElem *pEntry = NULL;
16483 tListElem *pPrevEntry = NULL;
16484 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
16485 eHalStatus status = eHAL_STATUS_SUCCESS;
16486 VOS_STATUS vosStatus;
16487 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016488 if(!pEntry)
16489 {
16490 //list empty
16491 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016492 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070016493 return status;
16494 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016495 while( pEntry )
16496 {
16497 if(pPrevEntry)
16498 {
16499 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16500 //send up the stats report
16501 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16502 pTempStaEntry->staId, pTempStaEntry->pContext);
16503 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16504 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016505 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016506 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
16507 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016508 pTempStaEntry->pPeStaEntry->numClient--;
16509 //check if we need to delete the entry from peStatsReqList too
16510 if(!pTempStaEntry->pPeStaEntry->numClient)
16511 {
16512 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
16513 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016514 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016515 //check if we need to stop the tl stats timer too
16516 pMac->roam.tlStatsReqInfo.numClient--;
16517 if(!pMac->roam.tlStatsReqInfo.numClient)
16518 {
16519 if(pMac->roam.tlStatsReqInfo.timerRunning)
16520 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016521 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
16522 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016523 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016524 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016525 //we will continue
16526 }
16527 }
16528 pMac->roam.tlStatsReqInfo.periodicity = 0;
16529 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
16530 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016531 if (pTempStaEntry->periodicity)
16532 {
16533 //While creating StaEntry in csrGetStatistics,
16534 //Initializing and starting timer only when periodicity is set.
16535 //So Stop and Destroy timer only when periodicity is set.
16536
Jeff Johnsone7245742012-09-05 17:12:55 -070016537 vos_timer_stop( &pTempStaEntry->timer );
16538 // Destroy the vos timer...
16539 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
16540 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16541 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016542 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070016543 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016544 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016545
Jeff Johnson295189b2012-06-20 16:38:30 -070016546
16547 pPrevEntry = pEntry;
16548 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
16549 }
16550 //the last one
16551 if(pPrevEntry)
16552 {
16553 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16554 //send up the stats report
16555 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16556 pTempStaEntry->staId, pTempStaEntry->pContext);
16557 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16558 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016559 return status;
16560
16561}
16562
Jeff Johnson295189b2012-06-20 16:38:30 -070016563eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
16564 tRequestFullPowerReason *pReason,
16565 tANI_BOOLEAN *pfNeedPower )
16566{
16567 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
16568 tRequestFullPowerReason reason = eSME_REASON_OTHER;
16569 tPmcState pmcState;
16570 eHalStatus status = eHAL_STATUS_SUCCESS;
16571 // TODO : Session info unavailable
16572 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016573 if( pfNeedPower )
16574 {
16575 *pfNeedPower = eANI_BOOLEAN_FALSE;
16576 }
16577 //We only handle CSR commands
16578 if( !(eSmeCsrCommandMask & pCommand->command) )
16579 {
16580 return eHAL_STATUS_SUCCESS;
16581 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016582 //Check PMC state first
16583 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070016584 switch( pmcState )
16585 {
16586 case REQUEST_IMPS:
16587 case IMPS:
16588 if( eSmeCommandScan == pCommand->command )
16589 {
16590 switch( pCommand->u.scanCmd.reason )
16591 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016592#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
16593 case eCsrScanGetLfrResult:
16594#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016595 case eCsrScanGetResult:
16596 case eCsrScanBGScanAbort:
16597 case eCsrScanBGScanEnable:
16598 case eCsrScanGetScanChnInfo:
16599 //Internal process, no need for full power
16600 fNeedFullPower = eANI_BOOLEAN_FALSE;
16601 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016602 default:
16603 //Other scans are real scan, ask for power
16604 fNeedFullPower = eANI_BOOLEAN_TRUE;
16605 break;
16606 } //switch
16607 }
16608 else
16609 {
16610 //ask for power for roam and status change
16611 fNeedFullPower = eANI_BOOLEAN_TRUE;
16612 }
16613 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016614 case REQUEST_BMPS:
16615 case BMPS:
16616 case REQUEST_START_UAPSD:
16617 case UAPSD:
16618 //We treat WOWL same as BMPS
16619 case REQUEST_ENTER_WOWL:
16620 case WOWL:
16621 if( eSmeCommandRoam == pCommand->command )
16622 {
16623 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
16624 tCsrScanResult *pScanResult;
16625 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070016626 switch ( pCommand->u.roamCmd.roamReason )
16627 {
16628 case eCsrForcedDisassoc:
16629 case eCsrForcedDisassocMICFailure:
16630 reason = eSME_LINK_DISCONNECTED_BY_HDD;
16631 fNeedFullPower = eANI_BOOLEAN_TRUE;
16632 break;
16633 case eCsrSmeIssuedDisassocForHandoff:
16634 case eCsrForcedDeauth:
16635 case eCsrHddIssuedReassocToSameAP:
16636 case eCsrSmeIssuedReassocToSameAP:
16637 fNeedFullPower = eANI_BOOLEAN_TRUE;
16638 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016639 case eCsrCapsChange:
16640 fNeedFullPower = eANI_BOOLEAN_TRUE;
16641 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016642 default:
16643 //Check whether the profile is already connected. If so, no need for full power
16644 //Note: IBSS is ignored for now because we don't support powersave in IBSS
16645 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
16646 {
16647 //Only need to check the first one
16648 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
16649 if( pEntry )
16650 {
16651 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
16652#if 0
16653 // TODO : Session Specific info pConnectBssDesc
16654 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
16655 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
16656 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
16657 {
16658 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
16659 // with Authenticating first. To force this, stop the current association (Disassociate) and
16660 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
16661 // a new Association.
16662 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
16663 {
16664 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
16665 {
16666 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
16667 //No need for full power
16668 //Set the flag so the code later can avoid to do the above
16669 //check again.
16670 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
16671 break;
16672 }
16673 }
16674 }
16675#endif
16676 }
16677 }
16678 //If we are here, full power is needed
16679 fNeedFullPower = eANI_BOOLEAN_TRUE;
16680 break;
16681 }
16682 }
16683 else if( eSmeCommandWmStatusChange == pCommand->command )
16684 {
16685 //need full power for all
16686 fNeedFullPower = eANI_BOOLEAN_TRUE;
16687 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
16688 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016689#ifdef FEATURE_WLAN_TDLS
16690 else if( eSmeCommandTdlsAddPeer == pCommand->command )
16691 {
16692 //TDLS link is getting established. need full power
16693 fNeedFullPower = eANI_BOOLEAN_TRUE;
16694 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
16695 }
16696#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016697 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016698 case REQUEST_STOP_UAPSD:
16699 case REQUEST_EXIT_WOWL:
16700 if( eSmeCommandRoam == pCommand->command )
16701 {
16702 fNeedFullPower = eANI_BOOLEAN_TRUE;
16703 switch ( pCommand->u.roamCmd.roamReason )
16704 {
16705 case eCsrForcedDisassoc:
16706 case eCsrForcedDisassocMICFailure:
16707 reason = eSME_LINK_DISCONNECTED_BY_HDD;
16708 break;
16709 default:
16710 break;
16711 }
16712 }
16713 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016714 case STOPPED:
16715 case REQUEST_STANDBY:
16716 case STANDBY:
16717 case LOW_POWER:
16718 //We are not supposed to do anything
Sushant Kaushike0d2cce2014-04-10 14:36:07 +053016719 smsLog( pMac, LOGE, FL( "cannot process because PMC is in"
16720 " stopped/standby state %s (%d)" ),
16721 sme_PmcStatetoString(pmcState), 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));
Abhishek Singh11aa2902014-05-05 11:52:52 +053017216
17217 if( NULL == pMsg )
17218 {
17219 smsLog(pMac, LOGE, FL("PMsg is NULL "));
17220 return eHAL_STATUS_FAILURE;
17221 }
Sandeep Puligilla332ea912014-02-04 00:16:24 +053017222 vos_mem_zero((void *)pMsg, sizeof(tSirSmeHT40OBSSStopScanInd));
17223 pMsg->messageType = eWNI_SME_HT40_STOP_OBSS_SCAN_IND;
17224 pMsg->length = sizeof(tANI_U8);
17225 pMsg->seesionId = sessionId;
17226 status = palSendMBMessage(pMac->hHdd, pMsg);
17227 if (!HAL_STATUS_SUCCESS(status))
17228 {
17229 smsLog(pMac, LOGE, FL(" csr STOP OBSS SCAN Fail %d "), status);
17230 //pMsg is freed by palSendMBMessage
17231 }
17232 }
17233 else
17234 {
17235 smsLog(pMac, LOGE, FL(" OBSS STOP OBSS SCAN is not supported"));
17236 status = eHAL_STATUS_FAILURE;
17237 }
17238 return status;
17239}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017240/* Returns whether a session is in VOS_STA_MODE...or not */
17241tANI_BOOLEAN csrRoamIsStaMode(tpAniSirGlobal pMac, tANI_U32 sessionId)
17242{
17243 tCsrRoamSession *pSession = NULL;
17244 pSession = CSR_GET_SESSION ( pMac, sessionId );
17245 if(!pSession)
17246 {
17247 smsLog(pMac, LOGE, FL(" %s: session %d not found "), __func__, sessionId);
17248 return eANI_BOOLEAN_FALSE;
17249 }
17250 if ( !CSR_IS_SESSION_VALID ( pMac, sessionId ) )
17251 {
17252 smsLog(pMac, LOGE, FL(" %s: Inactive session"), __func__);
17253 return eANI_BOOLEAN_FALSE;
17254 }
17255 if ( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
17256 {
17257 return eANI_BOOLEAN_FALSE;
17258 }
17259 /* There is a possibility that the above check may fail,because
17260 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
17261 * when it is connected.So,we may sneak through the above check even
17262 * if we are not a STA mode INFRA station. So, if we sneak through
17263 * the above condition, we can use the following check if we are
17264 * really in STA Mode.*/
17265
17266 if ( NULL != pSession->pCurRoamProfile )
17267 {
17268 if ( pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE )
17269 {
17270 return eANI_BOOLEAN_TRUE;
17271 } else {
17272 smsLog(pMac, LOGE, FL(" %s: pCurRoamProfile is NULL\n"), __func__);
17273 return eANI_BOOLEAN_FALSE;
17274 }
17275 }
17276
17277 return eANI_BOOLEAN_FALSE;
17278}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017279
17280#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
17281eHalStatus csrHandoffRequest(tpAniSirGlobal pMac,
17282 tCsrHandoffRequest *pHandoffInfo)
17283{
17284 eHalStatus status = eHAL_STATUS_SUCCESS;
17285 vos_msg_t msg;
17286
17287 tAniHandoffReq *pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053017288 pMsg = vos_mem_malloc(sizeof(tAniHandoffReq));
17289 if ( NULL == pMsg )
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017290 {
17291 smsLog(pMac, LOGE, " csrHandoffRequest: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053017292 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017293 }
17294 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_HANDOFF_REQ);
17295 pMsg->msgLen = (tANI_U16)sizeof(tAniHandoffReq);
17296 pMsg->sessionId = pMac->roam.neighborRoamInfo.csrSessionId;
17297 pMsg->channel = pHandoffInfo->channel;
Kiet Lam64c1b492013-07-12 13:56:44 +053017298 vos_mem_copy(pMsg->bssid,
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017299 pHandoffInfo->bssid,
17300 6);
17301 msg.type = eWNI_SME_HANDOFF_REQ;
17302 msg.bodyptr = pMsg;
17303 msg.reserved = 0;
17304 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
17305 {
17306 smsLog(pMac, LOGE, " csrHandoffRequest failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053017307 vos_mem_free((void *)pMsg);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017308 status = eHAL_STATUS_FAILURE;
17309 }
17310 return status;
17311}
17312#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017313
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017314
17315#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017316/* ---------------------------------------------------------------------------
17317 \fn csrSetCCKMIe
17318 \brief This function stores the CCKM IE passed by the supplicant in a place holder
17319 data structure and this IE will be packed inside reassociation request
17320 \param pMac - pMac global structure
17321 \param sessionId - Current session id
17322 \param pCckmIe - pointer to CCKM IE data
17323 \param ccKmIeLen - length of the CCKM IE
17324 \- return Success or failure
17325 -------------------------------------------------------------------------*/
17326VOS_STATUS csrSetCCKMIe(tpAniSirGlobal pMac, const tANI_U8 sessionId,
17327 const tANI_U8 *pCckmIe,
17328 const tANI_U8 ccKmIeLen)
17329{
17330 eHalStatus status = eHAL_STATUS_SUCCESS;
17331 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17332
17333 if (!pSession)
17334 {
17335 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17336 return eHAL_STATUS_FAILURE;
17337 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053017338 vos_mem_copy(pSession->suppCckmIeInfo.cckmIe, pCckmIe, ccKmIeLen);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017339 pSession->suppCckmIeInfo.cckmIeLen = ccKmIeLen;
17340 return status;
17341}
17342
17343/* ---------------------------------------------------------------------------
17344 \fn csrRoamReadTSF
17345 \brief This function reads the TSF; and also add the time elapsed since last beacon or
17346 probe response reception from the hand off AP to arrive at the latest TSF value.
17347 \param pMac - pMac global structure
17348 \param pTimestamp - output TSF timestamp
17349 \- return Success or failure
17350 -------------------------------------------------------------------------*/
17351VOS_STATUS csrRoamReadTSF(tpAniSirGlobal pMac, tANI_U8 *pTimestamp)
17352{
17353 eHalStatus status = eHAL_STATUS_SUCCESS;
17354 tCsrNeighborRoamBSSInfo handoffNode;
17355 tANI_U32 timer_diff = 0;
17356 tANI_U32 timeStamp[2];
17357 tpSirBssDescription pBssDescription = NULL;
17358
17359 csrNeighborRoamGetHandoffAPInfo(pMac, &handoffNode);
17360 pBssDescription = handoffNode.pBssDescription;
17361
17362 // Get the time diff in milli seconds
17363 timer_diff = vos_timer_get_system_time() - pBssDescription->scanSysTimeMsec;
17364 // Convert msec to micro sec timer
17365 timer_diff = (tANI_U32)(timer_diff * SYSTEM_TIME_MSEC_TO_USEC);
17366
17367 timeStamp[0] = pBssDescription->timeStamp[0];
17368 timeStamp[1] = pBssDescription->timeStamp[1];
17369
17370 UpdateCCKMTSF(&(timeStamp[0]), &(timeStamp[1]), &timer_diff);
17371
Kiet Lamf2f201e2013-11-16 21:24:16 +053017372 vos_mem_copy(pTimestamp, (void *) &timeStamp[0],
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017373 sizeof (tANI_U32) * 2);
17374 return status;
17375}
17376
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017377#endif /*FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017378