blob: 1cd8194bf29c6ee64e957b426ac08388160d7f79 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lam0fb93dd2014-02-19 00:32:59 -08002 * Copyright (c) 2012-2014 The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
23 * Copyright (c) 2012-2014 Qualcomm Atheros, Inc.
24 * All Rights Reserved.
25 * Qualcomm Atheros Confidential and Proprietary.
26 *
27 */
28
29
Jeff Johnson295189b2012-06-20 16:38:30 -070030/** ------------------------------------------------------------------------- *
31 ------------------------------------------------------------------------- *
Jeff Johnsone7245742012-09-05 17:12:55 -070032
Jeff Johnson295189b2012-06-20 16:38:30 -070033
34 \file csrApiRoam.c
35
36 Implementation for the Common Roaming interfaces.
37
Kiet Lamaa8e15a2014-02-11 23:30:06 -080038 Copyright (C) 2008 Qualcomm, Incorporated
39
Jeff Johnson295189b2012-06-20 16:38:30 -070040
41 ========================================================================== */
Jeff Johnson295189b2012-06-20 16:38:30 -070042/*===========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -070043 EDIT HISTORY FOR FILE
44
Jeff Johnson295189b2012-06-20 16:38:30 -070045 This section contains comments describing changes made to the module.
46 Notice that changes are listed in reverse chronological order.
47
Jeff Johnson295189b2012-06-20 16:38:30 -070048 when who what, where, why
49---------- --- --------------------------------------------------------
5006/03/10 js Added support to hostapd driven
51 * deauth/disassoc/mic failure
Jeff Johnson295189b2012-06-20 16:38:30 -070052===========================================================================*/
Jeff Johnson295189b2012-06-20 16:38:30 -070053#include "aniGlobal.h" //for tpAniSirGlobal
54#include "wlan_qct_wda.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070055#include "halMsgApi.h" //for HAL_STA_INVALID_IDX.
Jeff Johnsone7245742012-09-05 17:12:55 -070056#include "limUtils.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070057#include "palApi.h"
58#include "csrInsideApi.h"
59#include "smsDebug.h"
60#include "logDump.h"
61#include "smeQosInternal.h"
62#include "wlan_qct_tl.h"
63#include "smeInside.h"
64#include "vos_diag_core_event.h"
65#include "vos_diag_core_log.h"
66#include "csrApi.h"
67#include "pmc.h"
68#include "vos_nvitem.h"
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053069#include "macTrace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070070#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
71#include "csrNeighborRoam.h"
72#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080073#if defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD)
74#include "csrEse.h"
75#endif /* FEATURE_WLAN_ESE && !FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -070076#define CSR_NUM_IBSS_START_CHANNELS_50 4
77#define CSR_NUM_IBSS_START_CHANNELS_24 3
78#define CSR_DEF_IBSS_START_CHANNEL_50 36
79#define CSR_DEF_IBSS_START_CHANNEL_24 1
Srikant Kuppa2062aaf2012-12-27 17:36:41 -080080#define CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD ( 5 * PAL_TIMER_TO_SEC_UNIT ) // 5 seconds, for WPA, WPA2, CCKM
Jeff Johnson295189b2012-06-20 16:38:30 -070081#define CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD ( 120 * PAL_TIMER_TO_SEC_UNIT ) // 120 seconds, for WPS
82/*---------------------------------------------------------------------------
83 OBIWAN recommends [8 10]% : pick 9%
84---------------------------------------------------------------------------*/
85#define CSR_VCC_UL_MAC_LOSS_THRESHOLD 9
Jeff Johnson295189b2012-06-20 16:38:30 -070086/*---------------------------------------------------------------------------
87 OBIWAN recommends -85dBm
88---------------------------------------------------------------------------*/
89#define CSR_VCC_RSSI_THRESHOLD 80
90#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD 500 //ms
91#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS 2000 //ms
92#define CSR_MIN_TL_STAT_QUERY_PERIOD 500 //ms
93#define CSR_DIAG_LOG_STAT_PERIOD 3000 //ms
Jeff Johnson295189b2012-06-20 16:38:30 -070094//We use constatnt 4 here
95//This macro returns true when higher AC parameter is bigger than lower AC for a difference
96//The bigger the number, the less chance of TX
97//It must put lower AC as the first parameter.
98#define SME_DETECT_AC_WEIGHT_DIFF(loAC, hiAC) (v_BOOL_t)(((hiAC) > (loAC)) ? (((hiAC)-(loAC)) > 4) : 0)
Jeff Johnson295189b2012-06-20 16:38:30 -070099//Flag to send/do not send disassoc frame over the air
100#define CSR_DONT_SEND_DISASSOC_OVER_THE_AIR 1
Jeff Johnson295189b2012-06-20 16:38:30 -0700101#define RSSI_HACK_BMPS (-40)
Jeff Johnsone7245742012-09-05 17:12:55 -0700102#define MAX_CB_VALUE_IN_INI (2)
103
Srinivas Girigowda577ed652013-08-14 11:38:29 -0700104#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
105static tANI_BOOLEAN bRoamScanOffloadStarted = VOS_FALSE;
106#endif
107
Jeff Johnson295189b2012-06-20 16:38:30 -0700108/*--------------------------------------------------------------------------
109 Static Type declarations
110 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800111static tCsrRoamSession csrRoamRoamSession[CSR_ROAM_SESSION_MAX];
Srinivas Girigowdade697412013-02-14 16:31:48 -0800112
Jeff Johnson295189b2012-06-20 16:38:30 -0700113/*--------------------------------------------------------------------------
114 Type declarations
115 ------------------------------------------------------------------------*/
116#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700117int diagAuthTypeFromCSRType(eCsrAuthType authType)
118{
119 int n = AUTH_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700120 switch(authType)
121 {
122 case eCSR_AUTH_TYPE_SHARED_KEY:
123 n = AUTH_SHARED;
124 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700125 case eCSR_AUTH_TYPE_WPA:
126 n = AUTH_WPA_EAP;
127 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700128 case eCSR_AUTH_TYPE_WPA_PSK:
129 n = AUTH_WPA_PSK;
130 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700131 case eCSR_AUTH_TYPE_RSN:
132 n = AUTH_WPA2_EAP;
133 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700134 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700135#ifdef WLAN_FEATURE_11W
136 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
137#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700138 n = AUTH_WPA2_PSK;
139 break;
140#ifdef FEATURE_WLAN_WAPI
141 case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE:
142 n = AUTH_WAPI_CERT;
143 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700144 case eCSR_AUTH_TYPE_WAPI_WAI_PSK:
145 n = AUTH_WAPI_PSK;
146 break;
147#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -0700148 default:
149 break;
150 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700151 return (n);
152}
Jeff Johnson295189b2012-06-20 16:38:30 -0700153int diagEncTypeFromCSRType(eCsrEncryptionType encType)
154{
155 int n = ENC_MODE_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700156 switch(encType)
157 {
158 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
159 case eCSR_ENCRYPT_TYPE_WEP40:
160 n = ENC_MODE_WEP40;
161 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700162 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
163 case eCSR_ENCRYPT_TYPE_WEP104:
164 n = ENC_MODE_WEP104;
165 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700166 case eCSR_ENCRYPT_TYPE_TKIP:
167 n = ENC_MODE_TKIP;
168 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700169 case eCSR_ENCRYPT_TYPE_AES:
170 n = ENC_MODE_AES;
171 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700172#ifdef FEATURE_WLAN_WAPI
173 case eCSR_ENCRYPT_TYPE_WPI:
174 n = ENC_MODE_SMS4;
175 break;
176#endif /* FEATURE_WLAN_WAPI */
177 default:
178 break;
179 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700180 return (n);
181}
Jeff Johnson295189b2012-06-20 16:38:30 -0700182#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700183static const tANI_U8 csrStartIbssChannels50[ CSR_NUM_IBSS_START_CHANNELS_50 ] = { 36, 40, 44, 48};
184static const tANI_U8 csrStartIbssChannels24[ CSR_NUM_IBSS_START_CHANNELS_24 ] = { 1, 6, 11 };
Jeff Johnson295189b2012-06-20 16:38:30 -0700185static void initConfigParam(tpAniSirGlobal pMac);
186static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
187 eCsrRoamCompleteResult Result, void *Context );
188static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId,
189 tCsrRoamProfile *pProfile,
190 tANI_BOOLEAN *pfSameIbss );
191static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirSmeNewBssInfo *pNewBss );
192static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -0700193 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes);
194static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700195eHalStatus csrInitGetChannels(tpAniSirGlobal pMac);
196static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result );
197eHalStatus csrRoamOpen(tpAniSirGlobal pMac);
198eHalStatus csrRoamClose(tpAniSirGlobal pMac);
199void csrRoamMICErrorTimerHandler(void *pv);
200void csrRoamTKIPCounterMeasureTimerHandler(void *pv);
201tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2);
202
203static eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval);
204static eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId);
205static void csrRoamRoamingTimerHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700206eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval);
207eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac);
208static void csrRoamWaitForKeyTimeOutHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700209static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnsone7245742012-09-05 17:12:55 -0700210static eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700211static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo );
212eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
213 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
214 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
215 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
216 tANI_U8 *pKeyRsc );
217static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
218 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes,
219 tCsrRoamProfile *pProfile );
220void csrRoamStatisticsTimerHandler(void *pv);
221void csrRoamStatsGlobalClassDTimerHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700222static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid);
223VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
224 v_U8_t rssiNotification,
225 void * context);
226static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId);
227void csrRoamVccTrigger(tpAniSirGlobal pMac);
228eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId);
229/*
230 pStaEntry is no longer invalid upon the return of this function.
231*/
232static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700233static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,tANI_U8 operationChn, eCsrBand *pBand );
Jeff Johnson295189b2012-06-20 16:38:30 -0700234static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700235tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
236 tDblLinkList *pStaList,
237 tCsrStatsClientReqInfo *pStaEntry);
238void csrRoamStatsClientTimerHandler(void *pv);
239tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
240 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId);
241void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
242 tCsrStatsCallback callback, tANI_U8 staId, void *pContext);
Jeff Johnsone7245742012-09-05 17:12:55 -0700243void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats);
Jeff Johnson295189b2012-06-20 16:38:30 -0700244void csrRoamTlStatsTimerHandler(void *pv);
245void csrRoamPeStatsTimerHandler(void *pv);
246tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
247void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry);
248tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
249eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac);
250static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac );
251static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc );
252static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId );
253static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
254 tCsrRoamSetKey *pSetKey, tANI_U32 roamId );
255//static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand );
256static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
257void csrRoamReissueRoamCommand(tpAniSirGlobal pMac);
258#ifdef FEATURE_WLAN_BTAMP_UT_RF
259void csrRoamJoinRetryTimerHandler(void *pv);
260#endif
261extern void SysProcessMmhMsg(tpAniSirGlobal pMac, tSirMsgQ* pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700262extern void btampEstablishLogLinkHdlr(void* pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700263static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700264void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand);
Jeff Johnson295189b2012-06-20 16:38:30 -0700265
266//Initialize global variables
267static void csrRoamInitGlobals(tpAniSirGlobal pMac)
268{
269 if(pMac)
270 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800271 vos_mem_zero(&csrRoamRoamSession, sizeof(csrRoamRoamSession));
272 pMac->roam.roamSession = csrRoamRoamSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700273 }
274 return;
275}
276
Jeff Johnson295189b2012-06-20 16:38:30 -0700277static void csrRoamDeInitGlobals(tpAniSirGlobal pMac)
278{
279 if(pMac)
280 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800281 pMac->roam.roamSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700282 }
283 return;
284}
Jeff Johnson295189b2012-06-20 16:38:30 -0700285eHalStatus csrOpen(tpAniSirGlobal pMac)
286{
287 eHalStatus status = eHAL_STATUS_SUCCESS;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530288#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700289 static uNvTables nvTables;
290 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700291 v_REGDOMAIN_t regId;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530292#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700293 tANI_U32 i;
294
295 do
296 {
297 /* Initialize CSR Roam Globals */
298 csrRoamInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700299 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
300 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i);
301
302 initConfigParam(pMac);
303 if(!HAL_STATUS_SUCCESS((status = csrScanOpen(pMac))))
304 break;
305 if(!HAL_STATUS_SUCCESS((status = csrRoamOpen(pMac))))
306 break;
307 pMac->roam.nextRoamId = 1; //Must not be 0
308 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.statsClientReqList)))
309 break;
310 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.peStatsReqList)))
311 break;
312 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.roamCmdPendingList)))
313 break;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530314
315#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700316 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
317 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
318 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530319 vos_mem_copy(pMac->scan.countryCodeDefault, nvTables.defaultCountryTable.countryCode,
320 WNI_CFG_COUNTRY_CODE_LEN);
321 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700322 }
323 else
324 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800325 smsLog( pMac, LOGE, FL(" fail to get NV_FIELD_IMAGE") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700326 //hardcoded for now
327 pMac->scan.countryCodeDefault[0] = 'U';
328 pMac->scan.countryCodeDefault[1] = 'S';
329 pMac->scan.countryCodeDefault[2] = 'I';
330 //status = eHAL_STATUS_SUCCESS;
331 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700332 smsLog( pMac, LOG1, FL(" country Code from nvRam %.2s"), pMac->scan.countryCodeDefault );
Kiet Lam6c583332013-10-14 05:37:09 +0530333
334 if (!('0' == pMac->scan.countryCodeDefault[0] &&
335 '0' == pMac->scan.countryCodeDefault[1]))
336 {
337 csrGetRegulatoryDomainForCountry(pMac, pMac->scan.countryCodeDefault,
338 &regId, COUNTRY_NV);
339 }
340 else
341 {
342 regId = REGDOMAIN_WORLD;
343 }
Abhishek Singha306a442013-11-07 18:39:01 +0530344 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700345 pMac->scan.domainIdDefault = regId;
346 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Kiet Lam64c1b492013-07-12 13:56:44 +0530347 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
348 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700349 status = csrInitGetChannels( pMac );
Mihir Shetee1093ba2014-01-21 20:13:32 +0530350#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700351 }while(0);
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530352
Jeff Johnson295189b2012-06-20 16:38:30 -0700353 return (status);
354}
355
Mihir Shetee1093ba2014-01-21 20:13:32 +0530356/* --------------------------------------------------------------------------
357 \fn csrInitChannels
358 \brief This function must be called to initialize CSR channel lists
359 \return eHalStatus
360 ----------------------------------------------------------------------------*/
361eHalStatus csrInitChannels(tpAniSirGlobal pMac)
362{
363 eHalStatus status = eHAL_STATUS_SUCCESS;
364 static uNvTables nvTables;
365 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530366 v_REGDOMAIN_t regId = REGDOMAIN_WORLD;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530367
368 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
369 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
370 {
371 vos_mem_copy(pMac->scan.countryCodeDefault,
372 nvTables.defaultCountryTable.countryCode,
373 WNI_CFG_COUNTRY_CODE_LEN);
374 }
375 else
376 {
377 smsLog( pMac, LOGE, FL(" fail to get NV_FIELD_IMAGE") );
378 //hardcoded for now
379 pMac->scan.countryCodeDefault[0] = 'U';
380 pMac->scan.countryCodeDefault[1] = 'S';
381 pMac->scan.countryCodeDefault[2] = 'I';
382 }
383 smsLog( pMac, LOG1, FL(" country Code from nvRam %.2s"), pMac->scan.countryCodeDefault );
384
Mihir Shetee1093ba2014-01-21 20:13:32 +0530385 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
386 pMac->scan.domainIdDefault = regId;
387 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
388 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
389 WNI_CFG_COUNTRY_CODE_LEN);
Agrawal Ashish0b6984f2014-04-05 18:35:45 +0530390 vos_mem_copy(pMac->scan.countryCodeElected, pMac->scan.countryCodeDefault,
391 WNI_CFG_COUNTRY_CODE_LEN);
Mihir Shetee1093ba2014-01-21 20:13:32 +0530392 status = csrInitGetChannels( pMac );
Agrawal Ashish0b6984f2014-04-05 18:35:45 +0530393 csrClearVotesForCountryInfo(pMac);
Mihir Shetee1093ba2014-01-21 20:13:32 +0530394
395 return status;
396}
397
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530398eHalStatus csrInitChannelsForCC(tpAniSirGlobal pMac)
399{
400 eHalStatus status = eHAL_STATUS_SUCCESS;
401 v_REGDOMAIN_t regId = REGDOMAIN_WORLD;
402
403 if (!('0' == pMac->scan.countryCodeDefault[0] &&
404 '0' == pMac->scan.countryCodeDefault[1]))
405 {
406 csrGetRegulatoryDomainForCountry(pMac, pMac->scan.countryCodeDefault,
407 &regId, COUNTRY_NV);
408
409 }
410 else
411 {
412 return status;
413 }
414 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
415 pMac->scan.domainIdDefault = regId;
416 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
417 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
418 WNI_CFG_COUNTRY_CODE_LEN);
419 status = csrInitGetChannels( pMac );
420 return status;
421}
422
Jeff Johnson295189b2012-06-20 16:38:30 -0700423eHalStatus csrSetRegInfo(tHalHandle hHal, tANI_U8 *apCntryCode)
424{
425 eHalStatus status = eHAL_STATUS_SUCCESS;
426 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
427 v_REGDOMAIN_t regId;
428 v_U8_t cntryCodeLength;
Jeff Johnson295189b2012-06-20 16:38:30 -0700429 if(NULL == apCntryCode)
430 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +0530431 smsLog( pMac, LOGE, FL(" Invalid country Code Pointer") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700432 return eHAL_STATUS_FAILURE;
433 }
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +0530434 smsLog( pMac, LOG1, FL(" country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700435 /* To get correct Regulatory domain from NV table
436 * 2 character Country code should be used
437 * 3rd charater is optional for indoor/outdoor setting */
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700438 cntryCodeLength = WNI_CFG_COUNTRY_CODE_LEN;
439/*
Jeff Johnson295189b2012-06-20 16:38:30 -0700440 cntryCodeLength = strlen(apCntryCode);
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700441
442 if (cntryCodeLength > WNI_CFG_COUNTRY_CODE_LEN)
443 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800444 smsLog( pMac, LOGW, FL(" Invalid Country Code Length") );
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700445 return eHAL_STATUS_FAILURE;
446 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700447*/
Kiet Lam6c583332013-10-14 05:37:09 +0530448 status = csrGetRegulatoryDomainForCountry(pMac, apCntryCode, &regId,
449 COUNTRY_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -0700450 if (status != eHAL_STATUS_SUCCESS)
451 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700452 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700453 return status;
454 }
Abhishek Singha306a442013-11-07 18:39:01 +0530455 status = WDA_SetRegDomain(hHal, regId, eSIR_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700456 if (status != eHAL_STATUS_SUCCESS)
457 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700458 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700459 return status;
460 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700461 pMac->scan.domainIdDefault = regId;
462 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Jeff Johnson295189b2012-06-20 16:38:30 -0700463 /* Clear CC field */
Kiet Lam64c1b492013-07-12 13:56:44 +0530464 vos_mem_set(pMac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN, 0);
465
Jeff Johnson295189b2012-06-20 16:38:30 -0700466 /* Copy 2 or 3 bytes country code */
Kiet Lam64c1b492013-07-12 13:56:44 +0530467 vos_mem_copy(pMac->scan.countryCodeDefault, apCntryCode, cntryCodeLength);
468
Jeff Johnson295189b2012-06-20 16:38:30 -0700469 /* If 2 bytes country code, 3rd byte must be filled with space */
470 if((WNI_CFG_COUNTRY_CODE_LEN - 1) == cntryCodeLength)
471 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530472 vos_mem_set(pMac->scan.countryCodeDefault + 2, 1, 0x20);
Jeff Johnson295189b2012-06-20 16:38:30 -0700473 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530474 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
475 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700476 status = csrInitGetChannels( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -0700477 return status;
478}
Jeff Johnson295189b2012-06-20 16:38:30 -0700479eHalStatus csrSetChannels(tHalHandle hHal, tCsrConfigParam *pParam )
480{
481 eHalStatus status = eHAL_STATUS_SUCCESS;
482 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
483 tANI_U8 index = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +0530484 vos_mem_copy(pParam->Csr11dinfo.countryCode, pMac->scan.countryCodeCurrent,
485 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700486 for ( index = 0; index < pMac->scan.base20MHzChannels.numChannels ; index++)
487 {
488 pParam->Csr11dinfo.Channels.channelList[index] = pMac->scan.base20MHzChannels.channelList[ index ];
489 pParam->Csr11dinfo.ChnPower[index].firstChannel = pMac->scan.base20MHzChannels.channelList[ index ];
490 pParam->Csr11dinfo.ChnPower[index].numChannels = 1;
491 pParam->Csr11dinfo.ChnPower[index].maxtxPower = pMac->scan.defaultPowerTable[index].pwr;
492 }
493 pParam->Csr11dinfo.Channels.numChannels = pMac->scan.base20MHzChannels.numChannels;
494
495 return status;
496}
Jeff Johnson295189b2012-06-20 16:38:30 -0700497eHalStatus csrClose(tpAniSirGlobal pMac)
498{
499 eHalStatus status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800500
Jeff Johnson295189b2012-06-20 16:38:30 -0700501 csrRoamClose(pMac);
502 csrScanClose(pMac);
503 csrLLClose(&pMac->roam.statsClientReqList);
504 csrLLClose(&pMac->roam.peStatsReqList);
505 csrLLClose(&pMac->roam.roamCmdPendingList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700506 /* DeInit Globals */
507 csrRoamDeInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700508 return (status);
509}
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530510
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800511eHalStatus csrUpdateChannelList(tpAniSirGlobal pMac)
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530512{
513 tSirUpdateChanList *pChanList;
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800514 tCsrScanStruct *pScan = &pMac->scan;
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530515 tANI_U8 numChan = pScan->base20MHzChannels.numChannels;
516 tANI_U32 bufLen = sizeof(tSirUpdateChanList) +
517 (sizeof(tSirUpdateChanParam) * (numChan - 1));
518 vos_msg_t msg;
519 tANI_U8 i;
520
521 pChanList = (tSirUpdateChanList *) vos_mem_malloc(bufLen);
522 if (!pChanList)
523 {
524 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
525 "Failed to allocate memory for tSirUpdateChanList");
526 return eHAL_STATUS_FAILED_ALLOC;
527 }
528
529 msg.type = WDA_UPDATE_CHAN_LIST_REQ;
530 msg.reserved = 0;
531 msg.bodyptr = pChanList;
532 pChanList->numChan = numChan;
533 for (i = 0; i < pChanList->numChan; i++)
534 {
535 pChanList->chanParam[i].chanId = pScan->defaultPowerTable[i].chanId;
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800536 pChanList->chanParam[i].pwr = cfgGetRegulatoryMaxTransmitPower(pMac,
537 pScan->defaultPowerTable[i].chanId);
538 if (vos_nv_getChannelEnabledState(pChanList->chanParam[i].chanId) ==
539 NV_CHANNEL_DFS)
540 pChanList->chanParam[i].dfsSet = VOS_TRUE;
541 else
542 pChanList->chanParam[i].dfsSet = VOS_FALSE;
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530543 }
544
545 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
546 {
547 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
548 "%s: Failed to post msg to WDA", __func__);
549 vos_mem_free(pChanList);
550 return eHAL_STATUS_FAILURE;
551 }
552
553 return eHAL_STATUS_SUCCESS;
554}
555
Jeff Johnson295189b2012-06-20 16:38:30 -0700556eHalStatus csrStart(tpAniSirGlobal pMac)
557{
558 eHalStatus status = eHAL_STATUS_SUCCESS;
559 tANI_U32 i;
560
561 do
562 {
563 //save the global vos context
564 pMac->roam.gVosContext = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
565 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
566 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, i );
567
568 status = csrRoamStart(pMac);
569 if(!HAL_STATUS_SUCCESS(status)) break;
570 pMac->scan.f11dInfoApplied = eANI_BOOLEAN_FALSE;
571 status = pmcRegisterPowerSaveCheck(pMac, csrCheckPSReady, pMac);
572 if(!HAL_STATUS_SUCCESS(status)) break;
573 pMac->roam.sPendingCommands = 0;
574 csrScanEnable(pMac);
575#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
576 status = csrNeighborRoamInit(pMac);
577#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
578 pMac->roam.tlStatsReqInfo.numClient = 0;
579 pMac->roam.tlStatsReqInfo.periodicity = 0;
580 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
581 //init the link quality indication also
582 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_MIN_IND;
583 if(!HAL_STATUS_SUCCESS(status))
584 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800585 smsLog(pMac, LOGW, " csrStart: Couldn't Init HO control blk ");
Jeff Johnson295189b2012-06-20 16:38:30 -0700586 break;
587 }
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800588#ifdef QCA_WIFI_2_0
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530589 if (pMac->fScanOffload)
590 {
591 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
592 "Scan offload is enabled, update default chan list");
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800593 status = csrUpdateChannelList(pMac);
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530594 }
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800595#else
596 status = csrUpdateChannelList(pMac);
597#endif
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530598
Jeff Johnson295189b2012-06-20 16:38:30 -0700599 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700600#if defined(ANI_LOGDUMP)
601 csrDumpInit(pMac);
602#endif //#if defined(ANI_LOGDUMP)
Jeff Johnson295189b2012-06-20 16:38:30 -0700603 return (status);
604}
605
Kiet Lama72a2322013-11-15 11:18:11 +0530606eHalStatus csrStop(tpAniSirGlobal pMac, tHalStopType stopType)
Jeff Johnson295189b2012-06-20 16:38:30 -0700607{
608 tANI_U32 sessionId;
609 tANI_U32 i;
610
611 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
612 {
613 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
614 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700615 csrScanDisable(pMac);
616 pMac->scan.fCancelIdleScan = eANI_BOOLEAN_FALSE;
617 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700618 csrLLPurge( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_TRUE );
619
620#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
621 csrNeighborRoamClose(pMac);
622#endif
623 csrScanFlushResult(pMac); //Do we want to do this?
Jeff Johnson295189b2012-06-20 16:38:30 -0700624 // deregister from PMC since we register during csrStart()
625 // (ignore status since there is nothing we can do if it fails)
626 (void) pmcDeregisterPowerSaveCheck(pMac, csrCheckPSReady);
Jeff Johnson295189b2012-06-20 16:38:30 -0700627 //Reset the domain back to the deault
628 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800629 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700630
631 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
632 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530633 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i );
Jeff Johnson295189b2012-06-20 16:38:30 -0700634 pMac->roam.curSubState[i] = eCSR_ROAM_SUBSTATE_NONE;
635 }
636
Kiet Lama72a2322013-11-15 11:18:11 +0530637#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
638 /* When HAL resets all the context information
639 * in HAL is lost, so we might need to send the
640 * scan offload request again when it comes
641 * out of reset for scan offload to be functional
642 */
643 if (HAL_STOP_TYPE_SYS_RESET == stopType)
644 {
645 bRoamScanOffloadStarted = VOS_FALSE;
646 }
647#endif
648
Jeff Johnson295189b2012-06-20 16:38:30 -0700649 return (eHAL_STATUS_SUCCESS);
650}
651
Jeff Johnson295189b2012-06-20 16:38:30 -0700652eHalStatus csrReady(tpAniSirGlobal pMac)
653{
654 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700655 csrScanGetSupportedChannels( pMac );
656 //WNI_CFG_VALID_CHANNEL_LIST should be set by this time
657 //use it to init the background scan list
658 csrInitBGScanChannelList(pMac);
659 /* HDD issues the init scan */
660 csrScanStartResultAgingTimer(pMac);
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -0800661 /* If the gScanAgingTime is set to '0' then scan results aging timeout
662 based on timer feature is not enabled*/
663 if(0 != pMac->scan.scanResultCfgAgingTime )
664 {
665 csrScanStartResultCfgAgingTimer(pMac);
666 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700667 //Store the AC weights in TL for later use
668 WLANTL_GetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
Jeff Johnson295189b2012-06-20 16:38:30 -0700669 status = csrInitChannelList( pMac );
670 if ( ! HAL_STATUS_SUCCESS( status ) )
671 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800672 smsLog( pMac, LOGE, "csrInitChannelList failed during csrReady with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700673 status );
674 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700675 return (status);
676}
Jeff Johnson295189b2012-06-20 16:38:30 -0700677void csrSetDefaultDot11Mode( tpAniSirGlobal pMac )
678{
679 v_U32_t wniDot11mode = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700680 wniDot11mode = csrTranslateToWNICfgDot11Mode(pMac,pMac->roam.configParam.uCfgDot11Mode);
681 ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, wniDot11mode, NULL, eANI_BOOLEAN_FALSE);
682}
Jeff Johnson295189b2012-06-20 16:38:30 -0700683void csrSetGlobalCfgs( tpAniSirGlobal pMac )
684{
Jeff Johnsone7245742012-09-05 17:12:55 -0700685
Jeff Johnson295189b2012-06-20 16:38:30 -0700686 ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
687 ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
688 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
689 ((pMac->roam.configParam.Is11hSupportEnabled) ? pMac->roam.configParam.Is11dSupportEnabled : pMac->roam.configParam.Is11dSupportEnabled),
690 NULL, eANI_BOOLEAN_FALSE);
691 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnsone7245742012-09-05 17:12:55 -0700692 /* For now we will just use the 5GHz CB mode ini parameter to decide whether CB supported or not in Probes when there is no session
693 * Once session is established we will use the session related params stored in PE session for CB mode
694 */
695 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, !!(pMac->roam.configParam.channelBondingMode5GHz), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700696 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, pMac->roam.configParam.HeartbeatThresh24, NULL, eANI_BOOLEAN_FALSE);
697
698 //Update the operating mode to configured value during initialization,
699 //So that client can advertise full capabilities in Probe request frame.
700 csrSetDefaultDot11Mode( pMac );
701}
702
Jeff Johnson295189b2012-06-20 16:38:30 -0700703eHalStatus csrRoamOpen(tpAniSirGlobal pMac)
704{
705 eHalStatus status = eHAL_STATUS_SUCCESS;
706 tANI_U32 i;
707 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700708 do
709 {
710 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
711 {
712 pSession = CSR_GET_SESSION( pMac, i );
713 pSession->roamingTimerInfo.pMac = pMac;
714 pSession->roamingTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
715 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700716 pMac->roam.WaitForKeyTimerInfo.pMac = pMac;
717 pMac->roam.WaitForKeyTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530718 status = vos_timer_init(&pMac->roam.hTimerWaitForKey, VOS_TIMER_TYPE_SW,
719 csrRoamWaitForKeyTimeOutHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -0700720 &pMac->roam.WaitForKeyTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530721 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700722 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800723 smsLog(pMac, LOGE, FL("cannot allocate memory for WaitForKey time out timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700724 break;
725 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530726 status = vos_timer_init(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
727 VOS_TIMER_TYPE_SW, csrRoamTlStatsTimerHandler, pMac);
728 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700729 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800730 smsLog(pMac, LOGE, FL("cannot allocate memory for summary Statistics timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700731 return eHAL_STATUS_FAILURE;
732 }
733 }while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700734 return (status);
735}
736
Jeff Johnson295189b2012-06-20 16:38:30 -0700737eHalStatus csrRoamClose(tpAniSirGlobal pMac)
738{
739 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700740 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
741 {
742 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
743 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530744 vos_timer_stop(&pMac->roam.hTimerWaitForKey);
745 vos_timer_destroy(&pMac->roam.hTimerWaitForKey);
746 vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
747 vos_timer_destroy(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -0700748 return (eHAL_STATUS_SUCCESS);
749}
750
Jeff Johnson295189b2012-06-20 16:38:30 -0700751eHalStatus csrRoamStart(tpAniSirGlobal pMac)
752{
753 (void)pMac;
Jeff Johnson295189b2012-06-20 16:38:30 -0700754 return (eHAL_STATUS_SUCCESS);
755}
756
Jeff Johnson295189b2012-06-20 16:38:30 -0700757void csrRoamStop(tpAniSirGlobal pMac, tANI_U32 sessionId)
758{
759 csrRoamStopRoamingTimer(pMac, sessionId);
760 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
761 csrRoamDeregStatisticsReq(pMac);
762}
Jeff Johnson295189b2012-06-20 16:38:30 -0700763eHalStatus csrRoamGetConnectState(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrConnectState *pState)
764{
765 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Srinivas Girigowdac84c57c2013-02-19 17:41:56 -0800766 if ( CSR_IS_SESSION_VALID(pMac, sessionId) && (NULL != pState) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700767 {
768 status = eHAL_STATUS_SUCCESS;
769 *pState = pMac->roam.roamSession[sessionId].connectState;
770 }
771 return (status);
772}
773
Jeff Johnson295189b2012-06-20 16:38:30 -0700774eHalStatus csrRoamCopyConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
775{
776 eHalStatus status = eHAL_STATUS_FAILURE;
777 tANI_U32 size = 0;
778 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -0700779
780 if(!pSession)
781 {
782 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
783 return eHAL_STATUS_FAILURE;
784 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700785
786 if(pProfile)
787 {
788 if(pSession->pConnectBssDesc)
789 {
790 do
791 {
792 size = pSession->pConnectBssDesc->length + sizeof(pSession->pConnectBssDesc->length);
793 if(size)
794 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530795 pProfile->pBssDesc = vos_mem_malloc(size);
796 if ( NULL != pProfile->pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -0700797 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530798 vos_mem_copy(pProfile->pBssDesc,
799 pSession->pConnectBssDesc, size);
800 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700801 }
802 else
803 break;
804 }
805 else
806 {
807 pProfile->pBssDesc = NULL;
808 }
809 pProfile->AuthType = pSession->connectedProfile.AuthType;
810 pProfile->EncryptionType = pSession->connectedProfile.EncryptionType;
811 pProfile->mcEncryptionType = pSession->connectedProfile.mcEncryptionType;
812 pProfile->BSSType = pSession->connectedProfile.BSSType;
813 pProfile->operationChannel = pSession->connectedProfile.operationChannel;
814 pProfile->CBMode = pSession->connectedProfile.CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +0530815 vos_mem_copy(&pProfile->bssid, &pSession->connectedProfile.bssid,
816 sizeof(tCsrBssid));
817 vos_mem_copy(&pProfile->SSID, &pSession->connectedProfile.SSID,
818 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -0700819#ifdef WLAN_FEATURE_VOWIFI_11R
820 if (pSession->connectedProfile.MDID.mdiePresent)
821 {
822 pProfile->MDID.mdiePresent = 1;
823 pProfile->MDID.mobilityDomain = pSession->connectedProfile.MDID.mobilityDomain;
824 }
825 else
826 {
827 pProfile->MDID.mdiePresent = 0;
828 pProfile->MDID.mobilityDomain = 0;
829 }
830#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800831#ifdef FEATURE_WLAN_ESE
832 pProfile->isESEAssoc = pSession->connectedProfile.isESEAssoc;
833 if (csrIsAuthTypeESE(pSession->connectedProfile.AuthType))
Jeff Johnson295189b2012-06-20 16:38:30 -0700834 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800835 vos_mem_copy (pProfile->eseCckmInfo.krk,
836 pSession->connectedProfile.eseCckmInfo.krk,
Kiet Lam64c1b492013-07-12 13:56:44 +0530837 CSR_KRK_KEY_LEN);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800838 pProfile->eseCckmInfo.reassoc_req_num=
839 pSession->connectedProfile.eseCckmInfo.reassoc_req_num;
840 pProfile->eseCckmInfo.krk_plumbed =
841 pSession->connectedProfile.eseCckmInfo.krk_plumbed;
Jeff Johnson295189b2012-06-20 16:38:30 -0700842 }
843#endif
844 }while(0);
845 }
846 }
847
848 return (status);
849}
850
Jeff Johnson295189b2012-06-20 16:38:30 -0700851eHalStatus csrRoamGetConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
852{
853 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700854
855 if((csrIsConnStateConnected(pMac, sessionId)) ||
856 (csrIsConnStateIbss(pMac, sessionId)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700857 {
858 if(pProfile)
859 {
860 status = csrRoamCopyConnectProfile(pMac, sessionId, pProfile);
861 }
862 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700863 return (status);
864}
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700865
Jeff Johnson295189b2012-06-20 16:38:30 -0700866eHalStatus csrRoamFreeConnectProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile)
867{
868 eHalStatus status = eHAL_STATUS_SUCCESS;
869
Kiet Lam64c1b492013-07-12 13:56:44 +0530870 if (pProfile->pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -0700871 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530872 vos_mem_free(pProfile->pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700873 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530874 if (pProfile->pAddIEAssoc)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700875 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530876 vos_mem_free(pProfile->pAddIEAssoc);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700877 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530878 vos_mem_set(pProfile, sizeof(tCsrRoamConnectedProfile), 0);
879
Jeff Johnson295189b2012-06-20 16:38:30 -0700880 pProfile->AuthType = eCSR_AUTH_TYPE_UNKNOWN;
881 return (status);
882}
883
Jeff Johnson295189b2012-06-20 16:38:30 -0700884static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo )
885{
886 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700887 if( pConnectedInfo->pbFrames )
888 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530889 vos_mem_free(pConnectedInfo->pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -0700890 pConnectedInfo->pbFrames = NULL;
891 }
892 pConnectedInfo->nBeaconLength = 0;
893 pConnectedInfo->nAssocReqLength = 0;
894 pConnectedInfo->nAssocRspLength = 0;
895 pConnectedInfo->staId = 0;
896#ifdef WLAN_FEATURE_VOWIFI_11R
897 pConnectedInfo->nRICRspLength = 0;
898#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800899#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700900 pConnectedInfo->nTspecIeLength = 0;
901#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700902 return ( status );
903}
904
Jeff Johnson295189b2012-06-20 16:38:30 -0700905
906
Jeff Johnsone7245742012-09-05 17:12:55 -0700907
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700908void csrReleaseCommandPreauth(tpAniSirGlobal pMac, tSmeCmd *pCommand)
909{
910 csrReinitPreauthCmd(pMac, pCommand);
911 csrReleaseCommand( pMac, pCommand );
912}
913
Jeff Johnson295189b2012-06-20 16:38:30 -0700914void csrReleaseCommandRoam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
915{
916 csrReinitRoamCmd(pMac, pCommand);
917 csrReleaseCommand( pMac, pCommand );
918}
919
Jeff Johnson295189b2012-06-20 16:38:30 -0700920void csrReleaseCommandScan(tpAniSirGlobal pMac, tSmeCmd *pCommand)
921{
922 csrReinitScanCmd(pMac, pCommand);
923 csrReleaseCommand( pMac, pCommand );
924}
925
Jeff Johnson295189b2012-06-20 16:38:30 -0700926void csrReleaseCommandWmStatusChange(tpAniSirGlobal pMac, tSmeCmd *pCommand)
927{
928 csrReinitWmStatusChangeCmd(pMac, pCommand);
929 csrReleaseCommand( pMac, pCommand );
930}
931
Jeff Johnson295189b2012-06-20 16:38:30 -0700932void csrReinitSetKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
933{
Kiet Lam64c1b492013-07-12 13:56:44 +0530934 vos_mem_set(&pCommand->u.setKeyCmd, sizeof(tSetKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700935}
936
Jeff Johnson295189b2012-06-20 16:38:30 -0700937void csrReinitRemoveKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
938{
Kiet Lam64c1b492013-07-12 13:56:44 +0530939 vos_mem_set(&pCommand->u.removeKeyCmd, sizeof(tRemoveKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700940}
941
Jeff Johnson295189b2012-06-20 16:38:30 -0700942void csrReleaseCommandSetKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
943{
944 csrReinitSetKeyCmd(pMac, pCommand);
945 csrReleaseCommand( pMac, pCommand );
946}
Jeff Johnson295189b2012-06-20 16:38:30 -0700947void csrReleaseCommandRemoveKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
948{
949 csrReinitRemoveKeyCmd(pMac, pCommand);
950 csrReleaseCommand( pMac, pCommand );
951}
Jeff Johnson295189b2012-06-20 16:38:30 -0700952void csrAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping )
953{
954
955 if( eSmeCsrCommandMask & pCommand->command )
956 {
957 switch (pCommand->command)
958 {
959 case eSmeCommandScan:
Jeff Johnson1250df42012-12-10 14:31:52 -0800960 // We need to inform the requester before dropping the scan command
Jeff Johnsonc7c54b12013-11-17 11:49:03 -0800961 smsLog( pMac, LOGW, "%s: Drop scan reason %d callback %p",
962 __func__, pCommand->u.scanCmd.reason,
963 pCommand->u.scanCmd.callback);
Jeff Johnson295189b2012-06-20 16:38:30 -0700964 if (NULL != pCommand->u.scanCmd.callback)
965 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800966 smsLog( pMac, LOGW, "%s callback scan requester", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700967 csrScanCallCallback(pMac, pCommand, eCSR_SCAN_ABORT);
968 }
969 csrReleaseCommandScan( pMac, pCommand );
970 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700971 case eSmeCommandRoam:
972 csrReleaseCommandRoam( pMac, pCommand );
973 break;
974
975 case eSmeCommandWmStatusChange:
976 csrReleaseCommandWmStatusChange( pMac, pCommand );
977 break;
978
979 case eSmeCommandSetKey:
980 csrReleaseCommandSetKey( pMac, pCommand );
981 break;
982
983 case eSmeCommandRemoveKey:
984 csrReleaseCommandRemoveKey( pMac, pCommand );
985 break;
986
987 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800988 smsLog( pMac, LOGW, " CSR abort standard command %d", pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -0700989 csrReleaseCommand( pMac, pCommand );
990 break;
991 }
992 }
993}
994
Jeff Johnson295189b2012-06-20 16:38:30 -0700995void csrRoamSubstateChange( tpAniSirGlobal pMac, eCsrRoamSubState NewSubstate, tANI_U32 sessionId)
996{
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +0530997 smsLog(pMac, LOG1, FL("CSR RoamSubstate: [ %s <== %s ]"),
998 macTraceGetcsrRoamSubState(NewSubstate),
999 macTraceGetcsrRoamSubState(pMac->roam.curSubState[sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07001000
Jeff Johnson295189b2012-06-20 16:38:30 -07001001 if(pMac->roam.curSubState[sessionId] == NewSubstate)
1002 {
1003 return;
Jeff Johnsone7245742012-09-05 17:12:55 -07001004 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001005 pMac->roam.curSubState[sessionId] = NewSubstate;
1006}
1007
Jeff Johnson295189b2012-06-20 16:38:30 -07001008eCsrRoamState csrRoamStateChange( tpAniSirGlobal pMac, eCsrRoamState NewRoamState, tANI_U8 sessionId)
1009{
1010 eCsrRoamState PreviousState;
1011
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05301012 smsLog(pMac, LOG1, FL("CSR RoamState[%hu]: [ %s <== %s ]"), sessionId,
1013 macTraceGetcsrRoamState(NewRoamState),
1014 macTraceGetcsrRoamState(pMac->roam.curState[sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07001015
1016 PreviousState = pMac->roam.curState[sessionId];
1017
1018 if ( NewRoamState != pMac->roam.curState[sessionId] )
1019 {
1020 // Whenever we transition OUT of the Roaming state, clear the Roaming substate...
1021 if ( CSR_IS_ROAM_JOINING(pMac, sessionId) )
1022 {
1023 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
1024 }
1025
1026 pMac->roam.curState[sessionId] = NewRoamState;
1027 }
1028 return( PreviousState );
1029}
1030
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001031void csrAssignRssiForCategory(tpAniSirGlobal pMac, tANI_S8 bestApRssi, tANI_U8 catOffset)
Jeff Johnson295189b2012-06-20 16:38:30 -07001032{
1033 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001034 if(catOffset)
1035 {
1036 pMac->roam.configParam.bCatRssiOffset = catOffset;
1037 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
1038 {
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001039 pMac->roam.configParam.RSSICat[CSR_NUM_RSSI_CAT - i - 1] = (int)bestApRssi - pMac->roam.configParam.nSelect5GHzMargin - (int)(i * catOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07001040 }
1041 }
1042}
1043
Jeff Johnson295189b2012-06-20 16:38:30 -07001044static void initConfigParam(tpAniSirGlobal pMac)
1045{
1046 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001047 pMac->roam.configParam.agingCount = CSR_AGING_COUNT;
Sandeep Puligilla60342762014-01-30 21:05:37 +05301048 pMac->roam.configParam.channelBondingMode24GHz =
1049 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
1050 pMac->roam.configParam.channelBondingMode5GHz =
1051 WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001052 pMac->roam.configParam.phyMode = eCSR_DOT11_MODE_TAURUS;
1053 pMac->roam.configParam.eBand = eCSR_BAND_ALL;
1054 pMac->roam.configParam.uCfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
1055 pMac->roam.configParam.FragmentationThreshold = eCSR_DOT11_FRAG_THRESH_DEFAULT;
1056 pMac->roam.configParam.HeartbeatThresh24 = 40;
1057 pMac->roam.configParam.HeartbeatThresh50 = 40;
1058 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
1059 pMac->roam.configParam.Is11dSupportEnabledOriginal = eANI_BOOLEAN_FALSE;
1060 pMac->roam.configParam.Is11eSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001061 pMac->roam.configParam.Is11hSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001062 pMac->roam.configParam.RTSThreshold = 2346;
1063 pMac->roam.configParam.shortSlotTime = eANI_BOOLEAN_TRUE;
1064 pMac->roam.configParam.WMMSupportMode = eCsrRoamWmmAuto;
1065 pMac->roam.configParam.ProprietaryRatesEnabled = eANI_BOOLEAN_TRUE;
1066 pMac->roam.configParam.TxRate = eCSR_TX_RATE_AUTO;
1067 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1068 pMac->roam.configParam.scanAgeTimeNCNPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_NO_PS;
1069 pMac->roam.configParam.scanAgeTimeNCPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_W_PS;
1070 pMac->roam.configParam.scanAgeTimeCNPS = CSR_SCAN_AGING_TIME_CONNECT_NO_PS;
1071 pMac->roam.configParam.scanAgeTimeCPS = CSR_SCAN_AGING_TIME_CONNECT_W_PS;
1072 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
1073 {
1074 pMac->roam.configParam.BssPreferValue[i] = i;
1075 }
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001076 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, CSR_DEFAULT_RSSI_DB_GAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07001077 pMac->roam.configParam.nRoamingTime = CSR_DEFAULT_ROAMING_TIME;
1078 pMac->roam.configParam.fEnforce11dChannels = eANI_BOOLEAN_FALSE;
1079 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001080 pMac->roam.configParam.fEnforceCountryCodeMatch = eANI_BOOLEAN_FALSE;
1081 pMac->roam.configParam.fEnforceDefaultDomain = eANI_BOOLEAN_FALSE;
1082 pMac->roam.configParam.nActiveMaxChnTime = CSR_ACTIVE_MAX_CHANNEL_TIME;
1083 pMac->roam.configParam.nActiveMinChnTime = CSR_ACTIVE_MIN_CHANNEL_TIME;
1084 pMac->roam.configParam.nPassiveMaxChnTime = CSR_PASSIVE_MAX_CHANNEL_TIME;
1085 pMac->roam.configParam.nPassiveMinChnTime = CSR_PASSIVE_MIN_CHANNEL_TIME;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001086 pMac->roam.configParam.nActiveMaxChnTimeBtc = CSR_ACTIVE_MAX_CHANNEL_TIME_BTC;
1087 pMac->roam.configParam.nActiveMinChnTimeBtc = CSR_ACTIVE_MIN_CHANNEL_TIME_BTC;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001088 pMac->roam.configParam.disableAggWithBtc = eANI_BOOLEAN_TRUE;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001089#ifdef WLAN_AP_STA_CONCURRENCY
1090 pMac->roam.configParam.nActiveMaxChnTimeConc = CSR_ACTIVE_MAX_CHANNEL_TIME_CONC;
1091 pMac->roam.configParam.nActiveMinChnTimeConc = CSR_ACTIVE_MIN_CHANNEL_TIME_CONC;
1092 pMac->roam.configParam.nPassiveMaxChnTimeConc = CSR_PASSIVE_MAX_CHANNEL_TIME_CONC;
1093 pMac->roam.configParam.nPassiveMinChnTimeConc = CSR_PASSIVE_MIN_CHANNEL_TIME_CONC;
1094 pMac->roam.configParam.nRestTimeConc = CSR_REST_TIME_CONC;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001095 pMac->roam.configParam.nNumStaChanCombinedConc = CSR_NUM_STA_CHAN_COMBINED_CONC;
1096 pMac->roam.configParam.nNumP2PChanCombinedConc = CSR_NUM_P2P_CHAN_COMBINED_CONC;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001097#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001098 pMac->roam.configParam.IsIdleScanEnabled = TRUE; //enable the idle scan by default
1099 pMac->roam.configParam.nTxPowerCap = CSR_MAX_TX_POWER;
1100 pMac->roam.configParam.statsReqPeriodicity = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD;
1101 pMac->roam.configParam.statsReqPeriodicityInPS = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001102#ifdef WLAN_FEATURE_VOWIFI_11R
1103 pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported = 0;
1104#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001105#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1106 pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries = 3;
1107 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold = 120;
1108 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold = 125;
1109 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = 20;
1110 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = 40;
1111 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod = 200;
1112 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels = 3;
1113 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[0] = 1;
1114 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[1] = 6;
1115 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[2] = 11;
1116 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod = 20000; //20 seconds
Srinivas Girigowdade697412013-02-14 16:31:48 -08001117 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001118#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001119#ifdef WLAN_FEATURE_11AC
1120 pMac->roam.configParam.nVhtChannelWidth = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ + 1;
1121#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001122
1123 pMac->roam.configParam.addTSWhenACMIsOff = 0;
1124 pMac->roam.configParam.fScanTwice = eANI_BOOLEAN_FALSE;
Mohit Khanna349bc392012-09-11 17:24:52 -07001125
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001126 //Remove this code once SLM_Sessionization is supported
1127 //BMPS_WORKAROUND_NOT_NEEDED
Jeff Johnsone7245742012-09-05 17:12:55 -07001128 pMac->roam.configParam.doBMPSWorkaround = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001129
Jeff Johnsone7245742012-09-05 17:12:55 -07001130}
Jeff Johnson295189b2012-06-20 16:38:30 -07001131eCsrBand csrGetCurrentBand(tHalHandle hHal)
1132{
1133 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1134 return pMac->roam.configParam.bandCapability;
1135}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001136
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001137
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001138#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001139/*
1140 This function flushes the roam scan cache
1141*/
1142eHalStatus csrFlushRoamScanRoamChannelList(tpAniSirGlobal pMac)
1143{
1144 eHalStatus status = eHAL_STATUS_SUCCESS;
1145 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1146
1147 /* Free up the memory first (if required) */
1148 if (NULL != pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
1149 {
1150 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1151 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
1152 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
1153 }
1154 return status;
1155}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001156#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001157
1158
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001159#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001160/*
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001161 This function flushes the roam scan cache
Srinivas Girigowdade697412013-02-14 16:31:48 -08001162*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001163eHalStatus csrFlushCfgBgScanRoamChannelList(tpAniSirGlobal pMac)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001164{
1165 eHalStatus status = eHAL_STATUS_SUCCESS;
1166 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1167
1168 /* Free up the memory first (if required) */
1169 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1170 {
1171 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
1172 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001173 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001174 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001175 return status;
1176}
1177
1178
1179
1180/*
1181 This function flushes the roam scan cache and creates fresh cache
1182 based on the input channel list
1183*/
1184eHalStatus csrCreateBgScanRoamChannelList(tpAniSirGlobal pMac,
1185 const tANI_U8 *pChannelList,
1186 const tANI_U8 numChannels)
1187{
1188 eHalStatus status = eHAL_STATUS_SUCCESS;
1189 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1190
Srinivas Girigowdade697412013-02-14 16:31:48 -08001191 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = numChannels;
1192
1193 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
1194 vos_mem_malloc(pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1195
1196 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1197 {
1198 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
1199 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
1200 return eHAL_STATUS_RESOURCES;
1201 }
1202
1203 /* Update the roam global structure */
Kiet Lam64c1b492013-07-12 13:56:44 +05301204 vos_mem_copy(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
1205 pChannelList,
1206 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001207 return status;
1208}
1209
1210/* This function modifies the bgscan channel list set via config ini or
1211 runtime, whenever the band changes.
1212 if the band is auto, then no operation is performed on the channel list
1213 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1214 if the band is 5G, then make sure channel list contains only 5G valid channels
1215*/
1216eHalStatus csrUpdateBgScanConfigIniChannelList(tpAniSirGlobal pMac,
1217 eCsrBand eBand)
1218{
1219 eHalStatus status = eHAL_STATUS_SUCCESS;
1220 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1221 tANI_U8 outNumChannels = 0;
1222 tANI_U8 inNumChannels = 0;
1223 tANI_U8 *inPtr = NULL;
1224 tANI_U8 i = 0;
1225 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1226
1227 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1228
1229 {
1230 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1231 "No update required for channel list "
1232 "either cfg.ini channel list is not set up or "
1233 "auto band (Band %d)", eBand);
1234 return status;
1235 }
1236
1237 inNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
1238 inPtr = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
1239 if (eCSR_BAND_24 == eBand)
1240 {
1241 for (i = 0; i < inNumChannels; i++)
1242 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001243 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
Srinivas Girigowdade697412013-02-14 16:31:48 -08001244 {
1245 ChannelList[outNumChannels++] = inPtr[i];
1246 }
1247 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001248 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001249 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001250 }
1251 else if (eCSR_BAND_5G == eBand)
1252 {
1253 for (i = 0; i < inNumChannels; i++)
1254 {
1255 /* Add 5G Non-DFS channel */
1256 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
Srinivas Girigowda56076852013-08-20 14:00:50 -07001257 csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001258 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1259 {
1260 ChannelList[outNumChannels++] = inPtr[i];
1261 }
1262 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001263 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001264 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001265 }
1266 else if (eCSR_BAND_ALL == eBand)
1267 {
1268 for (i = 0; i < inNumChannels; i++)
1269 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001270 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001271 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1272 {
1273 ChannelList[outNumChannels++] = inPtr[i];
1274 }
1275 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001276 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001277 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001278 }
1279 else
1280 {
1281 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1282 "Invalid band, No operation carried out (Band %d)", eBand);
1283 status = eHAL_STATUS_INVALID_PARAMETER;
1284 }
1285
1286 return status;
1287}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001288#endif
1289
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001290#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001291/* This function modifies the roam scan channel list as per AP neighbor
1292 report; AP neighbor report may be empty or may include only other AP
1293 channels; in any case, we merge the channel list with the learned occupied
1294 channels list.
1295 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1296 if the band is 5G, then make sure channel list contains only 5G valid channels
1297*/
1298eHalStatus csrCreateRoamScanChannelList(tpAniSirGlobal pMac,
1299 tANI_U8 *pChannelList,
1300 tANI_U8 numChannels,
1301 const eCsrBand eBand)
1302{
1303 eHalStatus status = eHAL_STATUS_SUCCESS;
1304 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1305 tANI_U8 outNumChannels = 0;
1306 tANI_U8 inNumChannels = numChannels;
1307 tANI_U8 *inPtr = pChannelList;
1308 tANI_U8 i = 0;
1309 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1310 tANI_U8 tmpChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1311 tANI_U8 mergedOutputNumOfChannels = 0;
1312 tpCsrChannelInfo currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
1313
1314 /* Create a Union of occupied channel list learnt by the DUT along with the Neighbor
1315 * report Channels. This increases the chances of the DUT to get a candidate AP while
1316 * roaming even if the Neighbor Report is not able to provide sufficient information. */
1317 if (pMac->scan.occupiedChannels.numChannels)
1318 {
1319 csrNeighborRoamMergeChannelLists(pMac,
1320 &pMac->scan.occupiedChannels.channelList[0],
1321 pMac->scan.occupiedChannels.numChannels,
1322 inPtr,
1323 inNumChannels,
1324 &mergedOutputNumOfChannels);
1325 inNumChannels = mergedOutputNumOfChannels;
1326 }
1327
1328 if (eCSR_BAND_24 == eBand)
1329 {
1330 for (i = 0; i < inNumChannels; i++)
1331 {
1332 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
1333 {
1334 ChannelList[outNumChannels++] = inPtr[i];
1335 }
1336 }
1337 }
1338 else if (eCSR_BAND_5G == eBand)
1339 {
1340 for (i = 0; i < inNumChannels; i++)
1341 {
1342 /* Add 5G Non-DFS channel */
1343 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
1344 csrRoamIsChannelValid(pMac, inPtr[i]) &&
1345 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1346 {
1347 ChannelList[outNumChannels++] = inPtr[i];
1348 }
1349 }
1350 }
1351 else if (eCSR_BAND_ALL == eBand)
1352 {
1353 for (i = 0; i < inNumChannels; i++)
1354 {
1355 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
1356 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1357 {
1358 ChannelList[outNumChannels++] = inPtr[i];
1359 }
1360 }
1361 }
1362 else
1363 {
1364 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1365 "Invalid band, No operation carried out (Band %d)", eBand);
1366 return eHAL_STATUS_INVALID_PARAMETER;
1367 }
1368
1369 /* if roaming within band is enabled, then select only the
1370 in band channels .
1371 This is required only if the band capability is set to ALL,
1372 E.g., if band capability is only 2.4G then all the channels in the
1373 list are already filtered for 2.4G channels, hence ignore this check*/
1374
1375 if ((eCSR_BAND_ALL == eBand) && CSR_IS_ROAM_INTRA_BAND_ENABLED(pMac))
1376 {
1377 csrNeighborRoamChannelsFilterByCurrentBand(
1378 pMac,
1379 ChannelList,
1380 outNumChannels,
1381 tmpChannelList,
1382 &outNumChannels);
Kiet Lamf2f201e2013-11-16 21:24:16 +05301383 vos_mem_copy(ChannelList,
1384 tmpChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001385 }
1386
1387 /* Prepare final roam scan channel list */
1388 if(outNumChannels)
1389 {
1390 /* Clear the channel list first */
1391 if (NULL != currChannelListInfo->ChannelList)
1392 {
1393 vos_mem_free(currChannelListInfo->ChannelList);
1394 currChannelListInfo->ChannelList = NULL;
1395 currChannelListInfo->numOfChannels = 0;
1396 }
1397
1398 currChannelListInfo->ChannelList = vos_mem_malloc(outNumChannels * sizeof(tANI_U8));
1399 if (NULL == currChannelListInfo->ChannelList)
1400 {
1401 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
1402 "Failed to allocate memory for roam scan channel list");
1403 currChannelListInfo->numOfChannels = 0;
1404 return VOS_STATUS_E_RESOURCES;
1405 }
Kiet Lamf2f201e2013-11-16 21:24:16 +05301406 vos_mem_copy(currChannelListInfo->ChannelList,
1407 ChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001408 }
1409 return status;
1410}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001411#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001412
Jeff Johnson295189b2012-06-20 16:38:30 -07001413eHalStatus csrSetBand(tHalHandle hHal, eCsrBand eBand)
1414{
1415 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1416 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001417 if (CSR_IS_PHY_MODE_A_ONLY(pMac) &&
1418 (eBand == eCSR_BAND_24))
1419 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001420 /* DOT11 mode configured to 11a only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001421 request to change the band to 2.4 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001422 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001423 "failed to set band cfg80211 = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001424 pMac->roam.configParam.uCfgDot11Mode, eBand);
1425 return eHAL_STATUS_INVALID_PARAMETER;
1426 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001427 if ((CSR_IS_PHY_MODE_B_ONLY(pMac) ||
1428 CSR_IS_PHY_MODE_G_ONLY(pMac)) &&
1429 (eBand == eCSR_BAND_5G))
1430 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001431 /* DOT11 mode configured to 11b/11g only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001432 request to change the band to 5 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001433 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001434 "failed to set band dot11mode = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001435 pMac->roam.configParam.uCfgDot11Mode, eBand);
1436 return eHAL_STATUS_INVALID_PARAMETER;
1437 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001438 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001439 "Band changed to %u (0 - ALL, 1 - 2.4 GHZ, 2 - 5GHZ)", eBand);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001440 pMac->roam.configParam.eBand = eBand;
1441 pMac->roam.configParam.bandCapability = eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001442 csrScanGetSupportedChannels( pMac );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001443#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -08001444 if (!csrRoamIsRoamOffloadScanEnabled(pMac))
1445 csrUpdateBgScanConfigIniChannelList( pMac, eBand );
Srinivas Girigowdade697412013-02-14 16:31:48 -08001446#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001447 status = csrInitGetChannels( pMac );
1448 if (eHAL_STATUS_SUCCESS == status)
1449 csrInitChannelList( hHal );
1450 return status;
1451}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001452
1453
Jeff Johnsone7245742012-09-05 17:12:55 -07001454/* The funcns csrConvertCBIniValueToPhyCBState and csrConvertPhyCBStateToIniValue have been
1455 * introduced to convert the ini value to the ENUM used in csr and MAC for CB state
1456 * Ideally we should have kept the ini value and enum value same and representing the same
1457 * cb values as in 11n standard i.e.
1458 * Set to 1 (SCA) if the secondary channel is above the primary channel
1459 * Set to 3 (SCB) if the secondary channel is below the primary channel
1460 * Set to 0 (SCN) if no secondary channel is present
1461 * However, since our driver is already distributed we will keep the ini definition as it is which is:
1462 * 0 - secondary none
1463 * 1 - secondary LOW
1464 * 2 - secondary HIGH
1465 * and convert to enum value used within the driver in csrChangeDefaultConfigParam using this funcn
1466 * The enum values are as follows:
1467 * PHY_SINGLE_CHANNEL_CENTERED = 0
1468 * PHY_DOUBLE_CHANNEL_LOW_PRIMARY = 1
1469 * PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
1470 */
1471ePhyChanBondState csrConvertCBIniValueToPhyCBState(v_U32_t cbIniValue)
1472{
1473
1474 ePhyChanBondState phyCbState;
1475 switch (cbIniValue) {
1476 // secondary none
1477 case 0:
1478 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1479 break;
1480 // secondary LOW
1481 case 1:
1482 phyCbState = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1483 break;
1484 // secondary HIGH
1485 case 2:
1486 phyCbState = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1487 break;
1488#ifdef WLAN_FEATURE_11AC
1489 case 3:
1490 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
1491 break;
1492 case 4:
1493 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1494 break;
1495 case 5:
1496 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1497 break;
1498 case 6:
1499 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
1500 break;
1501 case 7:
1502 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
1503 break;
1504 case 8:
1505 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
1506 break;
1507 case 9:
1508 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
1509 break;
1510#endif
1511 default:
1512 // If an invalid value is passed, disable CHANNEL BONDING
1513 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1514 break;
1515 }
1516 return phyCbState;
1517}
1518
1519v_U32_t csrConvertPhyCBStateToIniValue(ePhyChanBondState phyCbState)
1520{
1521
1522 v_U32_t cbIniValue;
1523 switch (phyCbState) {
1524 // secondary none
1525 case PHY_SINGLE_CHANNEL_CENTERED:
1526 cbIniValue = 0;
1527 break;
1528 // secondary LOW
1529 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
1530 cbIniValue = 1;
1531 break;
1532 // secondary HIGH
1533 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
1534 cbIniValue = 2;
1535 break;
1536#ifdef WLAN_FEATURE_11AC
1537 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1538 cbIniValue = 3;
1539 break;
1540 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
1541 cbIniValue = 4;
1542 break;
1543 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1544 cbIniValue = 5;
1545 break;
1546 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
1547 cbIniValue = 6;
1548 break;
1549 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
1550 cbIniValue = 7;
1551 break;
1552 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
1553 cbIniValue = 8;
1554 break;
1555 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
1556 cbIniValue = 9;
1557 break;
1558#endif
1559 default:
1560 // return some invalid value
1561 cbIniValue = 10;
1562 break;
1563 }
1564 return cbIniValue;
1565}
Jeff Johnson295189b2012-06-20 16:38:30 -07001566
1567eHalStatus csrChangeDefaultConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1568{
1569 eHalStatus status = eHAL_STATUS_SUCCESS;
1570
1571 if(pParam)
1572 {
1573 pMac->roam.configParam.WMMSupportMode = pParam->WMMSupportMode;
1574 pMac->roam.configParam.Is11eSupportEnabled = pParam->Is11eSupportEnabled;
1575 pMac->roam.configParam.FragmentationThreshold = pParam->FragmentationThreshold;
1576 pMac->roam.configParam.Is11dSupportEnabled = pParam->Is11dSupportEnabled;
1577 pMac->roam.configParam.Is11dSupportEnabledOriginal = pParam->Is11dSupportEnabled;
1578 pMac->roam.configParam.Is11hSupportEnabled = pParam->Is11hSupportEnabled;
1579
1580 pMac->roam.configParam.fenableMCCMode = pParam->fEnableMCCMode;
Mohit Khanna7ed53f02012-09-11 17:52:10 -07001581 pMac->roam.configParam.fAllowMCCGODiffBI = pParam->fAllowMCCGODiffBI;
1582
Jeff Johnsone7245742012-09-05 17:12:55 -07001583 /* channelBondingMode5GHz plays a dual role right now
1584 * INFRA STA will use this non zero value as CB enabled and SOFTAP will use this non-zero value to determine the secondary channel offset
1585 * This is how channelBondingMode5GHz works now and this is kept intact to avoid any cfg.ini change
1586 */
1587 if (pParam->channelBondingMode24GHz > MAX_CB_VALUE_IN_INI)
1588 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001589 smsLog( pMac, LOGW, "Invalid CB value from ini in 2.4GHz band %d, CB DISABLED", pParam->channelBondingMode24GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001590 }
1591 pMac->roam.configParam.channelBondingMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode24GHz);
1592 if (pParam->channelBondingMode5GHz > MAX_CB_VALUE_IN_INI)
1593 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001594 smsLog( pMac, LOGW, "Invalid CB value from ini in 5GHz band %d, CB DISABLED", pParam->channelBondingMode5GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001595 }
1596 pMac->roam.configParam.channelBondingMode5GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001597 pMac->roam.configParam.RTSThreshold = pParam->RTSThreshold;
1598 pMac->roam.configParam.phyMode = pParam->phyMode;
1599 pMac->roam.configParam.shortSlotTime = pParam->shortSlotTime;
1600 pMac->roam.configParam.HeartbeatThresh24 = pParam->HeartbeatThresh24;
1601 pMac->roam.configParam.HeartbeatThresh50 = pParam->HeartbeatThresh50;
1602 pMac->roam.configParam.ProprietaryRatesEnabled = pParam->ProprietaryRatesEnabled;
1603 pMac->roam.configParam.TxRate = pParam->TxRate;
1604 pMac->roam.configParam.AdHocChannel24 = pParam->AdHocChannel24;
1605 pMac->roam.configParam.AdHocChannel5G = pParam->AdHocChannel5G;
1606 pMac->roam.configParam.bandCapability = pParam->bandCapability;
1607 pMac->roam.configParam.cbChoice = pParam->cbChoice;
1608 pMac->roam.configParam.bgScanInterval = pParam->bgScanInterval;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001609 pMac->roam.configParam.disableAggWithBtc = pParam->disableAggWithBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001610 //if HDD passed down non zero values then only update,
1611 //otherwise keep using the defaults
c_hpothu059edb02014-03-12 21:44:28 +05301612 if (pParam->nInitialDwellTime)
1613 {
1614 pMac->roam.configParam.nInitialDwellTime =
1615 pParam->nInitialDwellTime;
1616 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001617 if (pParam->nActiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001618 {
1619 pMac->roam.configParam.nActiveMaxChnTime = pParam->nActiveMaxChnTime;
1620 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001621 if (pParam->nActiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001622 {
1623 pMac->roam.configParam.nActiveMinChnTime = pParam->nActiveMinChnTime;
1624 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001625 if (pParam->nPassiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001626 {
1627 pMac->roam.configParam.nPassiveMaxChnTime = pParam->nPassiveMaxChnTime;
1628 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001629 if (pParam->nPassiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001630 {
1631 pMac->roam.configParam.nPassiveMinChnTime = pParam->nPassiveMinChnTime;
1632 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001633 if (pParam->nActiveMaxChnTimeBtc)
1634 {
1635 pMac->roam.configParam.nActiveMaxChnTimeBtc = pParam->nActiveMaxChnTimeBtc;
1636 }
1637 if (pParam->nActiveMinChnTimeBtc)
1638 {
1639 pMac->roam.configParam.nActiveMinChnTimeBtc = pParam->nActiveMinChnTimeBtc;
1640 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001641#ifdef WLAN_AP_STA_CONCURRENCY
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001642 if (pParam->nActiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001643 {
1644 pMac->roam.configParam.nActiveMaxChnTimeConc = pParam->nActiveMaxChnTimeConc;
1645 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001646 if (pParam->nActiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001647 {
1648 pMac->roam.configParam.nActiveMinChnTimeConc = pParam->nActiveMinChnTimeConc;
1649 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001650 if (pParam->nPassiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001651 {
1652 pMac->roam.configParam.nPassiveMaxChnTimeConc = pParam->nPassiveMaxChnTimeConc;
1653 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001654 if (pParam->nPassiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001655 {
1656 pMac->roam.configParam.nPassiveMinChnTimeConc = pParam->nPassiveMinChnTimeConc;
1657 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001658 if (pParam->nRestTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001659 {
1660 pMac->roam.configParam.nRestTimeConc = pParam->nRestTimeConc;
1661 }
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001662 if (pParam->nNumStaChanCombinedConc)
Vinay Malekal05fdc812012-12-17 13:04:30 -08001663 {
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001664 pMac->roam.configParam.nNumStaChanCombinedConc = pParam->nNumStaChanCombinedConc;
1665 }
1666 if (pParam->nNumP2PChanCombinedConc)
1667 {
1668 pMac->roam.configParam.nNumP2PChanCombinedConc = pParam->nNumP2PChanCombinedConc;
Vinay Malekal05fdc812012-12-17 13:04:30 -08001669 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001670#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001671 //if upper layer wants to disable idle scan altogether set it to 0
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001672 if (pParam->impsSleepTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001673 {
1674 //Change the unit from second to microsecond
1675 tANI_U32 impsSleepTime = pParam->impsSleepTime * PAL_TIMER_TO_SEC_UNIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07001676 if(CSR_IDLE_SCAN_NO_PS_INTERVAL_MIN <= impsSleepTime)
1677 {
1678 pMac->roam.configParam.impsSleepTime = impsSleepTime;
1679 }
1680 else
1681 {
1682 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1683 }
1684 }
1685 else
1686 {
1687 pMac->roam.configParam.impsSleepTime = 0;
1688 }
1689 pMac->roam.configParam.eBand = pParam->eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001690 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(NULL, pMac->roam.configParam.phyMode,
1691 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07001692 //if HDD passed down non zero values for age params, then only update,
1693 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001694 if (pParam->nScanResultAgeCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07001695 {
1696 pMac->roam.configParam.agingCount = pParam->nScanResultAgeCount;
1697 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001698 if(pParam->scanAgeTimeNCNPS)
1699 {
1700 pMac->roam.configParam.scanAgeTimeNCNPS = pParam->scanAgeTimeNCNPS;
1701 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001702 if(pParam->scanAgeTimeNCPS)
1703 {
1704 pMac->roam.configParam.scanAgeTimeNCPS = pParam->scanAgeTimeNCPS;
1705 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001706 if(pParam->scanAgeTimeCNPS)
1707 {
1708 pMac->roam.configParam.scanAgeTimeCNPS = pParam->scanAgeTimeCNPS;
1709 }
1710 if(pParam->scanAgeTimeCPS)
1711 {
1712 pMac->roam.configParam.scanAgeTimeCPS = pParam->scanAgeTimeCPS;
1713 }
c_hpothu0d5a7352014-03-22 12:30:25 +05301714 if (pParam->initialScanSkipDFSCh)
1715 {
1716 pMac->roam.configParam.initialScanSkipDFSCh =
1717 pParam->initialScanSkipDFSCh;
1718 }
1719
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001720 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, pParam->bCatRssiOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07001721 pMac->roam.configParam.nRoamingTime = pParam->nRoamingTime;
1722 pMac->roam.configParam.fEnforce11dChannels = pParam->fEnforce11dChannels;
1723 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = pParam->fSupplicantCountryCodeHasPriority;
1724 pMac->roam.configParam.fEnforceCountryCodeMatch = pParam->fEnforceCountryCodeMatch;
1725 pMac->roam.configParam.fEnforceDefaultDomain = pParam->fEnforceDefaultDomain;
Jeff Johnson295189b2012-06-20 16:38:30 -07001726 pMac->roam.configParam.vccRssiThreshold = pParam->vccRssiThreshold;
1727 pMac->roam.configParam.vccUlMacLossThreshold = pParam->vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001728 pMac->roam.configParam.IsIdleScanEnabled = pParam->IsIdleScanEnabled;
1729 pMac->roam.configParam.statsReqPeriodicity = pParam->statsReqPeriodicity;
1730 pMac->roam.configParam.statsReqPeriodicityInPS = pParam->statsReqPeriodicityInPS;
1731 //Assign this before calling CsrInit11dInfo
1732 pMac->roam.configParam.nTxPowerCap = pParam->nTxPowerCap;
Jeff Johnson295189b2012-06-20 16:38:30 -07001733 if( csrIs11dSupported( pMac ) )
1734 {
1735 status = CsrInit11dInfo(pMac, &pParam->Csr11dinfo);
1736 }
1737 else
1738 {
1739 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
1740 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001741
1742 /* Initialize the power + channel information if 11h is enabled.
1743 If 11d is enabled this information has already been initialized */
1744 if( csrIs11hSupported( pMac ) && !csrIs11dSupported( pMac ) )
1745 {
1746 csrInitChannelPowerList(pMac, &pParam->Csr11dinfo);
1747 }
1748
1749
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05301750#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05301751 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
1752 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001753 smsLog( pMac, LOG1, "IsFTResourceReqSupp = %d", pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07001754#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001755#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001756 pMac->roam.configParam.isFastTransitionEnabled = pParam->isFastTransitionEnabled;
Jeff Johnson43971f52012-07-17 12:26:56 -07001757 pMac->roam.configParam.RoamRssiDiff = pParam->RoamRssiDiff;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001758 pMac->roam.configParam.nImmediateRoamRssiDiff = pParam->nImmediateRoamRssiDiff;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001759 smsLog( pMac, LOG1, "nImmediateRoamRssiDiff = %d",
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001760 pMac->roam.configParam.nImmediateRoamRssiDiff );
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08001761 pMac->roam.configParam.nRoamPrefer5GHz = pParam->nRoamPrefer5GHz;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07001762 pMac->roam.configParam.nRoamIntraBand = pParam->nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07001763 pMac->roam.configParam.isWESModeEnabled = pParam->isWESModeEnabled;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001764 pMac->roam.configParam.nProbes = pParam->nProbes;
1765 pMac->roam.configParam.nRoamScanHomeAwayTime = pParam->nRoamScanHomeAwayTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001766#endif
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001767#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1768 pMac->roam.configParam.isRoamOffloadScanEnabled = pParam->isRoamOffloadScanEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001769 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled = pParam->bFastRoamInConIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001770#endif
1771#ifdef FEATURE_WLAN_LFR
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001772 pMac->roam.configParam.isFastRoamIniFeatureEnabled = pParam->isFastRoamIniFeatureEnabled;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -08001773 pMac->roam.configParam.MAWCEnabled = pParam->MAWCEnabled;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001774#endif
1775
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001776#ifdef FEATURE_WLAN_ESE
1777 pMac->roam.configParam.isEseIniFeatureEnabled = pParam->isEseIniFeatureEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001778#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001779#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301780 vos_mem_copy(&pMac->roam.configParam.neighborRoamConfig,
1781 &pParam->neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001782 smsLog( pMac, LOG1, "nNeighborScanTimerPerioid = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod);
1783 smsLog( pMac, LOG1, "nNeighborReassocRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold);
1784 smsLog( pMac, LOG1, "nNeighborLookupRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold);
1785 smsLog( pMac, LOG1, "nNeighborScanMinChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime);
1786 smsLog( pMac, LOG1, "nNeighborScanMaxChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime);
1787 smsLog( pMac, LOG1, "nMaxNeighborRetries = %d", pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries);
1788 smsLog( pMac, LOG1, "nNeighborResultsRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod);
1789 smsLog( pMac, LOG1, "nEmptyScanRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod);
Jeff Johnson295189b2012-06-20 16:38:30 -07001790 {
1791 int i;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001792 smsLog( pMac, LOG1, FL("Num of Channels in CFG Channel List: %d"), pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07001793 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1794 {
1795 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1796 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001797 }
1798#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001799 pMac->roam.configParam.addTSWhenACMIsOff = pParam->addTSWhenACMIsOff;
1800 pMac->scan.fValidateList = pParam->fValidateList;
1801 pMac->scan.fEnableBypass11d = pParam->fEnableBypass11d;
1802 pMac->scan.fEnableDFSChnlScan = pParam->fEnableDFSChnlScan;
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08001803 pMac->scan.scanResultCfgAgingTime = pParam->scanCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001804 pMac->roam.configParam.fScanTwice = pParam->fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001805 pMac->scan.fFirstScanOnly2GChnl = pParam->fFirstScanOnly2GChnl;
1806 /* This parameter is not available in cfg and not passed from upper layers. Instead it is initialized here
1807 * This paramtere is used in concurrency to determine if there are concurrent active sessions.
1808 * Is used as a temporary fix to disconnect all active sessions when BMPS enabled so the active session if Infra STA
1809 * will automatically connect back and resume BMPS since resume BMPS is not working when moving from concurrent to
1810 * single session
1811 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001812 //Remove this code once SLM_Sessionization is supported
1813 //BMPS_WORKAROUND_NOT_NEEDED
Mohit Khanna349bc392012-09-11 17:24:52 -07001814 pMac->roam.configParam.doBMPSWorkaround = 0;
1815
Jeff Johnsone7245742012-09-05 17:12:55 -07001816#ifdef WLAN_FEATURE_11AC
1817 pMac->roam.configParam.nVhtChannelWidth = pParam->nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001818 pMac->roam.configParam.txBFEnable= pParam->enableTxBF;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001819 pMac->roam.configParam.txBFCsnValue = pParam->txBFCsnValue;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07001820 pMac->roam.configParam.enableVhtFor24GHz = pParam->enableVhtFor24GHz;
Jeff Johnsone7245742012-09-05 17:12:55 -07001821#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08001822 pMac->roam.configParam.txLdpcEnable = pParam->enableTxLdpc;
krunal soni5afa96c2013-09-06 22:19:02 -07001823
1824 pMac->roam.configParam.isAmsduSupportInAMPDU = pParam->isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001825 pMac->roam.configParam.nSelect5GHzMargin = pParam->nSelect5GHzMargin;
krunal sonie9002db2013-11-25 14:24:17 -08001826 pMac->roam.configParam.isCoalesingInIBSSAllowed =
1827 pParam->isCoalesingInIBSSAllowed;
Sandeep Puligillac80f26e2014-03-11 18:36:10 +05301828 pMac->roam.configParam.allowDFSChannelRoam = pParam->allowDFSChannelRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -07001829 }
1830
1831 return status;
1832}
1833
Jeff Johnson295189b2012-06-20 16:38:30 -07001834eHalStatus csrGetConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1835{
1836 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07001837 if(pParam)
1838 {
1839 pParam->WMMSupportMode = pMac->roam.configParam.WMMSupportMode;
1840 pParam->Is11eSupportEnabled = pMac->roam.configParam.Is11eSupportEnabled;
1841 pParam->FragmentationThreshold = pMac->roam.configParam.FragmentationThreshold;
1842 pParam->Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabled;
1843 pParam->Is11dSupportEnabledOriginal = pMac->roam.configParam.Is11dSupportEnabledOriginal;
1844 pParam->Is11hSupportEnabled = pMac->roam.configParam.Is11hSupportEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07001845 pParam->channelBondingMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode24GHz);
1846 pParam->channelBondingMode5GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001847 pParam->RTSThreshold = pMac->roam.configParam.RTSThreshold;
1848 pParam->phyMode = pMac->roam.configParam.phyMode;
1849 pParam->shortSlotTime = pMac->roam.configParam.shortSlotTime;
1850 pParam->HeartbeatThresh24 = pMac->roam.configParam.HeartbeatThresh24;
1851 pParam->HeartbeatThresh50 = pMac->roam.configParam.HeartbeatThresh50;
1852 pParam->ProprietaryRatesEnabled = pMac->roam.configParam.ProprietaryRatesEnabled;
1853 pParam->TxRate = pMac->roam.configParam.TxRate;
1854 pParam->AdHocChannel24 = pMac->roam.configParam.AdHocChannel24;
1855 pParam->AdHocChannel5G = pMac->roam.configParam.AdHocChannel5G;
1856 pParam->bandCapability = pMac->roam.configParam.bandCapability;
1857 pParam->cbChoice = pMac->roam.configParam.cbChoice;
1858 pParam->bgScanInterval = pMac->roam.configParam.bgScanInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07001859 pParam->nActiveMaxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
1860 pParam->nActiveMinChnTime = pMac->roam.configParam.nActiveMinChnTime;
1861 pParam->nPassiveMaxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
1862 pParam->nPassiveMinChnTime = pMac->roam.configParam.nPassiveMinChnTime;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001863 pParam->nActiveMaxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
1864 pParam->nActiveMinChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
1865 pParam->disableAggWithBtc = pMac->roam.configParam.disableAggWithBtc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001866#ifdef WLAN_AP_STA_CONCURRENCY
1867 pParam->nActiveMaxChnTimeConc = pMac->roam.configParam.nActiveMaxChnTimeConc;
1868 pParam->nActiveMinChnTimeConc = pMac->roam.configParam.nActiveMinChnTimeConc;
1869 pParam->nPassiveMaxChnTimeConc = pMac->roam.configParam.nPassiveMaxChnTimeConc;
1870 pParam->nPassiveMinChnTimeConc = pMac->roam.configParam.nPassiveMinChnTimeConc;
1871 pParam->nRestTimeConc = pMac->roam.configParam.nRestTimeConc;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001872 pParam->nNumStaChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc;
1873 pParam->nNumP2PChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001874#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001875 //Change the unit from microsecond to second
1876 pParam->impsSleepTime = pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_SEC_UNIT;
1877 pParam->eBand = pMac->roam.configParam.eBand;
1878 pParam->nScanResultAgeCount = pMac->roam.configParam.agingCount;
1879 pParam->scanAgeTimeNCNPS = pMac->roam.configParam.scanAgeTimeNCNPS;
1880 pParam->scanAgeTimeNCPS = pMac->roam.configParam.scanAgeTimeNCPS;
1881 pParam->scanAgeTimeCNPS = pMac->roam.configParam.scanAgeTimeCNPS;
1882 pParam->scanAgeTimeCPS = pMac->roam.configParam.scanAgeTimeCPS;
1883 pParam->bCatRssiOffset = pMac->roam.configParam.bCatRssiOffset;
1884 pParam->nRoamingTime = pMac->roam.configParam.nRoamingTime;
1885 pParam->fEnforce11dChannels = pMac->roam.configParam.fEnforce11dChannels;
1886 pParam->fSupplicantCountryCodeHasPriority = pMac->roam.configParam.fSupplicantCountryCodeHasPriority;
1887 pParam->fEnforceCountryCodeMatch = pMac->roam.configParam.fEnforceCountryCodeMatch;
1888 pParam->fEnforceDefaultDomain = pMac->roam.configParam.fEnforceDefaultDomain;
1889 pParam->vccRssiThreshold = pMac->roam.configParam.vccRssiThreshold;
1890 pParam->vccUlMacLossThreshold = pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001891 pParam->IsIdleScanEnabled = pMac->roam.configParam.IsIdleScanEnabled;
1892 pParam->nTxPowerCap = pMac->roam.configParam.nTxPowerCap;
1893 pParam->statsReqPeriodicity = pMac->roam.configParam.statsReqPeriodicity;
1894 pParam->statsReqPeriodicityInPS = pMac->roam.configParam.statsReqPeriodicityInPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001895 pParam->addTSWhenACMIsOff = pMac->roam.configParam.addTSWhenACMIsOff;
1896 pParam->fValidateList = pMac->roam.configParam.fValidateList;
1897 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
1898 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
1899 pParam->fScanTwice = pMac->roam.configParam.fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001900 pParam->fFirstScanOnly2GChnl = pMac->scan.fFirstScanOnly2GChnl;
Madan Mohan Koyyalamudied419512012-11-29 15:53:46 -08001901 pParam->fEnableMCCMode = pMac->roam.configParam.fenableMCCMode;
Madan Mohan Koyyalamudi057bd802012-11-29 16:02:39 -08001902 pParam->fAllowMCCGODiffBI = pMac->roam.configParam.fAllowMCCGODiffBI;
Sunil Ravi39b2e532013-01-20 23:45:53 -08001903 pParam->scanCfgAgingTime = pMac->scan.scanResultCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001904
1905#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301906 vos_mem_copy(&pParam->neighborRoamConfig,
1907 &pMac->roam.configParam.neighborRoamConfig,
1908 sizeof(tCsrNeighborRoamConfigParams));
Jeff Johnson295189b2012-06-20 16:38:30 -07001909#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001910#ifdef WLAN_FEATURE_11AC
1911 pParam->nVhtChannelWidth = pMac->roam.configParam.nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001912 pParam->enableTxBF = pMac->roam.configParam.txBFEnable;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001913 pParam->txBFCsnValue = pMac->roam.configParam.txBFCsnValue;
Ravi Joshiacc81822013-10-10 15:30:41 -07001914 pParam->enableVhtFor24GHz = pMac->roam.configParam.enableVhtFor24GHz;
Jeff Johnsone7245742012-09-05 17:12:55 -07001915#endif
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001916#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05301917 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
1918 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001919#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001920#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001921 pParam->isFastTransitionEnabled = pMac->roam.configParam.isFastTransitionEnabled;
1922 pParam->RoamRssiDiff = pMac->roam.configParam.RoamRssiDiff;
1923 pParam->nImmediateRoamRssiDiff = pMac->roam.configParam.nImmediateRoamRssiDiff;
1924 pParam->nRoamPrefer5GHz = pMac->roam.configParam.nRoamPrefer5GHz;
1925 pParam->nRoamIntraBand = pMac->roam.configParam.nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07001926 pParam->isWESModeEnabled = pMac->roam.configParam.isWESModeEnabled;
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -07001927 pParam->nProbes = pMac->roam.configParam.nProbes;
1928 pParam->nRoamScanHomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001929#endif
1930#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1931 pParam->isRoamOffloadScanEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
1932 pParam->bFastRoamInConIniFeatureEnabled = pMac->roam.configParam.bFastRoamInConIniFeatureEnabled;
1933#endif
1934#ifdef FEATURE_WLAN_LFR
1935 pParam->isFastRoamIniFeatureEnabled = pMac->roam.configParam.isFastRoamIniFeatureEnabled;
1936#endif
1937
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001938#ifdef FEATURE_WLAN_ESE
1939 pParam->isEseIniFeatureEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001940#endif
1941#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301942 vos_mem_copy(&pParam->neighborRoamConfig,
1943 &pMac->roam.configParam.neighborRoamConfig,
1944 sizeof(tCsrNeighborRoamConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001945 {
1946 int i;
1947 smsLog( pMac, LOG1, FL("Num of Channels in CFG Channel List: %d"), pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
1948 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1949 {
1950 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1951 }
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001952 }
1953#endif
1954
Venkata Prathyusha Kuntupallif2695c12013-04-17 15:41:23 -07001955 pParam->enableTxLdpc = pMac->roam.configParam.txLdpcEnable;
krunal soni4f087d22013-07-29 16:32:26 -07001956
krunal soni5afa96c2013-09-06 22:19:02 -07001957 pParam->isAmsduSupportInAMPDU = pMac->roam.configParam.isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001958 pParam->nSelect5GHzMargin = pMac->roam.configParam.nSelect5GHzMargin;
krunal soni5afa96c2013-09-06 22:19:02 -07001959
krunal sonie9002db2013-11-25 14:24:17 -08001960 pParam->isCoalesingInIBSSAllowed =
1961 pMac->roam.configParam.isCoalesingInIBSSAllowed;
Sandeep Puligillac80f26e2014-03-11 18:36:10 +05301962 pParam->allowDFSChannelRoam =
1963 pMac->roam.configParam.allowDFSChannelRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -07001964 csrSetChannels(pMac, pParam);
1965
1966 status = eHAL_STATUS_SUCCESS;
1967 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001968 return (status);
1969}
1970
Jeff Johnson295189b2012-06-20 16:38:30 -07001971eHalStatus csrSetPhyMode(tHalHandle hHal, tANI_U32 phyMode, eCsrBand eBand, tANI_BOOLEAN *pfRestartNeeded)
1972{
1973 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
1974 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1975 tANI_BOOLEAN fRestartNeeded = eANI_BOOLEAN_FALSE;
1976 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07001977 do
1978 {
1979 if(eCSR_BAND_24 == eBand)
1980 {
1981 if(CSR_IS_RADIO_A_ONLY(pMac)) break;
1982 if((eCSR_DOT11_MODE_11a & phyMode) || (eCSR_DOT11_MODE_11a_ONLY & phyMode)) break;
1983 }
1984 if(eCSR_BAND_5G == eBand)
1985 {
1986 if(CSR_IS_RADIO_BG_ONLY(pMac)) break;
1987 if((eCSR_DOT11_MODE_11b & phyMode) || (eCSR_DOT11_MODE_11b_ONLY & phyMode) ||
1988 (eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11g_ONLY & phyMode)
1989 )
1990 {
1991 break;
1992 }
1993 }
1994 if((0 == phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
1995 {
1996 newPhyMode = eCSR_DOT11_MODE_TAURUS;
1997 }
1998 else if(eCSR_DOT11_MODE_AUTO & phyMode)
1999 {
2000 newPhyMode = eCSR_DOT11_MODE_AUTO;
2001 }
2002 else
2003 {
2004 //Check for dual band and higher capability first
2005 if(eCSR_DOT11_MODE_11n_ONLY & phyMode)
2006 {
2007 if(eCSR_DOT11_MODE_11n_ONLY != phyMode) break;
2008 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
2009 }
2010 else if(eCSR_DOT11_MODE_11a_ONLY & phyMode)
2011 {
2012 if(eCSR_DOT11_MODE_11a_ONLY != phyMode) break;
2013 if(eCSR_BAND_24 == eBand) break;
2014 newPhyMode = eCSR_DOT11_MODE_11a_ONLY;
2015 eBand = eCSR_BAND_5G;
2016 }
2017 else if(eCSR_DOT11_MODE_11g_ONLY & phyMode)
2018 {
2019 if(eCSR_DOT11_MODE_11g_ONLY != phyMode) break;
2020 if(eCSR_BAND_5G == eBand) break;
2021 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
2022 eBand = eCSR_BAND_24;
2023 }
2024 else if(eCSR_DOT11_MODE_11b_ONLY & phyMode)
2025 {
2026 if(eCSR_DOT11_MODE_11b_ONLY != phyMode) break;
2027 if(eCSR_BAND_5G == eBand) break;
2028 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
2029 eBand = eCSR_BAND_24;
2030 }
2031 else if(eCSR_DOT11_MODE_11n & phyMode)
2032 {
2033 newPhyMode = eCSR_DOT11_MODE_11n;
2034 }
2035 else if(eCSR_DOT11_MODE_abg & phyMode)
2036 {
2037 newPhyMode = eCSR_DOT11_MODE_abg;
2038 }
2039 else if(eCSR_DOT11_MODE_11a & phyMode)
2040 {
2041 if((eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11b & phyMode))
2042 {
2043 if(eCSR_BAND_ALL == eBand)
2044 {
2045 newPhyMode = eCSR_DOT11_MODE_abg;
2046 }
2047 else
2048 {
2049 //bad setting
2050 break;
2051 }
2052 }
2053 else
2054 {
2055 newPhyMode = eCSR_DOT11_MODE_11a;
2056 eBand = eCSR_BAND_5G;
2057 }
2058 }
2059 else if(eCSR_DOT11_MODE_11g & phyMode)
2060 {
2061 newPhyMode = eCSR_DOT11_MODE_11g;
2062 eBand = eCSR_BAND_24;
2063 }
2064 else if(eCSR_DOT11_MODE_11b & phyMode)
2065 {
2066 newPhyMode = eCSR_DOT11_MODE_11b;
2067 eBand = eCSR_BAND_24;
2068 }
2069 else
2070 {
2071 //We will never be here
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002072 smsLog( pMac, LOGE, FL(" cannot recognize the phy mode 0x%08X"), phyMode );
Jeff Johnson295189b2012-06-20 16:38:30 -07002073 newPhyMode = eCSR_DOT11_MODE_AUTO;
2074 }
2075 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002076 //Done validating
2077 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002078 //Now we need to check whether a restart is needed.
2079 if(eBand != pMac->roam.configParam.eBand)
2080 {
2081 fRestartNeeded = eANI_BOOLEAN_TRUE;
2082 break;
2083 }
2084 if(newPhyMode != pMac->roam.configParam.phyMode)
2085 {
2086 fRestartNeeded = eANI_BOOLEAN_TRUE;
2087 break;
2088 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002089 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002090 if(HAL_STATUS_SUCCESS(status))
2091 {
2092 pMac->roam.configParam.eBand = eBand;
2093 pMac->roam.configParam.phyMode = newPhyMode;
2094 if(pfRestartNeeded)
2095 {
2096 *pfRestartNeeded = fRestartNeeded;
2097 }
2098 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002099 return (status);
2100}
2101
Jeff Johnson295189b2012-06-20 16:38:30 -07002102void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList )
2103{
2104 tANI_U8 Index;
2105 tANI_U8 cChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07002106 // for dual band NICs, don't need to trim the channel list....
2107 if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) )
2108 {
2109 // 2.4 GHz band operation requires the channel list to be trimmed to
2110 // the 2.4 GHz channels only...
2111 if ( CSR_IS_24_BAND_ONLY( pMac ) )
2112 {
2113 for( Index = 0, cChannels = 0; Index < pChannelList->numChannels;
2114 Index++ )
2115 {
2116 if ( CSR_IS_CHANNEL_24GHZ(pChannelList->channelList[ Index ]) )
2117 {
2118 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2119 cChannels++;
2120 }
2121 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002122 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2123 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2124 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2125 // only if we need to.
2126 //
2127 // The amount of memory to clear is the number of channesl that we trimmed
2128 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2129
2130 if ( pChannelList->numChannels > cChannels )
2131 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302132 vos_mem_set(&pChannelList->channelList[ cChannels ],
2133 sizeof( pChannelList->channelList[ 0 ] ) *
2134 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002135 }
2136
2137 pChannelList->numChannels = cChannels;
2138 }
2139 else if ( CSR_IS_5G_BAND_ONLY( pMac ) )
2140 {
2141 for ( Index = 0, cChannels = 0; Index < pChannelList->numChannels; Index++ )
2142 {
2143 if ( CSR_IS_CHANNEL_5GHZ(pChannelList->channelList[ Index ]) )
2144 {
2145 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2146 cChannels++;
2147 }
2148 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002149 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2150 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2151 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2152 // only if we need to.
2153 //
2154 // The amount of memory to clear is the number of channesl that we trimmed
2155 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2156 if ( pChannelList->numChannels > cChannels )
2157 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302158 vos_mem_set(&pChannelList->channelList[ cChannels ],
2159 sizeof( pChannelList->channelList[ 0 ] ) *
2160 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002161 }
2162
2163 pChannelList->numChannels = cChannels;
2164 }
2165 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002166}
Jeff Johnson295189b2012-06-20 16:38:30 -07002167#define INFRA_AP_DEFAULT_CHANNEL 6
2168eHalStatus csrIsValidChannel(tpAniSirGlobal pMac, tANI_U8 chnNum)
2169{
2170 tANI_U8 index= 0;
2171 eHalStatus status = eHAL_STATUS_FAILURE;
2172 for (index=0; index < pMac->scan.base20MHzChannels.numChannels ;index++)
2173 {
2174 if(pMac->scan.base20MHzChannels.channelList[ index ] == chnNum){
2175 status = eHAL_STATUS_SUCCESS;
2176 break;
2177 }
2178 }
2179 return status;
2180}
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002181
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002182
Jeff Johnson295189b2012-06-20 16:38:30 -07002183eHalStatus csrInitGetChannels(tpAniSirGlobal pMac)
2184{
2185 eHalStatus status = eHAL_STATUS_SUCCESS;
2186 tANI_U8 num20MHzChannelsFound = 0;
2187 VOS_STATUS vosStatus;
2188 tANI_U8 Index = 0;
2189 tANI_U8 num40MHzChannelsFound = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002190
Jeff Johnson295189b2012-06-20 16:38:30 -07002191
2192 //TODO: this interface changed to include the 40MHz channel list
2193 // this needs to be tied into the adapter structure somehow and referenced appropriately for CB operation
2194 // Read the scan channel list (including the power limit) from EEPROM
2195 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
2196 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
2197 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
2198 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002199 smsLog( pMac, LOGE, FL("failed to get channels "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002200 status = eHAL_STATUS_FAILURE;
2201 }
2202 else
2203 {
2204 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
2205 {
2206 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2207 }
2208 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
2209 // Move the channel list to the global data
2210 // structure -- this will be used as the scan list
2211 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
2212 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002213 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[ Index ].chanId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002214 }
2215 pMac->scan.base20MHzChannels.numChannels = num20MHzChannelsFound;
2216 if(num40MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN)
2217 {
2218 num40MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2219 }
2220 for ( Index = 0; Index < num40MHzChannelsFound; Index++)
2221 {
2222 pMac->scan.base40MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable40MHz[ Index ].chanId;
2223 }
2224 pMac->scan.base40MHzChannels.numChannels = num40MHzChannelsFound;
2225 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002226 return (status);
2227}
2228
Jeff Johnson295189b2012-06-20 16:38:30 -07002229eHalStatus csrInitChannelList( tHalHandle hHal )
2230{
2231 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2232 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002233 csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels);
2234 csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels);
Kiran4a17ebe2013-01-31 10:43:43 -08002235 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE);
2236 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002237 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002238 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnson295189b2012-06-20 16:38:30 -07002239
2240 return (status);
2241}
Jeff Johnson295189b2012-06-20 16:38:30 -07002242eHalStatus csrChangeConfigParams(tpAniSirGlobal pMac,
2243 tCsrUpdateConfigParam *pUpdateConfigParam)
2244{
2245 eHalStatus status = eHAL_STATUS_FAILURE;
2246 tCsr11dinfo *ps11dinfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002247 ps11dinfo = &pUpdateConfigParam->Csr11dinfo;
2248 status = CsrInit11dInfo(pMac, ps11dinfo);
2249 return status;
2250}
2251
Jeff Johnson295189b2012-06-20 16:38:30 -07002252static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2253{
2254 eHalStatus status = eHAL_STATUS_FAILURE;
2255 tANI_U8 index;
2256 tANI_U32 count=0;
2257 tSirMacChanInfo *pChanInfo;
2258 tSirMacChanInfo *pChanInfoStart;
2259 tANI_BOOLEAN applyConfig = TRUE;
2260
Mihir Shetebc866f62014-02-13 16:08:53 +05302261 pMac->scan.currentCountryRSSI = -128;
2262
Jeff Johnson295189b2012-06-20 16:38:30 -07002263 if(!ps11dinfo)
2264 {
2265 return (status);
2266 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002267 if ( ps11dinfo->Channels.numChannels && ( WNI_CFG_VALID_CHANNEL_LIST_LEN >= ps11dinfo->Channels.numChannels ) )
2268 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302269 pMac->scan.base20MHzChannels.numChannels = ps11dinfo->Channels.numChannels;
2270 vos_mem_copy(pMac->scan.base20MHzChannels.channelList,
2271 ps11dinfo->Channels.channelList,
2272 ps11dinfo->Channels.numChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07002273 }
2274 else
2275 {
2276 //No change
2277 return (eHAL_STATUS_SUCCESS);
2278 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002279 //legacy maintenance
Kiet Lam64c1b492013-07-12 13:56:44 +05302280
2281 vos_mem_copy(pMac->scan.countryCodeDefault, ps11dinfo->countryCode,
2282 WNI_CFG_COUNTRY_CODE_LEN);
2283
2284
Jeff Johnson295189b2012-06-20 16:38:30 -07002285 //Tush: at csropen get this initialized with default, during csr reset if this
2286 // already set with some value no need initilaize with default again
2287 if(0 == pMac->scan.countryCodeCurrent[0])
2288 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302289 vos_mem_copy(pMac->scan.countryCodeCurrent, ps11dinfo->countryCode,
2290 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002291 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002292 // need to add the max power channel list
Kiet Lam64c1b492013-07-12 13:56:44 +05302293 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2294 if (pChanInfo != NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002295 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302296 vos_mem_set(pChanInfo,
2297 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN ,
2298 0);
2299
Jeff Johnson295189b2012-06-20 16:38:30 -07002300 pChanInfoStart = pChanInfo;
Jeff Johnsone7245742012-09-05 17:12:55 -07002301 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2302 {
2303 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2304 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2305 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2306 pChanInfo++;
2307 count++;
2308 }
2309 if(count)
2310 {
2311 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2312 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302313 vos_mem_free(pChanInfoStart);
Jeff Johnsone7245742012-09-05 17:12:55 -07002314 }
2315 //Only apply them to CFG when not in STOP state. Otherwise they will be applied later
2316 if( HAL_STATUS_SUCCESS(status) )
2317 {
2318 for( index = 0; index < CSR_ROAM_SESSION_MAX; index++ )
2319 {
2320 if((CSR_IS_SESSION_VALID(pMac, index)) && CSR_IS_ROAM_STOP(pMac, index))
2321 {
2322 applyConfig = FALSE;
2323 }
2324 }
2325
2326 if(TRUE == applyConfig)
2327 {
2328 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002329 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnsone7245742012-09-05 17:12:55 -07002330 }
2331
2332 }
2333 return (status);
2334}
2335/* Initialize the Channel + Power List in the local cache and in the CFG */
2336eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2337{
2338 tANI_U8 index;
2339 tANI_U32 count=0;
2340 tSirMacChanInfo *pChanInfo;
2341 tSirMacChanInfo *pChanInfoStart;
2342
2343 if(!ps11dinfo || !pMac)
2344 {
2345 return eHAL_STATUS_FAILURE;
2346 }
2347
Kiet Lam64c1b492013-07-12 13:56:44 +05302348 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2349 if (pChanInfo != NULL)
Jeff Johnsone7245742012-09-05 17:12:55 -07002350 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302351 vos_mem_set(pChanInfo,
2352 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN,
2353 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07002354 pChanInfoStart = pChanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002355
2356 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2357 {
2358 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2359 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2360 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2361 pChanInfo++;
2362 count++;
2363 }
2364 if(count)
2365 {
2366 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2367 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302368 vos_mem_free(pChanInfoStart);
Jeff Johnson295189b2012-06-20 16:38:30 -07002369 }
2370
Jeff Johnsone7245742012-09-05 17:12:55 -07002371 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002372}
2373
2374//pCommand may be NULL
2375//Pass in sessionId in case pCommand is NULL. sessionId is not used in case pCommand is not NULL.
2376void csrRoamRemoveDuplicateCommand(tpAniSirGlobal pMac, tANI_U32 sessionId, tSmeCmd *pCommand, eCsrRoamReason eRoamReason)
2377{
2378 tListElem *pEntry, *pNextEntry;
2379 tSmeCmd *pDupCommand;
2380 tDblLinkList localList;
2381
2382 vos_mem_zero(&localList, sizeof(tDblLinkList));
2383 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
2384 {
2385 smsLog(pMac, LOGE, FL(" failed to open list"));
2386 return;
2387 }
2388 csrLLLock( &pMac->sme.smeCmdPendingList );
2389 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK );
2390 while( pEntry )
2391 {
2392 pNextEntry = csrLLNext( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
2393 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07002394 // Remove the previous command if..
2395 // - the new roam command is for the same RoamReason...
2396 // - the new roam command is a NewProfileList.
2397 // - the new roam command is a Forced Dissoc
2398 // - the new roam command is from an 802.11 OID (OID_SSID or OID_BSSID).
2399 if (
2400 (pCommand && ( pCommand->sessionId == pDupCommand->sessionId ) &&
2401 ((pCommand->command == pDupCommand->command) &&
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08002402 /* This peermac check is requried for Softap/GO scenarios
2403 * For STA scenario below OR check will suffice as pCommand will
2404 * always be NULL for STA scenarios
2405 */
2406 (vos_mem_compare(pDupCommand->u.roamCmd.peerMac, pCommand->u.roamCmd.peerMac, sizeof(v_MACADDR_t))) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002407 (pCommand->u.roamCmd.roamReason == pDupCommand->u.roamCmd.roamReason ||
2408 eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason ||
2409 eCsrHddIssued == pCommand->u.roamCmd.roamReason)))
2410 ||
2411 //below the pCommand is NULL
Jeff Johnson43971f52012-07-17 12:26:56 -07002412 ( (sessionId == pDupCommand->sessionId) &&
2413 (eSmeCommandRoam == pDupCommand->command) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002414 ((eCsrForcedDisassoc == eRoamReason) ||
2415 (eCsrHddIssued == eRoamReason))
2416 )
2417 )
2418 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002419 smsLog(pMac, LOGW, FL(" roamReason = %d"), pDupCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07002420 // Remove the 'stale' roam command from the pending list...
2421 if(csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK ))
2422 {
2423 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
2424 }
2425 }
2426 pEntry = pNextEntry;
2427 }
2428 csrLLUnlock( &pMac->sme.smeCmdPendingList );
2429
2430 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
2431 {
2432 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
2433 //Tell caller that the command is cancelled
2434 csrRoamCallCallback(pMac, pDupCommand->sessionId, NULL, pDupCommand->u.roamCmd.roamId,
2435 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
2436 csrReleaseCommandRoam(pMac, pDupCommand);
2437 }
2438 csrLLClose(&localList);
2439}
Jeff Johnson295189b2012-06-20 16:38:30 -07002440eHalStatus csrRoamCallCallback(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo,
2441 tANI_U32 roamId, eRoamCmdStatus u1, eCsrRoamResult u2)
2442{
2443 eHalStatus status = eHAL_STATUS_SUCCESS;
2444#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2445 WLAN_VOS_DIAG_EVENT_DEF(connectionStatus, vos_event_wlan_status_payload_type);
2446#endif
2447 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07002448 if( CSR_IS_SESSION_VALID( pMac, sessionId) )
2449 {
2450 pSession = CSR_GET_SESSION( pMac, sessionId );
2451 }
2452 else
2453 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002454 smsLog(pMac, LOGE, "Session ID:%d is not valid", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002455 VOS_ASSERT(0);
2456 return eHAL_STATUS_FAILURE;
2457 }
krunal soni587bf012014-02-04 12:35:11 -08002458
2459 if (eANI_BOOLEAN_FALSE == pSession->sessionActive)
2460 {
2461 smsLog(pMac, LOG1, "%s Session is not Active", __func__);
2462 return eHAL_STATUS_FAILURE;
2463 }
krunal soni7f7d2c92014-02-06 15:08:43 -08002464
krunal soni587bf012014-02-04 12:35:11 -08002465 smsLog(pMac, LOG4, "Recieved RoamCmdStatus %d with Roam Result %d", u1, u2);
2466
krunal soni7f7d2c92014-02-06 15:08:43 -08002467 if(eCSR_ROAM_ASSOCIATION_COMPLETION == u1 && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002468 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002469 smsLog(pMac, LOGW, " Assoc complete result = %d statusCode = %d reasonCode = %d", u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002470 }
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07002471 if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED) && (pSession->bRefAssocStartCnt)) {
2472 /*
2473 * Decrement bRefAssocStartCnt for FT reassoc failure.
2474 * Reason: For FT reassoc failures, we first call
2475 * csrRoamCallCallback before notifying a failed roam
2476 * completion through csrRoamComplete. The latter in
2477 * turn calls csrRoamProcessResults which tries to
2478 * once again call csrRoamCallCallback if bRefAssocStartCnt
2479 * is non-zero. Since this is redundant for FT reassoc
2480 * failure, decrement bRefAssocStartCnt.
2481 */
2482 pSession->bRefAssocStartCnt--;
2483 }
2484
Jeff Johnson295189b2012-06-20 16:38:30 -07002485 if(NULL != pSession->callback)
2486 {
2487 if( pRoamInfo )
2488 {
2489 pRoamInfo->sessionId = (tANI_U8)sessionId;
2490 }
2491
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302492 /* avoid holding the global lock when making the roaming callback, original change came
2493 from a raised CR (CR304874). Since this callback is in HDD a potential deadlock
2494 is possible on other OS ports where the callback may need to take locks to protect
2495 HDD state
Jeff Johnson295189b2012-06-20 16:38:30 -07002496 UPDATE : revert this change but keep the comments here. Need to revisit as there are callbacks
2497 that may actually depend on the lock being held */
2498 // TODO: revisit: sme_ReleaseGlobalLock( &pMac->sme );
2499 status = pSession->callback(pSession->pContext, pRoamInfo, roamId, u1, u2);
2500 // TODO: revisit: sme_AcquireGlobalLock( &pMac->sme );
2501 }
2502 //EVENT_WLAN_STATUS: eCSR_ROAM_ASSOCIATION_COMPLETION,
2503 // eCSR_ROAM_LOSTLINK, eCSR_ROAM_DISASSOCIATED,
2504#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiet Lam64c1b492013-07-12 13:56:44 +05302505 vos_mem_set(&connectionStatus,
2506 sizeof(vos_event_wlan_status_payload_type), 0);
2507
krunal soni7f7d2c92014-02-06 15:08:43 -08002508 if((eCSR_ROAM_ASSOCIATION_COMPLETION == u1) && (eCSR_ROAM_RESULT_ASSOCIATED == u2) && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002509 {
2510 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
2511 connectionStatus.bssType = pRoamInfo->u.pConnectedProfile->BSSType;
2512 if(NULL != pRoamInfo->pBssDesc)
2513 {
2514 connectionStatus.rssi = pRoamInfo->pBssDesc->rssi * (-1);
2515 connectionStatus.channel = pRoamInfo->pBssDesc->channelId;
2516 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002517 connectionStatus.qosCapability = pRoamInfo->u.pConnectedProfile->qosConnection;
2518 connectionStatus.authType = (v_U8_t)diagAuthTypeFromCSRType(pRoamInfo->u.pConnectedProfile->AuthType);
2519 connectionStatus.encryptionType = (v_U8_t)diagEncTypeFromCSRType(pRoamInfo->u.pConnectedProfile->EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05302520 vos_mem_copy(connectionStatus.ssid,
2521 pRoamInfo->u.pConnectedProfile->SSID.ssId, 6);
2522
Jeff Johnson295189b2012-06-20 16:38:30 -07002523 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
2524 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2525 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002526 if((eCSR_ROAM_MIC_ERROR_IND == u1) || (eCSR_ROAM_RESULT_MIC_FAILURE == u2))
2527 {
2528 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2529 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
2530 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2531 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002532 if(eCSR_ROAM_RESULT_FORCED == u2)
2533 {
2534 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2535 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
2536 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2537 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002538 if(eCSR_ROAM_RESULT_DISASSOC_IND == u2)
2539 {
2540 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2541 connectionStatus.reason = eCSR_REASON_DISASSOC;
2542 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2543 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002544 if(eCSR_ROAM_RESULT_DEAUTH_IND == u2)
2545 {
2546 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2547 connectionStatus.reason = eCSR_REASON_DEAUTH;
2548 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2549 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002550#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
2551
2552 return (status);
2553}
Jeff Johnson295189b2012-06-20 16:38:30 -07002554// Returns whether handoff is currently in progress or not
2555tANI_BOOLEAN csrRoamIsHandoffInProgress(tpAniSirGlobal pMac)
2556{
2557#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2558 return csrNeighborRoamIsHandoffInProgress(pMac);
2559#else
2560 return eANI_BOOLEAN_FALSE;
2561#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002562}
Jeff Johnson295189b2012-06-20 16:38:30 -07002563eHalStatus csrRoamIssueDisassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
2564 eCsrRoamSubState NewSubstate, tANI_BOOLEAN fMICFailure )
2565{
2566 eHalStatus status = eHAL_STATUS_SUCCESS;
2567 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2568 tANI_U16 reasonCode;
2569 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002570
2571 if(!pSession)
2572 {
2573 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2574 return eHAL_STATUS_FAILURE;
2575 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002576
2577 //Restore AC weight in case we change it
2578 if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
2579 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07002580 smsLog(pMac, LOG1, FL(" restore AC weights (%d-%d-%d-%d)"), pMac->roam.ucACWeights[0], pMac->roam.ucACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07002581 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
2582 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
2583 }
2584
2585 if ( fMICFailure )
2586 {
2587 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
2588 }
2589 else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)
2590 {
2591 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002592 }
2593 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002594 {
2595 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
2596 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002597#ifdef WLAN_FEATURE_VOWIFI_11R
2598 if ( (csrRoamIsHandoffInProgress(pMac)) &&
2599 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF))
2600 {
2601 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05302602 vos_mem_copy(&bssId,
2603 pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid,
2604 sizeof(tSirMacAddr));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002605 }
2606 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002607#endif
2608 if(pSession->pConnectBssDesc)
2609 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302610 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002611 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002612
Jeff Johnson295189b2012-06-20 16:38:30 -07002613
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05302614 smsLog(pMac, LOG2, FL("CSR Attempting to Disassociate Bssid="MAC_ADDRESS_STR
2615 " subState = %s reason=%d"),
2616 MAC_ADDR_ARRAY(bssId), macTraceGetcsrRoamSubState(NewSubstate),
2617 reasonCode);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08002618
Jeff Johnson295189b2012-06-20 16:38:30 -07002619 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2620
2621 status = csrSendMBDisassocReqMsg( pMac, sessionId, bssId, reasonCode );
2622
2623 if(HAL_STATUS_SUCCESS(status))
2624 {
2625 csrRoamLinkDown(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002626#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2627 //no need to tell QoS that we are disassociating, it will be taken care off in assoc req for HO
2628 if(eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate)
2629 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002630 //notify QoS module that disassoc happening
Jeff Johnson295189b2012-06-20 16:38:30 -07002631 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
2632 }
2633#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002634 }
2635 else
2636 {
2637 smsLog(pMac, LOGW, FL("csrSendMBDisassocReqMsg failed with status %d"), status);
2638 }
2639
Jeff Johnson295189b2012-06-20 16:38:30 -07002640 return (status);
2641}
Jeff Johnson295189b2012-06-20 16:38:30 -07002642
Jeff Johnson295189b2012-06-20 16:38:30 -07002643/* ---------------------------------------------------------------------------
2644 \fn csrRoamIssueDisassociateStaCmd
2645 \brief csr function that HDD calls to disassociate a associated station
2646 \param sessionId - session Id for Soft AP
2647 \param pPeerMacAddr - MAC of associated station to delete
2648 \param reason - reason code, be one of the tSirMacReasonCodes
2649 \return eHalStatus
2650 ---------------------------------------------------------------------------*/
2651eHalStatus csrRoamIssueDisassociateStaCmd( tpAniSirGlobal pMac,
2652 tANI_U32 sessionId,
2653 tANI_U8 *pPeerMacAddr,
2654 tANI_U32 reason)
2655{
2656 eHalStatus status = eHAL_STATUS_SUCCESS;
2657 tSmeCmd *pCommand;
2658
2659 do
2660 {
2661 pCommand = csrGetCommandBuffer( pMac );
2662 if ( !pCommand )
2663 {
2664 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2665 status = eHAL_STATUS_RESOURCES;
2666 break;
2667 }
2668 pCommand->command = eSmeCommandRoam;
2669 pCommand->sessionId = (tANI_U8)sessionId;
2670 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
2671 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2672 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2673 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2674 if( !HAL_STATUS_SUCCESS( status ) )
2675 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002676 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002677 csrReleaseCommandRoam( pMac, pCommand );
2678 }
2679 }while(0);
2680
2681 return status;
2682}
2683
2684
Jeff Johnson295189b2012-06-20 16:38:30 -07002685/* ---------------------------------------------------------------------------
2686 \fn csrRoamIssueDeauthSta
2687 \brief csr function that HDD calls to delete a associated station
2688 \param sessionId - session Id for Soft AP
2689 \param pPeerMacAddr - MAC of associated station to delete
2690 \param reason - reason code, be one of the tSirMacReasonCodes
2691 \return eHalStatus
2692 ---------------------------------------------------------------------------*/
2693eHalStatus csrRoamIssueDeauthStaCmd( tpAniSirGlobal pMac,
2694 tANI_U32 sessionId,
2695 tANI_U8 *pPeerMacAddr,
2696 tANI_U32 reason)
2697{
2698 eHalStatus status = eHAL_STATUS_SUCCESS;
2699 tSmeCmd *pCommand;
2700
2701 do
2702 {
2703 pCommand = csrGetCommandBuffer( pMac );
2704 if ( !pCommand )
2705 {
2706 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2707 status = eHAL_STATUS_RESOURCES;
2708 break;
2709 }
2710 pCommand->command = eSmeCommandRoam;
2711 pCommand->sessionId = (tANI_U8)sessionId;
2712 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
2713 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2714 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2715 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2716 if( !HAL_STATUS_SUCCESS( status ) )
2717 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002718 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002719 csrReleaseCommandRoam( pMac, pCommand );
2720 }
2721 }while(0);
2722
2723 return status;
2724}
Jeff Johnson295189b2012-06-20 16:38:30 -07002725eHalStatus
2726csrRoamIssueTkipCounterMeasures( tpAniSirGlobal pMac, tANI_U32 sessionId,
2727 tANI_BOOLEAN bEnable )
2728{
2729 eHalStatus status = eHAL_STATUS_FAILURE;
2730 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2731 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002732 if (!pSession)
2733 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002734 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002735 return (status);
2736 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002737 if (pSession->pConnectBssDesc)
2738 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302739 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002740 }
2741 else
2742 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002743 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002744 return (status);
2745 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002746 smsLog( pMac, LOG2, "CSR issuing tkip counter measures for Bssid = "MAC_ADDRESS_STR", Enable = %d",
2747 MAC_ADDR_ARRAY(bssId), bEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002748 status = csrSendMBTkipCounterMeasuresReqMsg( pMac, sessionId, bEnable, bssId );
2749 return (status);
2750}
Jeff Johnson295189b2012-06-20 16:38:30 -07002751eHalStatus
2752csrRoamGetAssociatedStas( tpAniSirGlobal pMac, tANI_U32 sessionId,
2753 VOS_MODULE_ID modId, void *pUsrContext,
2754 void *pfnSapEventCallback, v_U8_t *pAssocStasBuf )
2755{
2756 eHalStatus status = eHAL_STATUS_SUCCESS;
2757 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2758 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002759 if (!pSession)
2760 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002761 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002762 return (status);
2763 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002764 if(pSession->pConnectBssDesc)
2765 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302766 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002767 }
2768 else
2769 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002770 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002771 return (status);
2772 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002773 smsLog( pMac, LOG2, "CSR getting associated stations for Bssid = "MAC_ADDRESS_STR,
2774 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002775 status = csrSendMBGetAssociatedStasReqMsg( pMac, sessionId, modId, bssId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
2776 return (status);
2777}
Jeff Johnson295189b2012-06-20 16:38:30 -07002778eHalStatus
2779csrRoamGetWpsSessionOverlap( tpAniSirGlobal pMac, tANI_U32 sessionId,
2780 void *pUsrContext, void *pfnSapEventCallback, v_MACADDR_t pRemoveMac )
2781{
2782 eHalStatus status = eHAL_STATUS_SUCCESS;
2783 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2784 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2785
2786 if (!pSession)
2787 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002788 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002789 return (status);
2790 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002791 if(pSession->pConnectBssDesc)
2792 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302793 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002794 }
2795 else
2796 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002797 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002798 return (status);
2799 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002800 smsLog( pMac, LOG2, "CSR getting WPS Session Overlap for Bssid = "MAC_ADDRESS_STR,
2801 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002802
2803 status = csrSendMBGetWPSPBCSessions( pMac, sessionId, bssId, pUsrContext, pfnSapEventCallback, pRemoveMac);
2804
2805 return (status);
2806}
Jeff Johnson295189b2012-06-20 16:38:30 -07002807eHalStatus csrRoamIssueDeauth( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
2808{
2809 eHalStatus status = eHAL_STATUS_SUCCESS;
2810 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2811 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002812
2813 if (!pSession)
2814 {
2815 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2816 return eHAL_STATUS_FAILURE;
2817 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002818
2819 if(pSession->pConnectBssDesc)
2820 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302821 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002822 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002823 smsLog( pMac, LOG2, "CSR Attempting to Deauth Bssid= "MAC_ADDRESS_STR,
2824 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002825 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2826
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05302827 status = csrSendMBDeauthReqMsg( pMac, sessionId, bssId, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002828 if(!HAL_STATUS_SUCCESS(status))
2829 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05302830 smsLog(pMac, LOGE, FL("csrSendMBDeauthReqMsg failed with status %d Session ID: %d"
2831 MAC_ADDRESS_STR ), status, sessionId, MAC_ADDR_ARRAY(bssId));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002832 }
2833
Jeff Johnson295189b2012-06-20 16:38:30 -07002834 return (status);
2835}
2836
Jeff Johnson295189b2012-06-20 16:38:30 -07002837eHalStatus csrRoamSaveConnectedBssDesc( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDesc )
2838{
2839 eHalStatus status = eHAL_STATUS_SUCCESS;
2840 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2841 tANI_U32 size;
Jeff Johnson32d95a32012-09-10 13:15:23 -07002842
2843 if(!pSession)
2844 {
2845 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2846 return eHAL_STATUS_FAILURE;
2847 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002848
2849 // If no BSS description was found in this connection (happens with start IBSS), then
2850 // nix the BSS description that we keep around for the connected BSS) and get out...
2851 if(NULL == pBssDesc)
2852 {
2853 csrFreeConnectBssDesc(pMac, sessionId);
2854 }
2855 else
2856 {
2857 size = pBssDesc->length + sizeof( pBssDesc->length );
2858 if(NULL != pSession->pConnectBssDesc)
2859 {
2860 if(((pSession->pConnectBssDesc->length) + sizeof(pSession->pConnectBssDesc->length)) < size)
2861 {
2862 //not enough room for the new BSS, pMac->roam.pConnectBssDesc is freed inside
2863 csrFreeConnectBssDesc(pMac, sessionId);
2864 }
2865 }
2866 if(NULL == pSession->pConnectBssDesc)
2867 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302868 pSession->pConnectBssDesc = vos_mem_malloc(size);
Jeff Johnson295189b2012-06-20 16:38:30 -07002869 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302870 if (NULL == pSession->pConnectBssDesc)
2871 status = eHAL_STATUS_FAILURE;
2872 else
2873 vos_mem_copy(pSession->pConnectBssDesc, pBssDesc, size);
2874 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002875 return (status);
2876}
2877
Jeff Johnson295189b2012-06-20 16:38:30 -07002878eHalStatus csrRoamPrepareBssConfig(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2879 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
2880 tDot11fBeaconIEs *pIes)
2881{
2882 eHalStatus status = eHAL_STATUS_SUCCESS;
2883 eCsrCfgDot11Mode cfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002884 VOS_ASSERT( pIes != NULL );
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +05302885 if (pIes == NULL)
2886 return eHAL_STATUS_FAILURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002887
Jeff Johnson295189b2012-06-20 16:38:30 -07002888 do
2889 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302890 vos_mem_copy(&pBssConfig->BssCap, &pBssDesc->capabilityInfo,
2891 sizeof(tSirMacCapabilityInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07002892 //get qos
2893 pBssConfig->qosType = csrGetQoSFromBssDesc(pMac, pBssDesc, pIes);
2894 //get SSID
2895 if(pIes->SSID.present)
2896 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302897 vos_mem_copy(&pBssConfig->SSID.ssId, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07002898 pBssConfig->SSID.length = pIes->SSID.num_ssid;
2899 }
2900 else
2901 pBssConfig->SSID.length = 0;
2902 if(csrIsNULLSSID(pBssConfig->SSID.ssId, pBssConfig->SSID.length))
2903 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002904 smsLog(pMac, LOGW, " BSS desc SSID is a wildcard");
Jeff Johnson295189b2012-06-20 16:38:30 -07002905 //Return failed if profile doesn't have an SSID either.
2906 if(pProfile->SSIDs.numOfSSIDs == 0)
2907 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002908 smsLog(pMac, LOGW, " Both BSS desc and profile doesn't have SSID");
Jeff Johnson295189b2012-06-20 16:38:30 -07002909 status = eHAL_STATUS_FAILURE;
2910 break;
2911 }
2912 }
2913 if(CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
2914 {
2915 pBssConfig->eBand = eCSR_BAND_5G;
2916 }
2917 else
2918 {
2919 pBssConfig->eBand = eCSR_BAND_24;
2920 }
2921 //phymode
2922 if(csrIsPhyModeMatch( pMac, pProfile->phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes ))
2923 {
2924 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
2925 }
2926 else
2927 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002928 smsLog(pMac, LOGW, " Can not find match phy mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07002929 //force it
2930 if(eCSR_BAND_24 == pBssConfig->eBand)
2931 {
2932 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
2933 }
2934 else
2935 {
2936 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
2937 }
2938 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002939 //Qos
2940 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
2941 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos))
2942 {
2943 //Joining BSS is not 11n capable and WMM is disabled on client.
2944 //Disable QoS and WMM
2945 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
2946 }
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302947
2948 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
Pratik Bhalgat8d461642012-11-22 16:55:42 +05302949 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC)) &&
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05302950 ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP) ||
2951 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF) ||
2952 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF) ))
2953 {
2954 //Joining BSS is 11n capable and WMM is disabled on AP.
2955 //Assume all HT AP's are QOS AP's and enable WMM
2956 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
2957 }
2958
Jeff Johnson295189b2012-06-20 16:38:30 -07002959 //auth type
2960 switch( pProfile->negotiatedAuthType )
2961 {
2962 default:
2963 case eCSR_AUTH_TYPE_WPA:
2964 case eCSR_AUTH_TYPE_WPA_PSK:
2965 case eCSR_AUTH_TYPE_WPA_NONE:
2966 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
2967 pBssConfig->authType = eSIR_OPEN_SYSTEM;
2968 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002969 case eCSR_AUTH_TYPE_SHARED_KEY:
2970 pBssConfig->authType = eSIR_SHARED_KEY;
2971 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002972 case eCSR_AUTH_TYPE_AUTOSWITCH:
2973 pBssConfig->authType = eSIR_AUTO_SWITCH;
2974 break;
2975 }
2976 //short slot time
2977 if( eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode )
2978 {
2979 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
2980 }
2981 else
2982 {
2983 pBssConfig->uShortSlotTime = 0;
2984 }
2985 if(pBssConfig->BssCap.ibss)
2986 {
2987 //We don't support 11h on IBSS
2988 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
2989 }
2990 else
2991 {
2992 pBssConfig->f11hSupport = pMac->roam.configParam.Is11hSupportEnabled;
2993 }
2994 //power constraint
2995 pBssConfig->uPowerLimit = csrGet11hPowerConstraint(pMac, &pIes->PowerConstraints);
2996 //heartbeat
2997 if ( CSR_IS_11A_BSS( pBssDesc ) )
2998 {
2999 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3000 }
3001 else
3002 {
3003 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3004 }
3005 //Join timeout
3006 // if we find a BeaconInterval in the BssDescription, then set the Join Timeout to
Jeff Johnsone7245742012-09-05 17:12:55 -07003007 // be 10 x the BeaconInterval.
Jeff Johnson295189b2012-06-20 16:38:30 -07003008 if ( pBssDesc->beaconInterval )
3009 {
3010 //Make sure it is bigger than the minimal
Jeff Johnsone7245742012-09-05 17:12:55 -07003011 pBssConfig->uJoinTimeOut = CSR_ROAM_MAX(10 * pBssDesc->beaconInterval, CSR_JOIN_FAILURE_TIMEOUT_MIN);
Jeff Johnson295189b2012-06-20 16:38:30 -07003012 }
3013 else
3014 {
3015 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
3016 }
3017 //validate CB
3018 pBssConfig->cbMode = csrGetCBModeFromIes(pMac, pBssDesc->channelId, pIes);
Sandeep Puligilla60342762014-01-30 21:05:37 +05303019
Jeff Johnson295189b2012-06-20 16:38:30 -07003020 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003021 return (status);
3022}
3023
Jeff Johnson295189b2012-06-20 16:38:30 -07003024static eHalStatus csrRoamPrepareBssConfigFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
3025 tBssConfigParam *pBssConfig, tSirBssDescription *pBssDesc)
3026{
3027 eHalStatus status = eHAL_STATUS_SUCCESS;
3028 tANI_U8 operationChannel = 0;
3029 tANI_U8 qAPisEnabled = FALSE;
3030 //SSID
3031 pBssConfig->SSID.length = 0;
3032 if(pProfile->SSIDs.numOfSSIDs)
3033 {
3034 //only use the first one
Kiet Lam64c1b492013-07-12 13:56:44 +05303035 vos_mem_copy(&pBssConfig->SSID, &pProfile->SSIDs.SSIDList[0].SSID,
3036 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003037 }
3038 else
3039 {
3040 //SSID must present
3041 return eHAL_STATUS_FAILURE;
3042 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003043 //Settomg up the capabilities
3044 if( csrIsBssTypeIBSS(pProfile->BSSType) )
3045 {
3046 pBssConfig->BssCap.ibss = 1;
3047 }
3048 else
3049 {
3050 pBssConfig->BssCap.ess = 1;
3051 }
3052 if( eCSR_ENCRYPT_TYPE_NONE != pProfile->EncryptionType.encryptionType[0] )
3053 {
3054 pBssConfig->BssCap.privacy = 1;
3055 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003056 pBssConfig->eBand = pMac->roam.configParam.eBand;
3057 //phymode
3058 if(pProfile->ChannelInfo.ChannelList)
3059 {
3060 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3061 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003062 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, operationChannel,
3063 &pBssConfig->eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07003064 //QOS
3065 //Is this correct to always set to this //***
Jeff Johnson295189b2012-06-20 16:38:30 -07003066 if ( pBssConfig->BssCap.ess == 1 )
3067 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003068 /*For Softap case enable WMM*/
3069 if(CSR_IS_INFRA_AP(pProfile) && (eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode )){
3070 qAPisEnabled = TRUE;
3071 }
3072 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003073 if (csrRoamGetQosInfoFromBss(pMac, pBssDesc) == eHAL_STATUS_SUCCESS) {
3074 qAPisEnabled = TRUE;
3075 } else {
3076 qAPisEnabled = FALSE;
3077 }
3078 } else {
3079 qAPisEnabled = TRUE;
3080 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003081 if (( eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode && qAPisEnabled) ||
3082 (( eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode && qAPisEnabled) ||
3083 ( eCSR_CFG_DOT11_MODE_TAURUS == pBssConfig->uCfgDot11Mode ) ) //For 11n, need QoS
3084 )
3085 {
3086 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3087 } else {
3088 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3089 }
3090
3091 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08003092 switch( pProfile->AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07003093 {
3094 default:
3095 case eCSR_AUTH_TYPE_WPA:
3096 case eCSR_AUTH_TYPE_WPA_PSK:
3097 case eCSR_AUTH_TYPE_WPA_NONE:
3098 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3099 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3100 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003101 case eCSR_AUTH_TYPE_SHARED_KEY:
3102 pBssConfig->authType = eSIR_SHARED_KEY;
3103 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003104 case eCSR_AUTH_TYPE_AUTOSWITCH:
3105 pBssConfig->authType = eSIR_AUTO_SWITCH;
3106 break;
3107 }
3108 //short slot time
3109 if( WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode )
3110 {
3111 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3112 }
3113 else
3114 {
3115 pBssConfig->uShortSlotTime = 0;
3116 }
3117 //power constraint. We don't support 11h on IBSS
3118 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3119 pBssConfig->uPowerLimit = 0;
3120 //heartbeat
3121 if ( eCSR_BAND_5G == pBssConfig->eBand )
3122 {
3123 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3124 }
3125 else
3126 {
3127 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3128 }
3129 //Join timeout
3130 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07003131
Jeff Johnson295189b2012-06-20 16:38:30 -07003132 return (status);
3133}
Jeff Johnson295189b2012-06-20 16:38:30 -07003134static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc)
3135{
3136 eHalStatus status = eHAL_STATUS_FAILURE;
3137 tDot11fBeaconIEs *pIes = NULL;
3138
3139 do
3140 {
3141 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
3142 {
3143 //err msg
3144 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003145 "csrRoamGetQosInfoFromBss() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07003146 break;
3147 }
3148 //check if the AP is QAP & it supports APSD
3149 if( CSR_IS_QOS_BSS(pIes) )
3150 {
Kiet Lamb537cfb2013-11-07 12:56:49 +05303151 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07003152 }
3153 } while (0);
Kiet Lamb537cfb2013-11-07 12:56:49 +05303154
3155 if (NULL != pIes)
3156 {
3157 vos_mem_free(pIes);
3158 }
3159
Jeff Johnson295189b2012-06-20 16:38:30 -07003160 return status;
3161}
3162
Jeff Johnson295189b2012-06-20 16:38:30 -07003163void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
3164{
Jeff Johnson295189b2012-06-20 16:38:30 -07003165 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
3166 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
3167 // See !!Note: below in this function...
3168 tANI_U32 PrivacyEnabled = 0;
3169 tANI_U32 RsnEnabled = 0;
3170 tANI_U32 WepDefaultKeyId = 0;
3171 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
3172 tANI_U32 Key0Length = 0;
3173 tANI_U32 Key1Length = 0;
3174 tANI_U32 Key2Length = 0;
3175 tANI_U32 Key3Length = 0;
3176
3177 // Reserve for the biggest key
3178 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
3179 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
3180 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
3181 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
3182
3183 switch ( pProfile->negotiatedUCEncryptionType )
3184 {
3185 case eCSR_ENCRYPT_TYPE_NONE:
3186
3187 // for NO encryption, turn off Privacy and Rsn.
3188 PrivacyEnabled = 0;
3189 RsnEnabled = 0;
3190
3191 // WEP key length and Wep Default Key ID don't matter in this case....
3192
3193 // clear out the WEP keys that may be hanging around.
3194 Key0Length = 0;
3195 Key1Length = 0;
3196 Key2Length = 0;
3197 Key3Length = 0;
3198
3199 break;
3200
3201 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303202 case eCSR_ENCRYPT_TYPE_WEP40:
Jeff Johnson295189b2012-06-20 16:38:30 -07003203
3204 // Privacy is ON. NO RSN for Wep40 static key.
3205 PrivacyEnabled = 1;
3206 RsnEnabled = 0;
3207
3208 // Set the Wep default key ID.
3209 WepDefaultKeyId = pProfile->Keys.defaultIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07003210 // Wep key size if 5 bytes (40 bits).
3211 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
3212
3213 // set encryption keys in the CFG database or clear those that are not present in this profile.
3214 if ( pProfile->Keys.KeyLength[0] )
3215 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303216 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[0],
3217 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003218 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
3219 }
3220 else
3221 {
3222 Key0Length = 0;
3223 }
3224
3225 if ( pProfile->Keys.KeyLength[1] )
3226 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303227 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[1],
3228 WNI_CFG_WEP_KEY_LENGTH_5);
3229 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
Jeff Johnson295189b2012-06-20 16:38:30 -07003230 }
3231 else
3232 {
3233 Key1Length = 0;
3234 }
3235
3236 if ( pProfile->Keys.KeyLength[2] )
3237 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303238 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[2],
3239 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003240 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
3241 }
3242 else
3243 {
3244 Key2Length = 0;
3245 }
3246
3247 if ( pProfile->Keys.KeyLength[3] )
3248 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303249 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[3],
3250 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003251 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
3252 }
3253 else
3254 {
3255 Key3Length = 0;
3256 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003257 break;
3258
3259 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303260 case eCSR_ENCRYPT_TYPE_WEP104:
Jeff Johnson295189b2012-06-20 16:38:30 -07003261
3262 // Privacy is ON. NO RSN for Wep40 static key.
3263 PrivacyEnabled = 1;
3264 RsnEnabled = 0;
3265
3266 // Set the Wep default key ID.
3267 WepDefaultKeyId = pProfile->Keys.defaultIndex;
3268
3269 // Wep key size if 13 bytes (104 bits).
3270 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
3271
3272 // set encryption keys in the CFG database or clear those that are not present in this profile.
3273 if ( pProfile->Keys.KeyLength[0] )
3274 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303275 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[ 0 ],
3276 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003277 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
3278 }
3279 else
3280 {
3281 Key0Length = 0;
3282 }
3283
3284 if ( pProfile->Keys.KeyLength[1] )
3285 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303286 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[ 1 ],
3287 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003288 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
3289 }
3290 else
3291 {
3292 Key1Length = 0;
3293 }
3294
3295 if ( pProfile->Keys.KeyLength[2] )
3296 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303297 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[ 2 ],
3298 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003299 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
3300 }
3301 else
3302 {
3303 Key2Length = 0;
3304 }
3305
3306 if ( pProfile->Keys.KeyLength[3] )
3307 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303308 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[ 3 ],
3309 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003310 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
3311 }
3312 else
3313 {
3314 Key3Length = 0;
3315 }
3316
3317 break;
3318
Jeff Johnson295189b2012-06-20 16:38:30 -07003319 case eCSR_ENCRYPT_TYPE_TKIP:
3320 case eCSR_ENCRYPT_TYPE_AES:
3321#ifdef FEATURE_WLAN_WAPI
3322 case eCSR_ENCRYPT_TYPE_WPI:
3323#endif /* FEATURE_WLAN_WAPI */
3324 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
3325 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
3326 PrivacyEnabled = (0 != fPrivacy);
3327
3328 // turn on RSN enabled for WPA associations
3329 RsnEnabled = 1;
3330
3331 // WEP key length and Wep Default Key ID don't matter in this case....
3332
3333 // clear out the static WEP keys that may be hanging around.
3334 Key0Length = 0;
3335 Key1Length = 0;
3336 Key2Length = 0;
3337 Key3Length = 0;
3338
3339 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003340 default:
3341 PrivacyEnabled = 0;
3342 RsnEnabled = 0;
3343 break;
3344 }
3345
3346 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
3347 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
3348 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
3349 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
3350 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
3351 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
3352 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
3353 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
3354}
3355
Jeff Johnson295189b2012-06-20 16:38:30 -07003356static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
3357{
3358 tANI_U32 len = 0;
3359 if(pSSID->length <= WNI_CFG_SSID_LEN)
3360 {
3361 len = pSSID->length;
3362 }
3363 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
3364}
3365
Jeff Johnson295189b2012-06-20 16:38:30 -07003366eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
3367{
3368 eHalStatus status = eHAL_STATUS_SUCCESS;
3369 tANI_U32 QoSEnabled;
3370 tANI_U32 WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003371 // set the CFG enable/disable variables based on the qosType being configured...
3372 switch( qosType )
3373 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003374 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
3375 QoSEnabled = FALSE;
3376 WmeEnabled = TRUE;
3377 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003378 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
3379 QoSEnabled = FALSE;
3380 WmeEnabled = TRUE;
3381 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003382 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
3383 QoSEnabled = FALSE;
3384 WmeEnabled = TRUE;
3385 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003386 case eCSR_MEDIUM_ACCESS_11e_eDCF:
3387 QoSEnabled = TRUE;
3388 WmeEnabled = FALSE;
3389 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003390 case eCSR_MEDIUM_ACCESS_11e_HCF:
3391 QoSEnabled = TRUE;
3392 WmeEnabled = FALSE;
3393 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003394 default:
3395 case eCSR_MEDIUM_ACCESS_DCF:
3396 QoSEnabled = FALSE;
3397 WmeEnabled = FALSE;
3398 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003399 }
3400 //save the WMM setting for later use
3401 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
Sandeep Puligillaaea98a22013-12-04 13:36:32 +05303402 pMac->roam.roamSession[sessionId].fQOSConnection = (tANI_BOOLEAN)QoSEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003403 return (status);
3404}
Jeff Johnson295189b2012-06-20 16:38:30 -07003405static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
3406 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet)
3407{
3408 eHalStatus status = eHAL_STATUS_FAILURE;
3409 int i;
3410 eCsrCfgDot11Mode cfgDot11Mode;
3411 tANI_U8 *pDstRate;
Kiet Lam64c1b492013-07-12 13:56:44 +05303412 vos_mem_set(pOpRateSet, sizeof(tSirMacRateSet), 0);
3413 vos_mem_set(pExRateSet, sizeof(tSirMacRateSet), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003414 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003415
3416 if( NULL != pIes )
3417 {
3418 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003419 // Originally, we thought that for 11a networks, the 11a rates are always
3420 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3421 // appear in the Operational Rate set. Consequently, in either case, we
3422 // would blindly put the rates we support into our Operational Rate set
3423 // (including the basic rates, which we have already verified are
3424 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003425 // However, it turns out that this is not always the case. Some AP's
3426 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3427 // too. Now, we're a little more careful:
3428 pDstRate = pOpRateSet->rate;
3429 if(pIes->SuppRates.present)
3430 {
3431 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3432 {
3433 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
3434 {
3435 *pDstRate++ = pIes->SuppRates.rates[ i ];
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003436 pOpRateSet->numRates++;
Jeff Johnson295189b2012-06-20 16:38:30 -07003437 }
3438 }
3439 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003440 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3441 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3442 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3443 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3444 {
3445 // If there are Extended Rates in the beacon, we will reflect those
3446 // extended rates that we support in out Extended Operational Rate
3447 // set:
3448 pDstRate = pExRateSet->rate;
3449 if(pIes->ExtSuppRates.present)
3450 {
3451 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3452 {
3453 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) )
3454 {
3455 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3456 pExRateSet->numRates++;
3457 }
3458 }
3459 }
3460 }
3461 }//Parsing BSSDesc
3462 else
3463 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003464 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003465 }
3466 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
3467 return status;
3468}
3469
3470static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
3471 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3472{
3473 int i;
3474 tANI_U8 *pDstRate;
3475 eCsrCfgDot11Mode cfgDot11Mode;
3476 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3477 tANI_U32 OperationalRatesLength = 0;
3478 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3479 tANI_U32 ExtendedOperationalRatesLength = 0;
3480 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3481 tANI_U32 ProprietaryOperationalRatesLength = 0;
3482 tANI_U32 PropRatesEnable = 0;
3483 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
3484 tANI_U32 MCSRateLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003485 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003486 if( NULL != pIes )
3487 {
3488 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003489 // Originally, we thought that for 11a networks, the 11a rates are always
3490 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3491 // appear in the Operational Rate set. Consequently, in either case, we
3492 // would blindly put the rates we support into our Operational Rate set
3493 // (including the basic rates, which we have already verified are
3494 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003495 // However, it turns out that this is not always the case. Some AP's
3496 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3497 // too. Now, we're a little more careful:
3498 pDstRate = OperationalRates;
3499 if(pIes->SuppRates.present)
3500 {
3501 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3502 {
3503 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
3504 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
3505 {
3506 *pDstRate++ = pIes->SuppRates.rates[ i ];
3507 OperationalRatesLength++;
3508 }
3509 }
3510 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003511 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3512 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3513 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3514 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3515 {
3516 // If there are Extended Rates in the beacon, we will reflect those
3517 // extended rates that we support in out Extended Operational Rate
3518 // set:
3519 pDstRate = ExtendedOperationalRates;
3520 if(pIes->ExtSuppRates.present)
3521 {
3522 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3523 {
3524 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
3525 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
3526 {
3527 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3528 ExtendedOperationalRatesLength++;
3529 }
3530 }
3531 }
3532 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003533 // Enable proprietary MAC features if peer node is Airgo node and STA
3534 // user wants to use them
3535 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
3536 {
3537 PropRatesEnable = 1;
3538 }
3539 else
3540 {
3541 PropRatesEnable = 0;
3542 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003543 // For ANI network companions, we need to populate the proprietary rate
3544 // set with any proprietary rates we found in the beacon, only if user
3545 // allows them...
3546 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
3547 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
3548 {
3549 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
3550 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
3551 {
3552 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
3553 }
Kiet Lam64c1b492013-07-12 13:56:44 +05303554 vos_mem_copy(ProprietaryOperationalRates,
3555 pIes->Airgo.PropSuppRates.rates,
3556 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003557 }
3558 else {
3559 // No proprietary modes...
3560 ProprietaryOperationalRatesLength = 0;
3561 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003562 /* Get MCS Rate */
3563 pDstRate = MCSRateIdxSet;
3564 if ( pIes->HTCaps.present )
3565 {
3566 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
3567 {
3568 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
3569 {
3570 MCSRateLength++;
3571 *pDstRate++ = i;
3572 }
3573 }
3574 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003575 // Set the operational rate set CFG variables...
3576 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3577 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3578 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3579 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3580 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3581 ProprietaryOperationalRates,
3582 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3583 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
3584 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
3585 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
3586 }//Parsing BSSDesc
3587 else
3588 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003589 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003590 }
3591}
3592
Jeff Johnson295189b2012-06-20 16:38:30 -07003593static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
3594 tCsrRoamProfile *pProfile )
3595{
3596 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
3597 { 8,
3598 { SIR_MAC_RATE_6,
3599 SIR_MAC_RATE_9,
3600 SIR_MAC_RATE_12,
3601 SIR_MAC_RATE_18,
3602 SIR_MAC_RATE_24,
3603 SIR_MAC_RATE_36,
3604 SIR_MAC_RATE_48,
3605 SIR_MAC_RATE_54 } } };
Jeff Johnson295189b2012-06-20 16:38:30 -07003606 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
3607 { 4,
3608 { SIR_MAC_RATE_1,
3609 SIR_MAC_RATE_2,
3610 SIR_MAC_RATE_5_5,
3611 SIR_MAC_RATE_11 } } };
3612
3613
3614 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
3615 { SIR_MAC_RATE_72,
3616 SIR_MAC_RATE_96,
3617 SIR_MAC_RATE_108 } };
3618 eCsrCfgDot11Mode cfgDot11Mode;
3619 eCsrBand eBand;
3620 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3621 tANI_U32 OperationalRatesLength = 0;
3622 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3623 tANI_U32 ExtendedOperationalRatesLength = 0;
3624 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3625 tANI_U32 ProprietaryOperationalRatesLength = 0;
3626 tANI_U32 PropRatesEnable = 0;
3627 tANI_U8 operationChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003628 if(pProfile->ChannelInfo.ChannelList)
3629 {
3630 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3631 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003632 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -07003633 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
3634 // networks, the 11b rates appear in the Operational Rate set. In either case,
3635 // we can blindly put the rates we support into our Operational Rate set
3636 // (including the basic rates, which we have already verified are supported
3637 // earlier in the roaming decision).
3638 if ( eCSR_BAND_5G == eBand )
3639 {
3640 // 11a rates into the Operational Rate Set.
3641 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3642 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303643 vos_mem_copy(OperationalRates,
3644 DefaultSupportedRates11a.supportedRateSet.rate,
3645 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003646
3647 // Nothing in the Extended rate set.
3648 ExtendedOperationalRatesLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003649 // populate proprietary rates if user allows them
3650 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3651 {
3652 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3653 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303654 vos_mem_copy(ProprietaryOperationalRates,
3655 DefaultSupportedPropRates.propRate,
3656 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003657 }
3658 else
3659 {
3660 // No proprietary modes
3661 ProprietaryOperationalRatesLength = 0;
3662 }
3663 }
3664 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
3665 {
3666 // 11b rates into the Operational Rate Set.
3667 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3668 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303669 vos_mem_copy(OperationalRates,
3670 DefaultSupportedRates11b.supportedRateSet.rate,
3671 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003672 // Nothing in the Extended rate set.
3673 ExtendedOperationalRatesLength = 0;
3674 // No proprietary modes
3675 ProprietaryOperationalRatesLength = 0;
3676 }
3677 else
3678 {
3679 // 11G
3680
3681 // 11b rates into the Operational Rate Set.
3682 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3683 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303684 vos_mem_copy(OperationalRates,
3685 DefaultSupportedRates11b.supportedRateSet.rate,
3686 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003687
3688 // 11a rates go in the Extended rate set.
3689 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3690 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303691 vos_mem_copy(ExtendedOperationalRates,
3692 DefaultSupportedRates11a.supportedRateSet.rate,
3693 ExtendedOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003694
3695 // populate proprietary rates if user allows them
3696 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3697 {
3698 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3699 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303700 vos_mem_copy(ProprietaryOperationalRates,
3701 DefaultSupportedPropRates.propRate,
3702 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003703 }
3704 else
3705 {
3706 // No proprietary modes
3707 ProprietaryOperationalRatesLength = 0;
3708 }
3709 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003710 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
3711 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
3712 {
3713 PropRatesEnable = 1;
3714 }
3715 else
3716 {
3717 PropRatesEnable = 0;
3718 }
3719
3720 // Set the operational rate set CFG variables...
3721 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3722 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3723 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3724 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3725 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3726 ProprietaryOperationalRates,
3727 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3728 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003729}
Jeff Johnson295189b2012-06-20 16:38:30 -07003730void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
3731{
3732 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07003733
Jeff Johnson295189b2012-06-20 16:38:30 -07003734 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
3735 tANI_U32 sessionId;
3736 tSmeCmd *pCommand = NULL;
3737
3738 if(NULL == pEntry)
3739 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003740 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07003741 return;
3742 }
3743 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
3744 sessionId = pCommand->sessionId;
3745
3746 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
3747 {
3748 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
3749 }
3750}
3751
Jeff Johnson295189b2012-06-20 16:38:30 -07003752//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
3753tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
3754{
3755 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
3756 {
3757 return (WNI_CFG_PHY_MODE_11B);
3758 }
3759 else
3760 {
3761 if(eCSR_BAND_24 == band)
3762 return (WNI_CFG_PHY_MODE_11G);
3763 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003764 return (WNI_CFG_PHY_MODE_11A);
3765}
Jeff Johnson295189b2012-06-20 16:38:30 -07003766
Jeff Johnsone7245742012-09-05 17:12:55 -07003767
3768#ifdef WLAN_FEATURE_11AC
3769ePhyChanBondState csrGetHTCBStateFromVHTCBState(ePhyChanBondState aniCBMode)
3770{
3771 switch ( aniCBMode )
3772 {
3773 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
3774 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
3775 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
3776 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3777 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
3778 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
3779 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
3780 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3781 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003782 default :
Jeff Johnsone7245742012-09-05 17:12:55 -07003783 return PHY_SINGLE_CHANNEL_CENTERED;
3784 }
3785}
3786#endif
3787
Jeff Johnson295189b2012-06-20 16:38:30 -07003788//pIes may be NULL
3789eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3790 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303791 tDot11fBeaconIEs *pIes, tANI_BOOLEAN resetCountry)
Jeff Johnson295189b2012-06-20 16:38:30 -07003792{
3793 eHalStatus status = eHAL_STATUS_SUCCESS;
3794 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3795 tANI_U8 channel = 0;
3796 //Make sure we have the domain info for the BSS we try to connect to.
3797 //Do we need to worry about sequence for OSs that are not Windows??
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303798 if (pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -07003799 {
Agrawal Ashish0b6984f2014-04-05 18:35:45 +05303800 if (csrLearnCountryInformation(pMac, eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07003801 {
3802 //Make sure the 11d info from this BSSDesc can be applied
3803 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303804 if (VOS_TRUE == resetCountry)
3805 {
3806 csrApplyCountryInformation(pMac, FALSE);
3807 }
3808 else
3809 {
3810 csrApplyCountryInformation(pMac, TRUE);
3811 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003812 }
Kiran4a17ebe2013-01-31 10:43:43 -08003813 if ((csrIs11dSupported (pMac)) && pIes)
3814 {
3815 if (!pIes->Country.present)
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003816 {
Kiran4a17ebe2013-01-31 10:43:43 -08003817 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE );
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003818 }
3819 else
3820 {
3821 //Let's also update the below to make sure we don't update CC while
3822 //connected to an AP which is advertising some CC
Kiet Lamf2f201e2013-11-16 21:24:16 +05303823 vos_mem_copy(pMac->scan.currentCountryBssid,
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003824 pBssDesc->bssId, sizeof(tSirMacAddr));
3825 }
Kiran4a17ebe2013-01-31 10:43:43 -08003826 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003827 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003828 //Qos
3829 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
3830 //SSID
3831 csrSetCfgSsid(pMac, &pBssConfig->SSID );
3832 //fragment threshold
3833 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3834 //RTS threshold
3835 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3836
3837 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003838 //Auth type
3839 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
3840 //encryption type
3841 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
3842 //short slot time
3843 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003844 //11d
3845 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
3846 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
3847 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003848 /*//11h
3849 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
3850 */
3851 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
3852 //CB
Jeff Johnsone7245742012-09-05 17:12:55 -07003853
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003854 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile) || CSR_IS_IBSS(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07003855 {
3856 channel = pProfile->operationChannel;
3857 }
3858 else
3859 {
3860 if(pBssDesc)
3861 {
3862 channel = pBssDesc->channelId;
3863 }
3864 }
3865 if(0 != channel)
3866 {
Sandeep Puligilla60342762014-01-30 21:05:37 +05303867 if(CSR_IS_CHANNEL_24GHZ(channel) &&
3868 !pMac->roam.configParam.channelBondingMode24GHz &&
3869 !WDA_getFwWlanFeatCaps(HT40_OBSS_SCAN))
3870 {//On 2.4 Ghz, CB will be disabled if it is not configured through .ini
Jeff Johnson295189b2012-06-20 16:38:30 -07003871 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Sandeep Puligilla60342762014-01-30 21:05:37 +05303872 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
3873 " cbMode disabled cfgCb = %d channelBondingMode24GHz %d",
3874 __func__, cfgCb, pMac->roam.configParam.channelBondingMode24GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07003875 }
3876 else
3877 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003878 cfgCb = pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003879 }
3880 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003881#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudia0d88932012-11-13 10:51:26 -08003882 // cbMode = 1 in cfg.ini is mapped to PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
3883 // in function csrConvertCBIniValueToPhyCBState()
3884 // So, max value for cbMode in 40MHz mode is 3 (MAC\src\include\sirParams.h)
3885 if(cfgCb > PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
Jeff Johnsone7245742012-09-05 17:12:55 -07003886 {
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003887 if(!WDA_getFwWlanFeatCaps(DOT11AC)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07003888 cfgCb = csrGetHTCBStateFromVHTCBState(cfgCb);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003889 }
Sandeep Puligilla60342762014-01-30 21:05:37 +05303890 else
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003891 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003892 ccmCfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, pMac->roam.configParam.nVhtChannelWidth, NULL, eANI_BOOLEAN_FALSE);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003893 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003894 }
3895 else
3896#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003897 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
3898 //Rate
3899 //Fixed Rate
3900 if(pBssDesc)
3901 {
3902 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
3903 }
3904 else
3905 {
3906 csrSetCfgRateSetFromProfile(pMac, pProfile);
3907 }
3908 //Make this the last CFG to set. The callback will trigger a join_req
3909 //Join time out
3910 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
3911
3912 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003913 return (status);
3914}
3915
Jeff Johnson295189b2012-06-20 16:38:30 -07003916eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3917 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3918{
3919 eHalStatus status;
3920 tBssConfigParam *pBssConfig;
3921 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003922
3923 if(!pSession)
3924 {
3925 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3926 return eHAL_STATUS_FAILURE;
3927 }
3928
Kiet Lam64c1b492013-07-12 13:56:44 +05303929 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
3930 if ( NULL == pBssConfig )
3931 status = eHAL_STATUS_FAILURE;
3932 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003933 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303934 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003935 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
3936 if(HAL_STATUS_SUCCESS(status))
3937 {
3938 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07003939 /* This will allow to pass cbMode during join req */
3940 pSession->bssParams.cbMode= pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003941 //For IBSS, we need to prepare some more information
3942 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003943 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003944 )
3945 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003946 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07003947 }
3948 // If we are in an IBSS, then stop the IBSS...
3949 ////Not worry about WDS connection for now
3950 if ( csrIsConnStateIbss( pMac, sessionId ) )
3951 {
3952 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
3953 }
3954 else
3955 {
3956 // if we are in an Infrastructure association....
3957 if ( csrIsConnStateInfra( pMac, sessionId ) )
3958 {
3959 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
3960 // across SSIDs (roaming to a new SSID)... //
3961 //Not worry about WDS connection for now
3962 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303963 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003964 {
3965 // then we need to disassociate from the Infrastructure network...
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303966 status = csrRoamIssueDisassociate( pMac, sessionId,
3967 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07003968 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303969 else
3970 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003971 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
3972 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303973 if ( pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -07003974 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303975 // Set parameters for this Bss.
3976 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
3977 pBssDesc, pBssConfig,
3978 pIes, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003979 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303980 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003981 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303982 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003983 {
3984 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
3985 // Nothing to stop.
3986 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07003987 || CSR_IS_INFRA_AP(pProfile)
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303988 )
3989 {
3990 tANI_BOOLEAN is11rRoamingFlag = eANI_BOOLEAN_FALSE;
3991 is11rRoamingFlag = csrRoamIs11rAssoc(pMac);
3992 // Set parameters for this Bss.
3993 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
3994 pBssDesc, pBssConfig,
3995 pIes, is11rRoamingFlag);
3996 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003997 }
3998 }
3999 }//Success getting BSS config info
Kiet Lam64c1b492013-07-12 13:56:44 +05304000 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -07004001 }//Allocate memory
Jeff Johnson295189b2012-06-20 16:38:30 -07004002 return (status);
4003}
4004
Jeff Johnson295189b2012-06-20 16:38:30 -07004005eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
4006 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
4007{
4008 eCsrJoinState eRoamState = eCsrContinueRoaming;
4009 eHalStatus status;
4010 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
4011 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
4012 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004013
4014 if(!pSession)
4015 {
4016 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4017 return (eCsrStopRoaming);
4018 }
4019
Jeff Johnson295189b2012-06-20 16:38:30 -07004020 if( CSR_IS_WDS_STA( pProfile ) )
4021 {
4022 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
4023 if( !HAL_STATUS_SUCCESS( status ) )
4024 {
4025 eRoamState = eCsrStopRoaming;
4026 }
4027 }
4028 else
4029 {
4030 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
4031 {
4032 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
4033 return (eCsrStopRoaming);
4034 }
4035 if ( csrIsInfraBssDesc( pBssDesc ) )
4036 {
4037 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
4038 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
4039 // have changed and handle the changes (without disturbing the current association).
4040
4041 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
4042 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
4043 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
4044 )
4045 {
4046 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
4047 // with Authenticating first. To force this, stop the current association (Disassociate) and
4048 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
4049 // a new Association.
4050 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4051 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07004052 smsLog(pMac, LOGW, FL(" detect same profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004053 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
4054 {
4055 eRoamState = eCsrReassocToSelfNoCapChange;
4056 }
4057 else
4058 {
4059 tBssConfigParam bssConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004060 //The key changes
Kiet Lam64c1b492013-07-12 13:56:44 +05304061 vos_mem_set(&bssConfig, sizeof(bssConfig), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004062 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
4063 if(HAL_STATUS_SUCCESS(status))
4064 {
4065 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07004066 pSession->bssParams.cbMode = bssConfig.cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004067 //Reapply the config including Keys so reassoc is happening.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304068 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4069 pBssDesc, &bssConfig,
4070 pIesLocal, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004071 if(!HAL_STATUS_SUCCESS(status))
4072 {
4073 eRoamState = eCsrStopRoaming;
4074 }
4075 }
4076 else
4077 {
4078 eRoamState = eCsrStopRoaming;
4079 }
4080 }//same profile
4081 }
4082 else
4083 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304084 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004085 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
4086 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05304087 smsLog(pMac, LOGE, FL(" fail to issue disassociate with Session ID %d"),
4088 sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004089 eRoamState = eCsrStopRoaming;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304090 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004091 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304092 }
4093 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004094 {
4095 // note: we used to pre-auth here with open authentication networks but that was not working so well.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304096 // we had a lot of join timeouts when testing at Samsung. removing this step helped associations
Jeff Johnson295189b2012-06-20 16:38:30 -07004097 // work much better.
4098 //
4099 //
4100 // stop the existing network before attempting to join the new network...
4101 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4102 {
4103 eRoamState = eCsrStopRoaming;
4104 }
4105 }
4106 }//Infra
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304107 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004108 {
4109 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4110 {
4111 eRoamState = eCsrStopRoaming;
4112 }
4113 }
4114 if( pIesLocal && !pScanResult->pvIes )
4115 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304116 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004117 }
4118 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004119 return( eRoamState );
4120}
4121
Jeff Johnson295189b2012-06-20 16:38:30 -07004122eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
4123 tSirBssDescription *pBssDesc, tANI_U32 roamId)
4124{
4125 eHalStatus status = eHAL_STATUS_SUCCESS;
4126 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05304127 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004128 roamInfo.pBssDesc = pBssDesc;
4129 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
4130 return (status);
4131}
Jeff Johnson295189b2012-06-20 16:38:30 -07004132//In case no matching BSS is found, use whatever default we can find
4133static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4134{
4135 //Need to get all negotiated types in place first
4136 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08004137 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07004138 {
4139 default:
4140 case eCSR_AUTH_TYPE_WPA:
4141 case eCSR_AUTH_TYPE_WPA_PSK:
4142 case eCSR_AUTH_TYPE_WPA_NONE:
4143 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4144 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4145 break;
4146
4147 case eCSR_AUTH_TYPE_SHARED_KEY:
4148 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
4149 break;
4150
4151 case eCSR_AUTH_TYPE_AUTOSWITCH:
4152 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
4153 break;
4154 }
4155 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4156 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4157 //In this case, the multicast encryption needs to follow the uncast ones.
4158 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4159 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4160}
4161
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004162
4163static void csrSetAbortRoamingCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4164{
4165 switch(pCommand->u.roamCmd.roamReason)
4166 {
4167 case eCsrLostLink1:
4168 pCommand->u.roamCmd.roamReason = eCsrLostLink1Abort;
4169 break;
4170 case eCsrLostLink2:
4171 pCommand->u.roamCmd.roamReason = eCsrLostLink2Abort;
4172 break;
4173 case eCsrLostLink3:
4174 pCommand->u.roamCmd.roamReason = eCsrLostLink3Abort;
4175 break;
4176 default:
4177 smsLog(pMac, LOGE, FL(" aborting roaming reason %d not recognized"),
4178 pCommand->u.roamCmd.roamReason);
4179 break;
4180 }
4181}
4182
Jeff Johnson295189b2012-06-20 16:38:30 -07004183static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
4184{
4185 eHalStatus status;
4186 tCsrScanResult *pScanResult = NULL;
4187 eCsrJoinState eRoamState = eCsrStopRoaming;
4188 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
4189 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
4190 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
4191#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4192 v_U8_t acm_mask = 0;
4193#endif
4194 tANI_U32 sessionId = pCommand->sessionId;
4195 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4196 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4197 tANI_U8 concurrentChannel = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004198
4199 if(!pSession)
4200 {
4201 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4202 return (eCsrStopRoaming);
4203 }
4204
Jeff Johnson295189b2012-06-20 16:38:30 -07004205 do
4206 {
4207 // Check for Cardbus eject condition, before trying to Roam to any BSS
4208 //***if( !balIsCardPresent(pAdapter) ) break;
4209
Kiet Lam64c1b492013-07-12 13:56:44 +05304210 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004211 memcpy (&roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004212 if(NULL != pBSSList)
4213 {
4214 // When handling AP's capability change, continue to associate to
4215 // same BSS and make sure pRoamBssEntry is not Null.
4216 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
4217 {
4218 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
4219 {
4220 //Try the first BSS
4221 pCommand->u.roamCmd.pLastRoamBss = NULL;
4222 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
4223 }
4224 else
4225 {
4226 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4227 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4228 {
4229 //Done with all the BSSs
4230 //In this case, will tell HDD the completion
4231 break;
4232 }
4233 else
4234 {
4235 //We need to indicate to HDD that we are done with this one.
Kiet Lam64c1b492013-07-12 13:56:44 +05304236 //vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004237 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
4238 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4239 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4240 pRoamInfo = &roamInfo;
4241 }
4242 }
4243 while(pCommand->u.roamCmd.pRoamBssEntry)
4244 {
4245 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Jeff Johnson295189b2012-06-20 16:38:30 -07004246 /*If concurrency enabled take the concurrent connected channel first. */
4247 /* Valid multichannel concurrent sessions exempted */
Jeff Johnsone7245742012-09-05 17:12:55 -07004248 if (vos_concurrent_sessions_running() &&
4249 !csrIsValidMcConcurrentSession(pMac, sessionId, &pScanResult->Result.BssDescriptor))
Jeff Johnson295189b2012-06-20 16:38:30 -07004250 {
4251 concurrentChannel =
4252 csrGetConcurrentOperationChannel(pMac);
4253 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004254 " csr Concurrent Channel = %d", __func__, concurrentChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07004255 if ((concurrentChannel) &&
4256 (concurrentChannel ==
4257 pScanResult->Result.BssDescriptor.channelId))
4258 {
4259 //make this 0 because we do not want the
4260 //below check to pass as we don't want to
4261 //connect on other channel
4262 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4263 FL("Concurrent channel match =%d"),
4264 concurrentChannel);
4265 concurrentChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004266 }
4267 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004268
4269 if (!concurrentChannel)
4270 {
4271
4272 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
4273 sessionId, &pScanResult->Result.BssDescriptor,
4274 pCommand->u.roamCmd.roamId)))
4275 {
4276 //Ok to roam this
4277 break;
4278 }
4279 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004280 else
4281 {
4282 eRoamState = eCsrStopRoamingDueToConcurrency;
4283 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004284 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4285 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4286 {
4287 //Done with all the BSSs
4288 fDone = eANI_BOOLEAN_TRUE;
4289 break;
4290 }
4291 }
4292 if(fDone)
4293 {
4294 break;
4295 }
4296 }
4297 }
4298 //We have something to roam, tell HDD when it is infra.
4299 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
4300 //For WDS, the indication is eCSR_ROAM_WDS_IND
4301 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4302 {
4303 if(pRoamInfo)
4304 {
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004305 if(pSession->bRefAssocStartCnt)
4306 {
4307 pSession->bRefAssocStartCnt--;
4308 //Complete the last association attemp because a new one is about to be tried
4309 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4310 eCSR_ROAM_ASSOCIATION_COMPLETION,
Jeff Johnson295189b2012-06-20 16:38:30 -07004311 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004312 }
4313 }
4314 /* If the roaming has stopped, not to continue the roaming command*/
4315 if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
4316 {
4317 //No need to complete roaming here as it already completes
4318 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed"),
4319 pCommand->u.roamCmd.roamReason);
4320 eRoamState = eCsrStopRoaming;
4321 csrSetAbortRoamingCommand(pMac, pCommand);
4322 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004323 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304324 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004325 if(pScanResult)
4326 {
4327 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07004328 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
4329 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004330 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004331 fDone = eANI_BOOLEAN_TRUE;
4332 eRoamState = eCsrStopRoaming;
4333 break;
4334 }
4335 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
4336 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
4337 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
4338 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
4339 CSR_IS_QOS_BSS(pIesLocal) &&
4340 CSR_IS_UAPSD_BSS(pIesLocal) )
4341 {
4342#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Jeff Johnson295189b2012-06-20 16:38:30 -07004343 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
4344 pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004345#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004346 }
4347 else
4348 {
4349 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4350 }
4351 if( pIesLocal && !pScanResult->Result.pvIes)
4352 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304353 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004354 }
4355 }
4356 else
4357 {
4358 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4359 }
4360 roamInfo.pProfile = pProfile;
4361 pSession->bRefAssocStartCnt++;
4362 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4363 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4364 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004365 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
4366 {
4367 // If this is a start IBSS profile, then we need to start the IBSS.
4368 if ( CSR_IS_START_IBSS(pProfile) )
4369 {
4370 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004371 // Attempt to start this IBSS...
4372 csrRoamAssignDefaultParam( pMac, pCommand );
4373 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
4374 if(HAL_STATUS_SUCCESS(status))
4375 {
4376 if ( fSameIbss )
4377 {
4378 eRoamState = eCsrStartIbssSameIbss;
4379 }
4380 else
4381 {
4382 eRoamState = eCsrContinueRoaming;
4383 }
4384 }
4385 else
4386 {
4387 //it somehow fail need to stop
4388 eRoamState = eCsrStopRoaming;
4389 }
4390 break;
4391 }
4392 else if ( (CSR_IS_WDS_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004393 || (CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004394 )
4395 {
4396 // Attempt to start this WDS...
4397 csrRoamAssignDefaultParam( pMac, pCommand );
4398 /* For AP WDS, we dont have any BSSDescription */
4399 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
4400 if(HAL_STATUS_SUCCESS(status))
4401 {
4402 eRoamState = eCsrContinueRoaming;
4403 }
4404 else
4405 {
4406 //it somehow fail need to stop
4407 eRoamState = eCsrStopRoaming;
4408 }
4409 }
4410 else
4411 {
4412 //Nothing we can do
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004413 smsLog(pMac, LOGW, FL("cannot continue without BSS list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004414 eRoamState = eCsrStopRoaming;
4415 break;
4416 }
4417 }
4418 else //We have BSS
4419 {
4420 //Need to assign these value because they are used in csrIsSameProfile
4421 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Leela Venkata Kiran Kumar Reddy Chirala909b8812014-05-16 22:09:05 -07004422 /* The OSEN IE doesn't provide the cipher suite.
4423 * Therefore set to constant value of AES */
4424 if(pCommand->u.roamCmd.roamProfile.bOSENAssociation)
4425 {
4426 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4427 eCSR_ENCRYPT_TYPE_AES;
4428 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4429 eCSR_ENCRYPT_TYPE_AES;
4430 }
4431 else
4432 {
4433 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4434 pScanResult->ucEncryptionType; //Negotiated while building scan result.
4435 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4436 pScanResult->mcEncryptionType;
4437 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004438 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
4439 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
4440 {
4441 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4442 {
4443 eRoamState = eCsrStartIbssSameIbss;
4444 break;
4445 }
4446 }
4447 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
4448 {
4449 //trying to connect to the one already connected
4450 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
4451 eRoamState = eCsrReassocToSelfNoCapChange;
4452 break;
4453 }
4454 // Attempt to Join this Bss...
4455 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
4456 break;
4457 }
4458
4459 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004460 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
4461 {
4462 //Need to indicate association_completion if association_start has been done
4463 if(pSession->bRefAssocStartCnt > 0)
4464 {
4465 pSession->bRefAssocStartCnt--;
4466 //Complete the last association attemp because a new one is about to be tried
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004467 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07004468 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4469 eCSR_ROAM_ASSOCIATION_COMPLETION,
4470 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4471 }
4472 }
4473
4474 return( eRoamState );
4475}
4476
Jeff Johnson295189b2012-06-20 16:38:30 -07004477static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4478{
4479 eHalStatus status = eHAL_STATUS_SUCCESS;
4480 eCsrJoinState RoamState;
4481 tANI_U32 sessionId = pCommand->sessionId;
4482
Jeff Johnson295189b2012-06-20 16:38:30 -07004483 //***if( hddIsRadioStateOn( pAdapter ) )
4484 {
4485 // Attept to join a Bss...
4486 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07004487
Jeff Johnson295189b2012-06-20 16:38:30 -07004488 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07004489 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004490 {
4491 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004492 // and if connected in Infrastructure mode...
4493 if ( csrIsConnStateInfra(pMac, sessionId) )
4494 {
4495 //... then we need to issue a disassociation
4496 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
4497 if(!HAL_STATUS_SUCCESS(status))
4498 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004499 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004500 //roam command is completed by caller in the failed case
4501 fComplete = eANI_BOOLEAN_TRUE;
4502 }
4503 }
4504 else if( csrIsConnStateIbss(pMac, sessionId) )
4505 {
4506 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4507 if(!HAL_STATUS_SUCCESS(status))
4508 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004509 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004510 //roam command is completed by caller in the failed case
4511 fComplete = eANI_BOOLEAN_TRUE;
4512 }
4513 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004514 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
4515 {
4516 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4517 if(!HAL_STATUS_SUCCESS(status))
4518 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004519 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004520 //roam command is completed by caller in the failed case
4521 fComplete = eANI_BOOLEAN_TRUE;
4522 }
4523 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004524 else
4525 {
4526 fComplete = eANI_BOOLEAN_TRUE;
4527 }
4528 if(fComplete)
4529 {
4530 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07004531 if(eCsrStopRoamingDueToConcurrency == RoamState)
4532 {
4533 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
4534 }
4535 else
4536 {
4537 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
4538 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004539 }
4540 }
4541 else if ( eCsrReassocToSelfNoCapChange == RoamState )
4542 {
4543 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
4544 }
4545 else if ( eCsrStartIbssSameIbss == RoamState )
4546 {
4547 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
4548 }
4549 }//hddIsRadioStateOn
4550
4551 return status;
4552}
Jeff Johnson295189b2012-06-20 16:38:30 -07004553eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4554{
4555 tANI_U32 sessionId;
4556 tCsrRoamSession *pSession;
4557 tCsrScanResult *pScanResult = NULL;
4558 tSirBssDescription *pBssDesc = NULL;
4559 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004560 sessionId = pCommand->sessionId;
4561 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004562
4563 if(!pSession)
4564 {
4565 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4566 return eHAL_STATUS_FAILURE;
4567 }
4568
Jeff Johnson295189b2012-06-20 16:38:30 -07004569 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
4570 {
4571 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004572 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004573 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4574 return eHAL_STATUS_FAILURE;
4575 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004576 if (pCommand->u.roamCmd.pRoamBssEntry)
4577 {
4578 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4579 pBssDesc = &pScanResult->Result.BssDescriptor;
4580 }
4581 else
4582 {
4583 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004584 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004585 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4586 return eHAL_STATUS_FAILURE;
4587 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004588 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
4589 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
4590 return status;
4591}
4592
Jeff Johnson295189b2012-06-20 16:38:30 -07004593eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4594{
4595 eHalStatus status = eHAL_STATUS_SUCCESS;
4596 tCsrRoamInfo roamInfo;
4597 tANI_U32 sessionId = pCommand->sessionId;
4598 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004599
4600 if(!pSession)
4601 {
4602 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4603 return eHAL_STATUS_FAILURE;
4604 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004605
4606 switch ( pCommand->u.roamCmd.roamReason )
4607 {
4608 case eCsrForcedDisassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07004609 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004610 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004611 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004612 case eCsrSmeIssuedDisassocForHandoff:
4613 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
4614#if 0 // TODO : Confirm this change
4615 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
4616#else
4617 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4618#endif
4619
4620 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004621 case eCsrForcedDisassocMICFailure:
Jeff Johnson295189b2012-06-20 16:38:30 -07004622 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004623 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004624 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004625 case eCsrForcedDeauth:
Jeff Johnson295189b2012-06-20 16:38:30 -07004626 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004627 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004628 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004629 case eCsrHddIssuedReassocToSameAP:
4630 case eCsrSmeIssuedReassocToSameAP:
4631 {
4632 tDot11fBeaconIEs *pIes = NULL;
4633
Jeff Johnson295189b2012-06-20 16:38:30 -07004634 if( pSession->pConnectBssDesc )
4635 {
4636 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
4637 if(!HAL_STATUS_SUCCESS(status) )
4638 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004639 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004640 }
4641 else
4642 {
4643 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
4644 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
4645 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07004646 roamInfo.pBssDesc = pSession->pConnectBssDesc;
4647 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
4648 pSession->bRefAssocStartCnt++;
4649 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4650 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4651
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004652 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004653 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
4654 &pCommand->u.roamCmd.roamProfile );
4655 if(!HAL_STATUS_SUCCESS(status))
4656 {
4657 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08004658 csrReleaseCommandRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004659 }
4660
Kiet Lam64c1b492013-07-12 13:56:44 +05304661 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07004662 pIes = NULL;
4663 }
4664 }
4665 break;
4666 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004667 case eCsrCapsChange:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004668 smsLog(pMac, LOGE, FL("received eCsrCapsChange "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004669 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4670 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
4671 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004672 case eCsrSmeIssuedFTReassoc:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004673 smsLog(pMac, LOG1, FL("received FT Reassoc Req "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004674 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
4675 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07004676
Jeff Johnson295189b2012-06-20 16:38:30 -07004677 case eCsrStopBss:
4678 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4679 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4680 break;
4681
4682 case eCsrForcedDisassocSta:
4683 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4684 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
4685 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4686 pCommand->u.roamCmd.reason);
4687 break;
4688
4689 case eCsrForcedDeauthSta:
4690 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4691 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
4692 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4693 pCommand->u.roamCmd.reason);
4694 break;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004695
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004696 case eCsrPerformPreauth:
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08004697 smsLog(pMac, LOG1, FL("Attempting FT PreAuth Req"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004698 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
4699 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004700 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004701
4702 default:
4703 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4704
4705 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
4706 {
4707 //Remember the roaming profile
4708 csrFreeRoamProfile(pMac, sessionId);
Kiet Lam64c1b492013-07-12 13:56:44 +05304709 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
4710 if ( NULL != pSession->pCurRoamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004711 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304712 vos_mem_set(pSession->pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004713 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
4714 }
4715 }
4716
4717 //At this point, original uapsd_mask is saved in pCurRoamProfile
4718 //uapsd_mask in the pCommand may change from this point on.
4719
4720 // Attempt to roam with the new scan results (if we need to..)
4721 status = csrRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004722 if(!HAL_STATUS_SUCCESS(status))
4723 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004724 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X"), status);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004725 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004726 break;
4727 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004728 return (status);
4729}
4730
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004731void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4732{
4733 pCommand->u.roamCmd.pLastRoamBss = NULL;
4734 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4735 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05304736 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004737}
4738
Jeff Johnson295189b2012-06-20 16:38:30 -07004739void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4740{
4741 if(pCommand->u.roamCmd.fReleaseBssList)
4742 {
4743 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
4744 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
4745 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
4746 }
4747 if(pCommand->u.roamCmd.fReleaseProfile)
4748 {
4749 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
4750 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
4751 }
4752 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4753 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05304754 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004755}
4756
Jeff Johnson295189b2012-06-20 16:38:30 -07004757void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4758{
Kiet Lam64c1b492013-07-12 13:56:44 +05304759 vos_mem_set(&pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004760}
Jeff Johnson295189b2012-06-20 16:38:30 -07004761void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
4762{
4763 tListElem *pEntry;
4764 tSmeCmd *pCommand;
4765 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004766 smsLog( pMac, LOG2, "Roam Completion ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004767 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
4768 if ( pEntry )
4769 {
4770 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07004771 // If the head of the queue is Active and it is a ROAM command, remove
4772 // and put this on the Free queue.
4773 if ( eSmeCommandRoam == pCommand->command )
4774 {
4775 //we need to process the result first before removing it from active list because state changes
4776 //still happening insides roamQProcessRoamResults so no other roam command should be issued
4777 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
4778 if( fReleaseCommand )
4779 {
4780 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
4781 {
4782 csrReleaseCommandRoam( pMac, pCommand );
4783 }
4784 else
4785 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004786 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004787 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004788 }
4789 }
4790 else
4791 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004792 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004793 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004794 }
4795 }
4796 else
4797 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004798 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004799 }
4800 }
4801 else
4802 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004803 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004804 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004805 if( fReleaseCommand )
4806 {
4807 smeProcessPendingQueue( pMac );
4808 }
4809}
4810
Jeff Johnson295189b2012-06-20 16:38:30 -07004811void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4812{
4813 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004814 if(!pSession)
4815 {
4816 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4817 return;
4818 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304819 vos_mem_set(&(pSession->PmkidCandidateInfo[0]),
4820 sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004821 pSession->NumPmkidCandidate = 0;
4822}
Jeff Johnson295189b2012-06-20 16:38:30 -07004823#ifdef FEATURE_WLAN_WAPI
4824void csrResetBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4825{
4826 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004827 if(!pSession)
4828 {
4829 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4830 return;
4831 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304832 vos_mem_set(&(pSession->BkidCandidateInfo[0]),
4833 sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004834 pSession->NumBkidCandidate = 0;
4835}
4836#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004837extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
4838
Jeff Johnson295189b2012-06-20 16:38:30 -07004839static eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrAuthType authType,
4840 tSirBssDescription *pSirBssDesc,
4841 tDot11fBeaconIEs *pIes)
4842{
4843 eHalStatus status = eHAL_STATUS_SUCCESS;
4844 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4845 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004846
4847 if(!pSession)
4848 {
4849 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4850 return eHAL_STATUS_FAILURE;
4851 }
4852
Jeff Johnson295189b2012-06-20 16:38:30 -07004853 if((eCSR_AUTH_TYPE_WPA == authType) ||
4854 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
4855 (eCSR_AUTH_TYPE_RSN == authType) ||
4856 (eCSR_AUTH_TYPE_RSN_PSK == authType)
4857#if defined WLAN_FEATURE_VOWIFI_11R
4858 ||
4859 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4860 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
4861#endif /* FEATURE_WLAN_WAPI */
4862#ifdef FEATURE_WLAN_WAPI
4863 ||
4864 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4865 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
4866#endif /* FEATURE_WLAN_WAPI */
Chet Lanctot186b5732013-03-18 10:26:30 -07004867#ifdef WLAN_FEATURE_11W
4868 ||
4869 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType)
4870#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004871 )
4872 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004873 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4874 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004875 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004876 }
4877 if( pIesLocal )
4878 {
4879 tANI_U32 nIeLen;
4880 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07004881 if((eCSR_AUTH_TYPE_RSN == authType) ||
4882#if defined WLAN_FEATURE_VOWIFI_11R
4883 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4884 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
4885#endif /* WLAN_FEATURE_VOWIFI_11R */
Chet Lanctot186b5732013-03-18 10:26:30 -07004886#if defined WLAN_FEATURE_11W
4887 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
4888#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004889 (eCSR_AUTH_TYPE_RSN_PSK == authType))
4890 {
4891 if(pIesLocal->RSN.present)
4892 {
4893 //Calculate the actual length
4894 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
4895 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
4896 + 2 //akm_suite_count
4897 + pIesLocal->RSN.akm_suite_count * 4 //akm_suites
4898 + 2; //reserved
4899 if( pIesLocal->RSN.pmkid_count )
4900 {
4901 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
4902 }
4903 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304904 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
4905 if (NULL == pSession->pWpaRsnRspIE)
4906 status = eHAL_STATUS_FAILURE;
4907 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004908 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304909 vos_mem_set(pSession->pWpaRsnRspIE, nIeLen + 2, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004910 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
4911 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4912 //copy upto akm_suites
4913 pIeBuf = pSession->pWpaRsnRspIE + 2;
Kiet Lam64c1b492013-07-12 13:56:44 +05304914 vos_mem_copy(pIeBuf, &pIesLocal->RSN.version,
4915 sizeof(pIesLocal->RSN.version));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004916 pIeBuf += sizeof(pIesLocal->RSN.version);
Kiet Lam64c1b492013-07-12 13:56:44 +05304917 vos_mem_copy(pIeBuf, &pIesLocal->RSN.gp_cipher_suite,
4918 sizeof(pIesLocal->RSN.gp_cipher_suite));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004919 pIeBuf += sizeof(pIesLocal->RSN.gp_cipher_suite);
Kiet Lam64c1b492013-07-12 13:56:44 +05304920 vos_mem_copy(pIeBuf, &pIesLocal->RSN.pwise_cipher_suite_count,
4921 sizeof(pIesLocal->RSN.pwise_cipher_suite_count));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004922 pIeBuf += sizeof(pIesLocal->RSN.pwise_cipher_suite_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07004923 if( pIesLocal->RSN.pwise_cipher_suite_count )
4924 {
4925 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304926 vos_mem_copy(pIeBuf,
4927 pIesLocal->RSN.pwise_cipher_suites,
4928 pIesLocal->RSN.pwise_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004929 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
4930 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304931 vos_mem_copy(pIeBuf, &pIesLocal->RSN.akm_suite_count, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07004932 pIeBuf += 2;
4933 if( pIesLocal->RSN.akm_suite_count )
4934 {
4935 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05304936 vos_mem_copy(pIeBuf,
4937 pIesLocal->RSN.akm_suites,
4938 pIesLocal->RSN.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004939 pIeBuf += pIesLocal->RSN.akm_suite_count * 4;
4940 }
4941 //copy the rest
Kiet Lam64c1b492013-07-12 13:56:44 +05304942 vos_mem_copy(pIeBuf,
4943 pIesLocal->RSN.akm_suites + pIesLocal->RSN.akm_suite_count * 4,
4944 2 + pIesLocal->RSN.pmkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004945 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4946 }
4947 }
4948 }
4949 else if((eCSR_AUTH_TYPE_WPA == authType) ||
4950 (eCSR_AUTH_TYPE_WPA_PSK == authType))
4951 {
4952 if(pIesLocal->WPA.present)
4953 {
4954 //Calculate the actual length
4955 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
4956 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
4957 + 2 //auth_suite_count
4958 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
4959 // The WPA capabilities follows the Auth Suite (two octects)--
4960 // this field is optional, and we always "send" zero, so just
4961 // remove it. This is consistent with our assumptions in the
4962 // frames compiler; c.f. bug 15234:
4963 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304964
4965 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
4966 if ( NULL == pSession->pWpaRsnRspIE )
4967 status = eHAL_STATUS_FAILURE;
4968 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004969 {
4970 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
4971 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4972 pIeBuf = pSession->pWpaRsnRspIE + 2;
4973 //Copy WPA OUI
Kiet Lam64c1b492013-07-12 13:56:44 +05304974 vos_mem_copy(pIeBuf, &csrWpaOui[1], 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004975 pIeBuf += 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05304976 vos_mem_copy(pIeBuf, &pIesLocal->WPA.version,
4977 8 + pIesLocal->WPA.unicast_cipher_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004978 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05304979 vos_mem_copy(pIeBuf, &pIesLocal->WPA.auth_suite_count,
4980 2 + pIesLocal->WPA.auth_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07004981 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
4982 pSession->nWpaRsnRspIeLength = nIeLen + 2;
4983 }
4984 }
4985 }
4986#ifdef FEATURE_WLAN_WAPI
4987 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4988 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
4989 {
4990 if(pIesLocal->WAPI.present)
4991 {
4992 //Calculate the actual length
4993 nIeLen = 4 //version + akm_suite_count
4994 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
4995 + 2 //pwise_cipher_suite_count
4996 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
4997 + 6; //gp_cipher_suite + preauth + reserved
4998 if( pIesLocal->WAPI.bkid_count )
4999 {
5000 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
5001 }
5002
5003 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305004 pSession->pWapiRspIE = vos_mem_malloc(nIeLen + 2);
5005 if ( NULL == pSession->pWapiRspIE )
5006 status = eHAL_STATUS_FAILURE;
5007 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005008 {
5009 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
5010 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
5011 pIeBuf = pSession->pWapiRspIE + 2;
5012 //copy upto akm_suite_count
Kiet Lam64c1b492013-07-12 13:56:44 +05305013 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.version, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005014 pIeBuf += 4;
5015 if( pIesLocal->WAPI.akm_suite_count )
5016 {
5017 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305018 vos_mem_copy(pIeBuf, pIesLocal->WAPI.akm_suites,
5019 pIesLocal->WAPI.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005020 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305021 }
5022 vos_mem_copy(pIeBuf,
5023 &pIesLocal->WAPI.unicast_cipher_suite_count,
5024 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005025 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005026 if( pIesLocal->WAPI.unicast_cipher_suite_count )
5027 {
5028 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305029 vos_mem_copy( pIeBuf,
5030 pIesLocal->WAPI.unicast_cipher_suites,
5031 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005032 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
5033 }
lukez3c809222013-05-03 10:23:02 -07005034 //gp_cipher_suite
Kiet Lam64c1b492013-07-12 13:56:44 +05305035 vos_mem_copy(pIeBuf,
5036 pIesLocal->WAPI.multicast_cipher_suite,
5037 4);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005038 pIeBuf += 4;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305039 //preauth + reserved
Kiet Lam64c1b492013-07-12 13:56:44 +05305040 vos_mem_copy(pIeBuf,
5041 pIesLocal->WAPI.multicast_cipher_suite + 4,
5042 2);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005043 pIeBuf += 2;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305044 //bkid_count
Kiet Lam64c1b492013-07-12 13:56:44 +05305045 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.bkid_count, 2);
5046
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005047 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005048 if( pIesLocal->WAPI.bkid_count )
5049 {
5050 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305051 vos_mem_copy(pIeBuf, pIesLocal->WAPI.bkid,
5052 pIesLocal->WAPI.bkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005053 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
5054 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305055 pSession->nWapiRspIeLength = nIeLen + 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005056 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005057 }
5058 }
5059#endif /* FEATURE_WLAN_WAPI */
5060 if( !pIes )
5061 {
5062 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05305063 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07005064 }
5065 }
5066 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005067 return (status);
5068}
5069
Jeff Johnson295189b2012-06-20 16:38:30 -07005070static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
5071{
5072 v_U8_t bACWeights[WLANTL_MAX_AC];
5073 v_U8_t paramBk, paramBe, paramVi, paramVo;
5074 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005075 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
5076 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
5077 //of the higher AC one, make the higher AC has the same weight as the lower AC.
5078 //This doesn't address the case where the lower AC needs a real higher weight
5079 if( pIEs->WMMParams.present )
5080 {
5081 //no change to the lowest ones
5082 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
5083 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
5084 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
5085 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
5086 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
5087 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
5088 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
5089 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
5090 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
5091 {
5092 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
5093 fWeightChange = VOS_TRUE;
5094 }
5095 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
5096 {
5097 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
5098 fWeightChange = VOS_TRUE;
5099 }
5100 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
5101 {
5102 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
5103 fWeightChange = VOS_TRUE;
5104 }
5105 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
5106 {
5107 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
5108 fWeightChange = VOS_TRUE;
5109 }
5110 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
5111 {
5112 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
5113 fWeightChange = VOS_TRUE;
5114 }
5115 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
5116 {
5117 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
5118 fWeightChange = VOS_TRUE;
5119 }
5120 if(fWeightChange)
5121 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005122 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)"), bACWeights[0], bACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07005123 bACWeights[2], bACWeights[3]);
5124 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
5125 }
5126 }
5127}
Jeff Johnson295189b2012-06-20 16:38:30 -07005128#ifdef WLAN_FEATURE_VOWIFI_11R
5129//Returns whether the current association is a 11r assoc or not
5130tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
5131{
5132#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5133 return csrNeighborRoamIs11rAssoc(pMac);
5134#else
5135 return eANI_BOOLEAN_FALSE;
5136#endif
5137}
5138#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005139#ifdef FEATURE_WLAN_ESE
5140//Returns whether the current association is a ESE assoc or not
5141tANI_BOOLEAN csrRoamIsESEAssoc(tpAniSirGlobal pMac)
Jeff Johnson295189b2012-06-20 16:38:30 -07005142{
5143#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005144 return csrNeighborRoamIsESEAssoc(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07005145#else
5146 return eANI_BOOLEAN_FALSE;
5147#endif
5148}
5149#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005150#ifdef FEATURE_WLAN_LFR
5151//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305152tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005153{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305154 tCsrRoamSession *pSession = NULL;
5155
5156 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
5157 {
5158 pSession = CSR_GET_SESSION( pMac, sessionId );
5159 if (NULL != pSession->pCurRoamProfile)
5160 {
5161 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
5162 {
5163 return eANI_BOOLEAN_FALSE;
5164 }
5165 }
5166 }
5167
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005168#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5169 if (eANI_BOOLEAN_TRUE == CSR_IS_FASTROAM_IN_CONCURRENCY_INI_FEATURE_ENABLED(pMac))
5170 {
5171 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled);
5172 }
5173 else
5174#endif
5175 {
5176 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07005177 (!csrIsConcurrentSessionRunning(pMac)));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005178 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005179}
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005180
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005181#ifdef FEATURE_WLAN_ESE
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005182/* ---------------------------------------------------------------------------
5183
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005184 \fn csrNeighborRoamIsESEAssoc
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005185
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005186 \brief This function returns whether the current association is a ESE assoc or not
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005187
5188 \param pMac - The handle returned by macOpen.
5189
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005190 \return eANI_BOOLEAN_TRUE if current assoc is ESE, eANI_BOOLEAN_FALSE otherwise
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005191
5192---------------------------------------------------------------------------*/
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005193tANI_BOOLEAN csrNeighborRoamIsESEAssoc(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005194{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005195 return pMac->roam.neighborRoamInfo.isESEAssoc;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005196}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005197#endif /* FEATURE_WLAN_ESE */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005198
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005199#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5200//Returns whether "FW based BG scan" is currently enabled...or not
5201tANI_BOOLEAN csrRoamIsRoamOffloadScanEnabled(tpAniSirGlobal pMac)
5202{
5203 return (pMac->roam.configParam.isRoamOffloadScanEnabled);
5204}
5205#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005206#endif
5207
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005208#if defined(FEATURE_WLAN_ESE)
5209tANI_BOOLEAN csrRoamIsEseIniFeatureEnabled(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005210{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005211 return pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005212}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005213#endif /*FEATURE_WLAN_ESE*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005214
Jeff Johnson295189b2012-06-20 16:38:30 -07005215//Return true means the command can be release, else not
5216static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
5217 eCsrRoamCompleteResult Result, void *Context )
5218{
5219 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
5220 tSirBssDescription *pSirBssDesc = NULL;
5221 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
5222 tCsrScanResult *pScanResult = NULL;
5223 tCsrRoamInfo roamInfo;
5224 sme_QosAssocInfo assocInfo;
5225 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
5226 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
5227 tDot11fBeaconIEs *pIes = NULL;
5228 tANI_U32 sessionId = pCommand->sessionId;
5229 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5230 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
5231 eRoamCmdStatus roamStatus;
5232 eCsrRoamResult roamResult;
5233 eHalStatus status;
5234 tANI_U32 key_timeout_interval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005235 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005236
Jeff Johnson32d95a32012-09-10 13:15:23 -07005237 if(!pSession)
5238 {
5239 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5240 return eANI_BOOLEAN_FALSE;
5241 }
5242
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005243 smsLog( pMac, LOG1, FL("Processing ROAM results..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07005244 switch( Result )
5245 {
5246 case eCsrJoinSuccess:
5247 // reset the IDLE timer
5248 // !!
5249 // !! fall through to the next CASE statement here is intentional !!
5250 // !!
5251 case eCsrReassocSuccess:
5252 if(eCsrReassocSuccess == Result)
5253 {
5254 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
5255 }
5256 else
5257 {
5258 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
5259 }
5260 // Success Join Response from LIM. Tell NDIS we are connected and save the
5261 // Connected state...
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005262 smsLog(pMac, LOGW, FL("receives association indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305263 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005264 //always free the memory here
5265 if(pSession->pWpaRsnRspIE)
5266 {
5267 pSession->nWpaRsnRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305268 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005269 pSession->pWpaRsnRspIE = NULL;
5270 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005271#ifdef FEATURE_WLAN_WAPI
5272 if(pSession->pWapiRspIE)
5273 {
5274 pSession->nWapiRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305275 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005276 pSession->pWapiRspIE = NULL;
5277 }
5278#endif /* FEATURE_WLAN_WAPI */
5279#ifdef FEATURE_WLAN_BTAMP_UT_RF
5280 //Reset counter so no join retry is needed.
5281 pSession->maxRetryCount = 0;
5282 csrRoamStopJoinRetryTimer(pMac, sessionId);
5283#endif
5284 /* This creates problem since we have not saved the connected profile.
5285 So moving this after saving the profile
5286 */
5287 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
Abhishek Singh36abbcb2014-03-20 13:04:09 +05305288
5289 /* Reset remainInPowerActiveTillDHCP as it might have been set
5290 * by last failed secured connection.
5291 * It should be set only for secured connection.
5292 */
5293 pMac->pmc.remainInPowerActiveTillDHCP = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005294 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
5295 {
5296 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
5297 }
5298 else
5299 {
5300 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
5301 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005302 //Use the last connected bssdesc for reassoc-ing to the same AP.
5303 //NOTE: What to do when reassoc to a different AP???
5304 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5305 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5306 {
5307 pSirBssDesc = pSession->pConnectBssDesc;
5308 if(pSirBssDesc)
5309 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305310 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5311 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005312 }
5313 }
5314 else
5315 {
5316
5317 if(pCommand->u.roamCmd.pRoamBssEntry)
5318 {
5319 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
5320 if(pScanResult != NULL)
5321 {
5322 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5323 //this can be NULL
5324 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
Kiet Lam64c1b492013-07-12 13:56:44 +05305325 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5326 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005327 }
5328 }
5329 }
5330 if( pSirBssDesc )
5331 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005332 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07005333 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5334 //Save WPA/RSN IE
5335 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005336#ifdef FEATURE_WLAN_ESE
5337 roamInfo.isESEAssoc = pSession->connectedProfile.isESEAssoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005338#endif
5339
5340 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
5341 // substate change.
5342 // Moving even save profile above so that below mentioned conditon is also met.
5343 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
5344 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005345 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
5346 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
5347 // will be dropped for the security context may not be set properly.
5348 //
5349 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
5350 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
5351 //
5352 // this reordering was done on titan_prod_usb branch and is being replicated here.
5353 //
5354
5355 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
5356 !pProfile->bWPSAssociation)
5357 {
5358 // Issue the set Context request to LIM to establish the Unicast STA context
5359 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
5360 pProfile->negotiatedUCEncryptionType,
5361 pSirBssDesc, &(pSirBssDesc->bssId),
5362 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
5363 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005364 smsLog( pMac, LOGE, FL(" Set context for unicast fail") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005365 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5366 }
5367 // Issue the set Context request to LIM to establish the Broadcast STA context
5368 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
5369 pSirBssDesc, &BroadcastMac,
5370 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5371 }
5372 else
5373 {
5374 //Need to wait for supplicant authtication
5375 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005376 //Set the subestate to WaitForKey in case authentiation is needed
5377 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
5378
Jeff Johnson295189b2012-06-20 16:38:30 -07005379 if(pProfile->bWPSAssociation)
5380 {
5381 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
5382 }
5383 else
5384 {
5385 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
5386 }
5387
5388 //Save sessionId in case of timeout
5389 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
5390 //This time should be long enough for the rest of the process plus setting key
5391 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
5392 {
5393 //Reset our state so nothting is blocked.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005394 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005395 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
5396 }
5397 }
5398
5399 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
5400 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005401 if(Context)
5402 {
5403 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
5404 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07005405 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5406 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
5407#ifdef WLAN_FEATURE_VOWIFI_11R
5408 len += pJoinRsp->parsedRicRspLen;
5409#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005410#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005411 len += pJoinRsp->tspecIeLen;
5412#endif
5413 if(len)
5414 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305415 pSession->connectedInfo.pbFrames = vos_mem_malloc(len);
5416 if ( pSession->connectedInfo.pbFrames != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07005417 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305418 vos_mem_copy(pSession->connectedInfo.pbFrames,
5419 pJoinRsp->frames, len);
5420 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5421 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5422 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
Jeff Johnson295189b2012-06-20 16:38:30 -07005423#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05305424 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005425#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005426#ifdef FEATURE_WLAN_ESE
Kiet Lam64c1b492013-07-12 13:56:44 +05305427 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005428#endif
Kiet Lam64c1b492013-07-12 13:56:44 +05305429 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5430 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5431 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
5432 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
Jeff Johnson295189b2012-06-20 16:38:30 -07005433 }
5434 }
5435 if(pCommand->u.roamCmd.fReassoc)
5436 {
5437 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5438 }
5439 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5440 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5441 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
5442 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
c_hpothu44ff4e02014-05-08 00:13:57 +05305443 roamInfo.maxRateFlags = pJoinRsp->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -07005444 }
5445 else
5446 {
5447 if(pCommand->u.roamCmd.fReassoc)
5448 {
5449 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5450 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5451 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5452 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5453 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5454 }
5455 }
5456#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5457 // Indicate SME-QOS with reassoc success event, only after
5458 // copying the frames
5459 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
5460#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005461 roamInfo.pBssDesc = pSirBssDesc;
5462 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5463 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5464#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5465 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
5466#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
5467 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005468 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
5469 //It may be better to let QoS do this????
5470 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
5471 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005472 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now",
Jeff Johnson295189b2012-06-20 16:38:30 -07005473 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
5474 pmcStartUapsd( pMac, NULL, NULL );
5475 }
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05305476 pSession->connectedProfile.dot11Mode = pSession->bssParams.uCfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005477 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5478 if( pSession->bRefAssocStartCnt > 0 )
5479 {
5480 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005481 //Remove this code once SLM_Sessionization is supported
5482 //BMPS_WORKAROUND_NOT_NEEDED
5483 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005484 {
5485 pMac->roam.configParam.doBMPSWorkaround = 1;
5486 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005487 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5488 }
5489
5490 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005491 // reset the PMKID candidate list
5492 csrResetPMKIDCandidateList( pMac, sessionId );
5493 //Update TL's AC weight base on the current EDCA parameters
5494 //These parameters may change in the course of the connection, that sictuation
5495 //is not taken care here. This change is mainly to address a WIFI WMM test where
5496 //BE has a equal or higher TX priority than VI.
5497 //We only do this for infra link
5498 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
5499 {
5500 csrCheckAndUpdateACWeight(pMac, pIes);
5501 }
5502#ifdef FEATURE_WLAN_WAPI
5503 // reset the BKID candidate list
5504 csrResetBKIDCandidateList( pMac, sessionId );
5505#endif /* FEATURE_WLAN_WAPI */
5506 }
5507 else
5508 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005509 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc");
Jeff Johnson295189b2012-06-20 16:38:30 -07005510 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005511 csrScanCancelIdleScan(pMac);
5512 //Not to signal link up because keys are yet to be set.
5513 //The linkup function will overwrite the sub-state that we need to keep at this point.
5514 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
5515 {
5516 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
5517 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005518 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
5519 //enough to let security and DHCP handshake succeed before entry into BMPS
5520 if (pmcShouldBmpsTimerRun(pMac))
5521 {
Abhishek Singh65d939e2014-04-25 13:33:07 +05305522 /* Set remainInPowerActiveTillDHCP to make sure we wait for
5523 * until keys are set before going into BMPS.
5524 */
5525 if(eANI_BOOLEAN_TRUE == roamInfo.fAuthRequired)
5526 {
5527 pMac->pmc.remainInPowerActiveTillDHCP = TRUE;
5528 smsLog(pMac, LOG1, FL("Set remainInPowerActiveTillDHCP "
5529 "to make sure we wait until keys are set before"
5530 " going to BMPS"));
5531 }
5532
Jeff Johnson295189b2012-06-20 16:38:30 -07005533 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
5534 != eHAL_STATUS_SUCCESS)
5535 {
5536 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
5537 }
5538 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
5539 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005540 break;
5541
Jeff Johnson295189b2012-06-20 16:38:30 -07005542 case eCsrStartBssSuccess:
5543 // on the StartBss Response, LIM is returning the Bss Description that we
5544 // are beaconing. Add this Bss Description to our scan results and
5545 // chain the Profile to this Bss Description. On a Start BSS, there was no
5546 // detected Bss description (no partner) so we issued the Start Bss to
5547 // start the Ibss without any Bss description. Lim was kind enough to return
5548 // the Bss Description that we start beaconing for the newly started Ibss.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005549 smsLog(pMac, LOG2, FL("receives start BSS ok indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005550 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005551 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
Kiet Lam64c1b492013-07-12 13:56:44 +05305552 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005553 if( CSR_IS_IBSS( pProfile ) )
5554 {
5555 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
5556 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005557 else if (CSR_IS_INFRA_AP(pProfile))
5558 {
5559 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
5560 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005561 else
5562 {
5563 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
5564 }
5565 if( !CSR_IS_WDS_STA( pProfile ) )
5566 {
5567 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005568 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
Jeff Johnson295189b2012-06-20 16:38:30 -07005569 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
5570 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05305571 smsLog(pMac, LOGW, FL("cannot parse IBSS IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005572 roamInfo.pBssDesc = pSirBssDesc;
5573 //We need to associate_complete it first, becasue Associate_start already indicated.
5574 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5575 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
5576 break;
5577 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005578 if (!CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07005579 {
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07005580 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005581 }
5582 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
5583 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5584 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5585 if(pSirBssDesc)
5586 {
5587 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
Kiet Lam64c1b492013-07-12 13:56:44 +05305588 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5589 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005590 }
5591 //We are doen with the IEs so free it
Kiet Lam64c1b492013-07-12 13:56:44 +05305592 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005593#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5594 {
5595 vos_log_ibss_pkt_type *pIbssLog;
5596 tANI_U32 bi;
5597
5598 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5599 if(pIbssLog)
5600 {
5601 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5602 {
5603 //We start the IBSS (didn't find any matched IBSS out there)
5604 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
5605 }
5606 else
5607 {
5608 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
5609 }
5610 if(pSirBssDesc)
5611 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305612 vos_mem_copy(pIbssLog->bssid, pSirBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07005613 pIbssLog->operatingChannel = pSirBssDesc->channelId;
5614 }
5615 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
5616 {
5617 //***U8 is not enough for beacon interval
5618 pIbssLog->beaconInterval = (v_U8_t)bi;
5619 }
5620 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5621 }
5622 }
5623#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5624 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
5625 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07005626 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
5627 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005628 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
5629 csrRoamIssueSetContextReq( pMac, sessionId,
5630 pProfile->negotiatedMCEncryptionType,
5631 pSirBssDesc, &BroadcastMac,
5632 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5633 }
5634 }
5635 else
5636 {
5637 //Keep the state to eCSR_ROAMING_STATE_JOINING
5638 //Need to send join_req.
5639 if(pCommand->u.roamCmd.pRoamBssEntry)
5640 {
5641 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
5642 {
5643 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5644 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
5645 // Set the roaming substate to 'join attempt'...
5646 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08005647 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07005648 }
5649 }
5650 else
5651 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005652 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc" );
Jeff Johnson295189b2012-06-20 16:38:30 -07005653 VOS_ASSERT( 0 );
5654 }
5655 }
5656 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5657 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5658 //trigger the connection start indication in Vista
5659 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
5660 {
5661 roamStatus = eCSR_ROAM_IBSS_IND;
5662 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5663 if( CSR_IS_WDS( pProfile ) )
5664 {
5665 roamStatus = eCSR_ROAM_WDS_IND;
5666 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5667 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005668 if( CSR_IS_INFRA_AP( pProfile ) )
5669 {
5670 roamStatus = eCSR_ROAM_INFRA_IND;
5671 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
5672 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005673
5674 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5675 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5676 //trigger the connection start indication in Vista
Kiet Lam64c1b492013-07-12 13:56:44 +05305677 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005678 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5679 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
krunal soni3fc26642013-10-08 22:41:42 -07005680 //We start the IBSS (didn't find any matched IBSS out there)
5681 roamInfo.pBssDesc = pSirBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005682 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
Kiet Lam64c1b492013-07-12 13:56:44 +05305683 vos_mem_copy(roamInfo.bssid, pSirBssDesc->bssId,
5684 sizeof(tCsrBssid));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005685 //Remove this code once SLM_Sessionization is supported
5686 //BMPS_WORKAROUND_NOT_NEEDED
5687 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07005688 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005689 {
5690 pMac->roam.configParam.doBMPSWorkaround = 1;
5691 }
Mohit Khanna349bc392012-09-11 17:24:52 -07005692
Jeff Johnson295189b2012-06-20 16:38:30 -07005693 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5694 }
5695
5696 csrScanCancelIdleScan(pMac);
Ravi Joshi414b14c2013-10-04 16:33:26 -07005697
5698 if( CSR_IS_WDS_STA( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005699 {
5700 //need to send stop BSS because we fail to send join_req
5701 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
5702 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5703 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
5704 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005705 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005706 case eCsrStartBssFailure:
5707#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5708 {
5709 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07005710 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5711 if(pIbssLog)
5712 {
5713 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
5714 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5715 }
5716 }
5717#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07005718 roamStatus = eCSR_ROAM_IBSS_IND;
5719 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5720 if( CSR_IS_WDS( pProfile ) )
5721 {
5722 roamStatus = eCSR_ROAM_WDS_IND;
5723 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5724 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005725 if( CSR_IS_INFRA_AP( pProfile ) )
5726 {
5727 roamStatus = eCSR_ROAM_INFRA_IND;
5728 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
5729 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005730 if(Context)
5731 {
5732 pSirBssDesc = (tSirBssDescription *)Context;
5733 }
5734 else
5735 {
5736 pSirBssDesc = NULL;
5737 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305738 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005739 roamInfo.pBssDesc = pSirBssDesc;
5740 //We need to associate_complete it first, becasue Associate_start already indicated.
5741 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5742 csrSetDefaultDot11Mode( pMac );
5743 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005744 case eCsrSilentlyStopRoaming:
5745 // We are here because we try to start the same IBSS
5746 //No message to PE
5747 // return the roaming state to Joined.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005748 smsLog(pMac, LOGW, FL("receives silently roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005749 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
5750 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05305751 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005752 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5753 if( roamInfo.pBssDesc )
5754 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305755 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5756 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005757 }
5758 //Since there is no change in the current state, simply pass back no result otherwise
5759 //HDD may be mistakenly mark to disconnected state.
5760 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5761 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005762 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005763 case eCsrSilentlyStopRoamingSaveState:
5764 //We are here because we try to connect to the same AP
5765 //No message to PE
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005766 smsLog(pMac, LOGW, FL("receives silently stop roaming indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305767 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005768
5769 //to aviod resetting the substate to NONE
5770 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
5771 //No need to change substate to wai_for_key because there is no state change
5772 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5773 if( roamInfo.pBssDesc )
5774 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305775 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5776 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005777 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005778 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5779 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5780 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5781 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5782 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5783 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5784 roamInfo.staId = pSession->connectedInfo.staId;
5785 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005786 VOS_ASSERT( roamInfo.staId != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005787 pSession->bRefAssocStartCnt--;
5788 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5789 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5790 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
5791 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005792 case eCsrReassocFailure:
5793#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5794 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
5795#endif
5796 case eCsrJoinWdsFailure:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005797 smsLog(pMac, LOGW, FL("failed to join WDS"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005798 csrFreeConnectBssDesc(pMac, sessionId);
5799 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5800 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
Kiet Lam64c1b492013-07-12 13:56:44 +05305801 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005802 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5803 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5804 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5805 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5806 eCSR_ROAM_WDS_IND,
5807 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
5808 //Need to issue stop_bss
5809 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005810 case eCsrJoinFailure:
5811 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07005812 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07005813 default:
5814 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005815 smsLog(pMac, LOGW, FL("receives no association indication"));
5816 smsLog(pMac, LOG1, FL("Assoc ref count %d"),
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07005817 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07005818 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
5819 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
5820 {
5821 //do not free for the other profiles as we need to send down stop BSS later
5822 csrFreeConnectBssDesc(pMac, sessionId);
5823 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5824 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5825 csrSetDefaultDot11Mode( pMac );
5826 }
5827
5828 switch( pCommand->u.roamCmd.roamReason )
5829 {
5830 // If this transition is because of an 802.11 OID, then we transition
5831 // back to INIT state so we sit waiting for more OIDs to be issued and
5832 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07005833 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07005834 case eCsrSmeIssuedAssocToSimilarAP:
5835 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08005836 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07005837 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05305838 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005839 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5840 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5841 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Kiet Lam64c1b492013-07-12 13:56:44 +05305842 vos_mem_copy(&roamInfo.bssid,
5843 &pSession->joinFailStatusCode.bssId,
5844 sizeof(tCsrBssid));
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005845
Jeff Johnson295189b2012-06-20 16:38:30 -07005846 /* Defeaturize this later if needed */
5847#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5848 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
5849 if (csrRoamIsHandoffInProgress(pMac))
5850 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005851 /* Should indicate neighbor roam algorithm about the connect failure here */
5852 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
5853 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005854#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005855 if(pSession->bRefAssocStartCnt > 0)
5856 {
5857 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07005858 if(eCsrJoinFailureDueToConcurrency == Result)
5859 {
5860 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5861 eCSR_ROAM_ASSOCIATION_COMPLETION,
5862 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
5863 }
5864 else
5865 {
5866 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005867 eCSR_ROAM_ASSOCIATION_COMPLETION,
5868 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07005869 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005870 }
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005871 else
5872 {
5873 /* bRefAssocStartCnt is not incremented when
5874 * eRoamState == eCsrStopRoamingDueToConcurrency
5875 * in csrRoamJoinNextBss API. so handle this in
5876 * else case by sending assoc failure
5877 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005878 csrRoamCallCallback(pMac, sessionId, &roamInfo,
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005879 pCommand->u.scanCmd.roamId,
5880 eCSR_ROAM_ASSOCIATION_FAILURE,
5881 eCSR_ROAM_RESULT_FAILURE);
5882 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005883 smsLog(pMac, LOG1, FL(" roam(reason %d) failed"), pCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07005884#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Mukul Sharma5960ac82014-01-09 20:31:35 +05305885 sme_QosUpdateHandOff((tANI_U8)sessionId, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005886 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5887#endif
5888 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5889 csrScanStartIdleScan(pMac);
5890#ifdef FEATURE_WLAN_BTAMP_UT_RF
5891 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
5892 //BT activity and not able to recevie WLAN traffic. Retry the join
5893 if( CSR_IS_WDS_STA(pProfile) )
5894 {
5895 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
5896 }
5897#endif
5898 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005899 case eCsrHddIssuedReassocToSameAP:
5900 case eCsrSmeIssuedReassocToSameAP:
5901 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5902
5903 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5904#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5905 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5906#endif
5907 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5908 csrScanStartIdleScan(pMac);
5909 break;
5910 case eCsrForcedDisassoc:
5911 case eCsrForcedDeauth:
5912 case eCsrSmeIssuedIbssJoinFailure:
5913 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5914
5915 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
5916 {
5917 // Notify HDD that IBSS join failed
5918 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
5919 }
5920 else
5921 {
5922 csrRoamCallCallback(pMac, sessionId, NULL,
5923 pCommand->u.roamCmd.roamId,
5924 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5925 }
5926#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5927 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5928#endif
5929 csrRoamLinkDown(pMac, sessionId);
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08005930 /*
5931 *DelSta not done FW still in conneced state so dont
5932 *issue IMPS req
5933 */
5934 if (pMac->roam.deauthRspStatus == eSIR_SME_DEAUTH_STATUS)
5935 {
5936 smsLog(pMac, LOGW, FL("FW still in connected state "));
5937 break;
5938 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005939 csrScanStartIdleScan(pMac);
5940 break;
5941 case eCsrForcedIbssLeave:
5942 csrRoamCallCallback(pMac, sessionId, NULL,
5943 pCommand->u.roamCmd.roamId,
5944 eCSR_ROAM_IBSS_LEAVE,
5945 eCSR_ROAM_RESULT_IBSS_STOP);
5946 break;
5947 case eCsrForcedDisassocMICFailure:
5948 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5949
5950 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
5951#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5952 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
5953#endif
5954 csrScanStartIdleScan(pMac);
5955 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005956 case eCsrStopBss:
5957 csrRoamCallCallback(pMac, sessionId, NULL,
5958 pCommand->u.roamCmd.roamId,
5959 eCSR_ROAM_INFRA_IND,
5960 eCSR_ROAM_RESULT_INFRA_STOPPED);
5961 break;
5962 case eCsrForcedDisassocSta:
5963 case eCsrForcedDeauthSta:
5964 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
5965 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
5966 {
5967 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07005968
5969 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
5970 {
5971 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05305972 vos_mem_copy(roamInfo.peerMac,
5973 pCommand->u.roamCmd.peerMac,
5974 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07005975 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
5976 roamInfo.statusCode = eSIR_SME_SUCCESS;
5977 status = csrRoamCallCallback(pMac, sessionId,
5978 &roamInfo, pCommand->u.roamCmd.roamId,
5979 eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
5980 }
5981 }
5982 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005983 case eCsrLostLink1:
5984 // if lost link roam1 failed, then issue lost link Scan2 ...
5985 csrScanRequestLostLink2(pMac, sessionId);
5986 break;
5987 case eCsrLostLink2:
5988 // if lost link roam2 failed, then issue lost link scan3 ...
5989 csrScanRequestLostLink3(pMac, sessionId);
5990 break;
5991 case eCsrLostLink3:
5992 default:
5993 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
5994
5995 //We are done with one round of lostlink roaming here
5996 csrScanHandleFailedLostlink3(pMac, sessionId);
5997 break;
5998 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005999 break;
6000 }
6001 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006002 return ( fReleaseCommand );
6003}
6004
Jeff Johnson295189b2012-06-20 16:38:30 -07006005eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
6006{
6007 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006008 return (status);
6009}
6010
Jeff Johnson295189b2012-06-20 16:38:30 -07006011eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
6012{
6013 eHalStatus status = eHAL_STATUS_SUCCESS;
6014 tANI_U32 size = 0;
6015
6016 do
6017 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306018 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006019 if(pSrcProfile->BSSIDs.numOfBSSIDs)
6020 {
6021 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306022 pDstProfile->BSSIDs.bssid = vos_mem_malloc(size);
6023 if ( NULL == pDstProfile->BSSIDs.bssid )
6024 status = eHAL_STATUS_FAILURE;
6025 else
6026 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006027 if(!HAL_STATUS_SUCCESS(status))
6028 {
6029 break;
6030 }
6031 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306032 vos_mem_copy(pDstProfile->BSSIDs.bssid,
6033 pSrcProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07006034 }
6035 if(pSrcProfile->SSIDs.numOfSSIDs)
6036 {
6037 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306038 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(size);
6039 if ( NULL == pDstProfile->SSIDs.SSIDList )
6040 status = eHAL_STATUS_FAILURE;
6041 else
6042 status = eHAL_STATUS_SUCCESS;
6043 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006044 {
6045 break;
6046 }
6047 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306048 vos_mem_copy(pDstProfile->SSIDs.SSIDList,
6049 pSrcProfile->SSIDs.SSIDList, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07006050 }
6051 if(pSrcProfile->nWPAReqIELength)
6052 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306053 pDstProfile->pWPAReqIE = vos_mem_malloc(pSrcProfile->nWPAReqIELength);
6054 if ( NULL == pDstProfile->pWPAReqIE )
6055 status = eHAL_STATUS_FAILURE;
6056 else
6057 status = eHAL_STATUS_SUCCESS;
6058
6059 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006060 {
6061 break;
6062 }
6063 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306064 vos_mem_copy(pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE,
6065 pSrcProfile->nWPAReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006066 }
6067 if(pSrcProfile->nRSNReqIELength)
6068 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306069 pDstProfile->pRSNReqIE = vos_mem_malloc(pSrcProfile->nRSNReqIELength);
6070 if ( NULL == pDstProfile->pRSNReqIE )
6071 status = eHAL_STATUS_FAILURE;
6072 else
6073 status = eHAL_STATUS_SUCCESS;
6074
6075 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006076 {
6077 break;
6078 }
6079 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306080 vos_mem_copy(pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE,
6081 pSrcProfile->nRSNReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006082 }
6083#ifdef FEATURE_WLAN_WAPI
6084 if(pSrcProfile->nWAPIReqIELength)
6085 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306086 pDstProfile->pWAPIReqIE = vos_mem_malloc(pSrcProfile->nWAPIReqIELength);
6087 if ( NULL == pDstProfile->pWAPIReqIE )
6088 status = eHAL_STATUS_FAILURE;
6089 else
6090 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006091 if(!HAL_STATUS_SUCCESS(status))
6092 {
6093 break;
6094 }
6095 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306096 vos_mem_copy(pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE,
6097 pSrcProfile->nWAPIReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006098 }
6099#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07006100 if(pSrcProfile->nAddIEScanLength)
6101 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05306102 memset(pDstProfile->addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH);
6103 if ( SIR_MAC_MAX_IE_LENGTH >= pSrcProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -07006104 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05306105 vos_mem_copy(pDstProfile->addIEScan, pSrcProfile->addIEScan,
Kiet Lam64c1b492013-07-12 13:56:44 +05306106 pSrcProfile->nAddIEScanLength);
Agarwal Ashish4f616132013-12-30 23:32:50 +05306107 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
6108 }
6109 else
6110 {
6111 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
6112 FL(" AddIEScanLength is not valid %u"),
6113 pSrcProfile->nAddIEScanLength);
6114 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006115 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006116 if(pSrcProfile->nAddIEAssocLength)
6117 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306118 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6119 if ( NULL == pDstProfile->pAddIEAssoc )
6120 status = eHAL_STATUS_FAILURE;
6121 else
6122 status = eHAL_STATUS_SUCCESS;
6123
Jeff Johnson295189b2012-06-20 16:38:30 -07006124 if(!HAL_STATUS_SUCCESS(status))
6125 {
6126 break;
6127 }
6128 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306129 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6130 pSrcProfile->nAddIEAssocLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006131 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006132 if(pSrcProfile->ChannelInfo.ChannelList)
6133 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306134 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(
6135 pSrcProfile->ChannelInfo.numOfChannels);
6136 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6137 status = eHAL_STATUS_FAILURE;
6138 else
6139 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006140 if(!HAL_STATUS_SUCCESS(status))
6141 {
6142 break;
6143 }
6144 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
Kiet Lam64c1b492013-07-12 13:56:44 +05306145 vos_mem_copy(pDstProfile->ChannelInfo.ChannelList,
6146 pSrcProfile->ChannelInfo.ChannelList,
6147 pSrcProfile->ChannelInfo.numOfChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07006148 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006149 pDstProfile->AuthType = pSrcProfile->AuthType;
6150 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
6151 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
6152 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
6153 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
6154 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
Chet Lanctot186b5732013-03-18 10:26:30 -07006155#ifdef WLAN_FEATURE_11W
6156 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
6157 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
6158 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
6159#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006160 pDstProfile->BSSType = pSrcProfile->BSSType;
6161 pDstProfile->phyMode = pSrcProfile->phyMode;
6162 pDstProfile->csrPersona = pSrcProfile->csrPersona;
6163
6164#ifdef FEATURE_WLAN_WAPI
6165 if(csrIsProfileWapi(pSrcProfile))
6166 {
6167 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
6168 {
6169 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
6170 }
6171 }
6172#endif /* FEATURE_WLAN_WAPI */
6173 pDstProfile->CBMode = pSrcProfile->CBMode;
6174 /*Save the WPS info*/
6175 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006176 pDstProfile->bOSENAssociation = pSrcProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07006177 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006178 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07006179 pDstProfile->privacy = pSrcProfile->privacy;
6180 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
6181 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
6182 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
6183 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
6184 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
6185 pDstProfile->protEnabled = pSrcProfile->protEnabled;
6186 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
6187 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
6188 pDstProfile->wps_state = pSrcProfile->wps_state;
6189 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
Kiet Lam64c1b492013-07-12 13:56:44 +05306190 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6191 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006192#ifdef WLAN_FEATURE_VOWIFI_11R
6193 if (pSrcProfile->MDID.mdiePresent)
6194 {
6195 pDstProfile->MDID.mdiePresent = 1;
6196 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6197 }
6198#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006199 }while(0);
6200
6201 if(!HAL_STATUS_SUCCESS(status))
6202 {
6203 csrReleaseProfile(pMac, pDstProfile);
6204 pDstProfile = NULL;
6205 }
6206
6207 return (status);
6208}
Jeff Johnson295189b2012-06-20 16:38:30 -07006209eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
6210{
6211 eHalStatus status = eHAL_STATUS_SUCCESS;
6212 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
6213 do
6214 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306215 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006216 if(pSrcProfile->bssid)
6217 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306218 pDstProfile->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
6219 if ( NULL == pDstProfile->BSSIDs.bssid )
6220 status = eHAL_STATUS_FAILURE;
6221 else
6222 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006223 if(!HAL_STATUS_SUCCESS(status))
6224 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306225 smsLog( pMac, LOGE,
6226 FL("failed to allocate memory for BSSID"
6227 "%02x:%02x:%02x:%02x:%02x:%02x"),
6228 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6229 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006230 break;
6231 }
6232 pDstProfile->BSSIDs.numOfBSSIDs = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05306233 vos_mem_copy(pDstProfile->BSSIDs.bssid, pSrcProfile->bssid,
6234 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006235 }
6236 if(pSrcProfile->SSID.ssId)
6237 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306238 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
6239 if ( NULL == pDstProfile->SSIDs.SSIDList )
6240 status = eHAL_STATUS_FAILURE;
6241 else
6242 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006243 if(!HAL_STATUS_SUCCESS(status))
6244 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306245 smsLog( pMac, LOGE,
6246 FL("failed to allocate memory for SSIDList"
6247 "%02x:%02x:%02x:%02x:%02x:%02x"),
6248 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6249 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006250 break;
6251 }
6252 pDstProfile->SSIDs.numOfSSIDs = 1;
6253 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
6254 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
Kiet Lam64c1b492013-07-12 13:56:44 +05306255 vos_mem_copy(&pDstProfile->SSIDs.SSIDList[0].SSID,
6256 &pSrcProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006257 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006258 if(pSrcProfile->nAddIEAssocLength)
6259 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306260 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6261 if ( NULL == pDstProfile->pAddIEAssoc)
6262 status = eHAL_STATUS_FAILURE;
6263 else
6264 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006265 if(!HAL_STATUS_SUCCESS(status))
6266 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006267 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs ") );
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006268 break;
6269 }
6270 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306271 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6272 pSrcProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006273 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306274 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(1);
6275 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6276 status = eHAL_STATUS_FAILURE;
6277 else
6278 status = eHAL_STATUS_SUCCESS;
6279
Jeff Johnson295189b2012-06-20 16:38:30 -07006280 if(!HAL_STATUS_SUCCESS(status))
6281 {
6282 break;
6283 }
6284 pDstProfile->ChannelInfo.numOfChannels = 1;
6285 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006286 pDstProfile->AuthType.numEntries = 1;
6287 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
6288 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
6289 pDstProfile->EncryptionType.numEntries = 1;
6290 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
6291 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
6292 pDstProfile->mcEncryptionType.numEntries = 1;
6293 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
6294 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
6295 pDstProfile->BSSType = pSrcProfile->BSSType;
6296 pDstProfile->CBMode = pSrcProfile->CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +05306297 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6298 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006299#ifdef WLAN_FEATURE_VOWIFI_11R
6300 if (pSrcProfile->MDID.mdiePresent)
6301 {
6302 pDstProfile->MDID.mdiePresent = 1;
6303 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6304 }
6305#endif
6306
6307 }while(0);
6308
6309 if(!HAL_STATUS_SUCCESS(status))
6310 {
6311 csrReleaseProfile(pMac, pDstProfile);
6312 pDstProfile = NULL;
6313 }
6314
6315 return (status);
6316}
6317
Jeff Johnson295189b2012-06-20 16:38:30 -07006318eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6319 tScanResultHandle hBSSList,
6320 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
6321 tANI_BOOLEAN fClearScan)
6322{
6323 eHalStatus status = eHAL_STATUS_SUCCESS;
6324 tSmeCmd *pCommand;
6325
6326 pCommand = csrGetCommandBuffer(pMac);
6327 if(NULL == pCommand)
6328 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006329 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006330 status = eHAL_STATUS_RESOURCES;
6331 }
6332 else
6333 {
6334 if( fClearScan )
6335 {
6336 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306337 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006338 }
6339 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6340 if(NULL == pProfile)
6341 {
6342 //We can roam now
6343 //Since pProfile is NULL, we need to build our own profile, set everything to default
6344 //We can only support open and no encryption
6345 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
6346 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
6347 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
6348 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6349 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
6350 }
6351 else
6352 {
6353 //make a copy of the profile
6354 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6355 if(HAL_STATUS_SUCCESS(status))
6356 {
6357 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6358 }
6359 }
6360 pCommand->command = eSmeCommandRoam;
6361 pCommand->sessionId = (tANI_U8)sessionId;
6362 pCommand->u.roamCmd.hBSSList = hBSSList;
6363 pCommand->u.roamCmd.roamId = roamId;
6364 pCommand->u.roamCmd.roamReason = reason;
6365 //We need to free the BssList when the command is done
6366 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
6367 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006368 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6369 FL("CSR PERSONA=%d"),
6370 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07006371 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6372 if( !HAL_STATUS_SUCCESS( status ) )
6373 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006374 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006375 csrReleaseCommandRoam( pMac, pCommand );
6376 }
6377 }
6378
6379 return (status);
6380}
Jeff Johnson295189b2012-06-20 16:38:30 -07006381eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6382 tCsrRoamModifyProfileFields *pMmodProfileFields,
6383 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
6384{
6385 eHalStatus status = eHAL_STATUS_SUCCESS;
6386 tSmeCmd *pCommand;
6387
6388 pCommand = csrGetCommandBuffer(pMac);
6389 if(NULL == pCommand)
6390 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006391 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006392 status = eHAL_STATUS_RESOURCES;
6393 }
6394 else
6395 {
6396 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306397 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006398 if(pProfile)
6399 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006400 //This is likely trying to reassoc to different profile
6401 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6402 //make a copy of the profile
6403 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6404 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006405 }
6406 else
6407 {
6408 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
6409 //how to update WPA/WPA2 info in roamProfile??
6410 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006411 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006412 if(HAL_STATUS_SUCCESS(status))
6413 {
6414 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6415 }
6416 pCommand->command = eSmeCommandRoam;
6417 pCommand->sessionId = (tANI_U8)sessionId;
6418 pCommand->u.roamCmd.roamId = roamId;
6419 pCommand->u.roamCmd.roamReason = reason;
6420 //We need to free the BssList when the command is done
6421 //For reassoc there is no BSS list, so the boolean set to false
6422 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
6423 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
6424 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006425 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6426 if( !HAL_STATUS_SUCCESS( status ) )
6427 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006428 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006429 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6430 csrReleaseCommandRoam( pMac, pCommand );
6431 }
6432 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006433 return (status);
6434}
6435
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006436eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
6437 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306438// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006439{
6440 eHalStatus status = eHAL_STATUS_SUCCESS;
6441 tSmeCmd *pCommand;
6442
6443 pCommand = csrGetCommandBuffer(pMac);
6444 if(NULL == pCommand)
6445 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006446 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006447 status = eHAL_STATUS_RESOURCES;
6448 }
6449 else
6450 {
6451 if(pBssDescription)
6452 {
6453 //copy over the parameters we need later
6454 pCommand->command = eSmeCommandRoam;
6455 pCommand->sessionId = (tANI_U8)sessionId;
6456 pCommand->u.roamCmd.roamReason = reason;
6457 //this is the important parameter
6458 //in this case we are using this field for the "next" BSS
6459 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
6460 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
6461 if( !HAL_STATUS_SUCCESS( status ) )
6462 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006463 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d"), status );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006464 csrReleaseCommandPreauth( pMac, pCommand );
6465 }
6466 }
6467 else
6468 {
6469 //Return failure
6470 status = eHAL_STATUS_RESOURCES;
6471 }
6472 }
6473 return (status);
6474}
6475
6476eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
6477{
6478 tListElem *pEntry;
6479 tSmeCmd *pCommand;
6480 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6481 if ( pEntry )
6482 {
6483 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6484 if ( (eSmeCommandRoam == pCommand->command) &&
6485 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
6486 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006487 smsLog( pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006488 pCommand->command, pCommand->u.roamCmd.roamReason);
6489 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
6490 csrReleaseCommandPreauth( pMac, pCommand );
6491 }
6492 } else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006493 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d "),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006494 pCommand->command, pCommand->u.roamCmd.roamReason);
6495 }
6496 }
6497 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006498 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006499 }
6500 smeProcessPendingQueue( pMac );
6501 return eHAL_STATUS_SUCCESS;
6502}
6503
Jeff Johnson295189b2012-06-20 16:38:30 -07006504eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6505 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6506{
6507 eHalStatus status = eHAL_STATUS_FAILURE;
6508 tScanResultHandle hBSSList;
6509 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006510 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
6511 if(HAL_STATUS_SUCCESS(status))
6512 {
6513 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6514 if(pRoamId)
6515 {
6516 *pRoamId = roamId;
6517 }
6518 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6519 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6520 if(!HAL_STATUS_SUCCESS(status))
6521 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006522 smsLog(pMac, LOGE, FL("failed to start a join process"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006523 csrScanResultPurge(pMac, hBSSList);
6524 }
6525 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006526 return (status);
6527}
6528
Jeff Johnson295189b2012-06-20 16:38:30 -07006529eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6530 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6531{
6532 eHalStatus status = eHAL_STATUS_SUCCESS;
6533 tScanResultHandle hBSSList;
6534 tCsrScanResultFilter *pScanFilter;
6535 tANI_U32 roamId = 0;
6536 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
6537 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006538 if (NULL == pProfile)
6539 {
6540 smsLog(pMac, LOGP, FL("No profile specified"));
6541 return eHAL_STATUS_FAILURE;
6542 }
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05306543 smsLog(pMac, LOG1, FL("called BSSType = %s (%d) authtype = %d "
6544 "encryType = %d"),
6545 lim_BssTypetoString(pProfile->BSSType),
6546 pProfile->BSSType,
6547 pProfile->AuthType.authType[0],
6548 pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006549 if( CSR_IS_WDS( pProfile ) &&
6550 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
6551 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006552 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d"),
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006553 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006554 return status;
6555 }
6556 csrRoamCancelRoaming(pMac, sessionId);
6557 csrScanRemoveFreshScanCommand(pMac, sessionId);
6558 csrScanCancelIdleScan(pMac);
6559 //Only abort the scan if it is not used for other roam/connect purpose
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05306560 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Jeff Johnson295189b2012-06-20 16:38:30 -07006561 if (!vos_concurrent_sessions_running() && (VOS_STA_SAP_MODE == pProfile->csrPersona))//In case of AP mode we do not want idle mode scan
6562 {
6563 csrScanDisable(pMac);
6564 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006565 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6566 //Check whether ssid changes
6567 if(csrIsConnStateConnected(pMac, sessionId))
6568 {
6569 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6570 {
6571 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6572 }
6573 }
6574#ifdef FEATURE_WLAN_BTAMP_UT_RF
6575 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
6576#endif
6577 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
6578 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006579 smsLog(pMac, LOG1, FL("is called with BSSList"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006580 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
6581 if(pRoamId)
6582 {
6583 roamId = *pRoamId;
6584 }
6585 if(!HAL_STATUS_SUCCESS(status))
6586 {
6587 fCallCallback = eANI_BOOLEAN_TRUE;
6588 }
6589 }
6590 else
6591 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306592 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
6593 if ( NULL == pScanFilter )
6594 status = eHAL_STATUS_FAILURE;
6595 else
6596 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006597 if(HAL_STATUS_SUCCESS(status))
6598 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306599 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006600 //Try to connect to any BSS
6601 if(NULL == pProfile)
6602 {
6603 //No encryption
6604 pScanFilter->EncryptionType.numEntries = 1;
6605 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6606 }//we don't have a profile
6607 else
6608 {
6609 //Here is the profile we need to connect to
6610 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6611 }//We have a profile
6612 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6613 if(pRoamId)
6614 {
6615 *pRoamId = roamId;
6616 }
6617
6618 if(HAL_STATUS_SUCCESS(status))
6619 {
6620 /*Save the WPS info*/
6621 if(NULL != pProfile)
6622 {
6623 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006624 pScanFilter->bOSENAssociation = pProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07006625 }
6626 else
6627 {
6628 pScanFilter->bWPSAssociation = 0;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006629 pScanFilter->bOSENAssociation = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006630 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006631 do
6632 {
6633 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006634 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006635 )
6636 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006637 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07006638 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6639 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6640 if(!HAL_STATUS_SUCCESS(status))
6641 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006642 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006643 fCallCallback = eANI_BOOLEAN_TRUE;
6644 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006645 else
6646 {
6647 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
6648 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006649 break;
6650 }
6651 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006652 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006653 if(HAL_STATUS_SUCCESS(status))
6654 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006655 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6656 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6657 if(!HAL_STATUS_SUCCESS(status))
6658 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006659 smsLog(pMac, LOGE, FL(" CSR failed to issue connect command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006660 csrScanResultPurge(pMac, hBSSList);
6661 fCallCallback = eANI_BOOLEAN_TRUE;
6662 }
6663 }//Have scan result
6664 else if(NULL != pProfile)
6665 {
6666 //Check whether it is for start ibss
6667 if(CSR_IS_START_IBSS(pProfile))
6668 {
6669 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6670 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6671 if(!HAL_STATUS_SUCCESS(status))
6672 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006673 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006674 fCallCallback = eANI_BOOLEAN_TRUE;
6675 }
6676 }
6677 else
6678 {
6679 //scan for this SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006680 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006681 if(!HAL_STATUS_SUCCESS(status))
6682 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006683 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006684 fCallCallback = eANI_BOOLEAN_TRUE;
6685 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006686 else
6687 {
6688 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
6689 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006690 }
6691 }
6692 else
6693 {
6694 fCallCallback = eANI_BOOLEAN_TRUE;
6695 }
6696 } while (0);
6697 if(NULL != pProfile)
6698 {
6699 //we need to free memory for filter if profile exists
6700 csrFreeScanFilter(pMac, pScanFilter);
6701 }
6702 }//Got the scan filter from profile
6703
Kiet Lam64c1b492013-07-12 13:56:44 +05306704 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006705 }//allocated memory for pScanFilter
6706 }//No Bsslist coming in
6707 //tell the caller if we fail to trigger a join request
6708 if( fCallCallback )
6709 {
6710 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6711 }
6712
6713 return (status);
6714}
Jeff Johnson295189b2012-06-20 16:38:30 -07006715eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6716 tCsrRoamModifyProfileFields modProfileFields,
6717 tANI_U32 *pRoamId)
6718{
6719 eHalStatus status = eHAL_STATUS_SUCCESS;
6720 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
6721 tANI_U32 roamId = 0;
6722 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006723 if (NULL == pProfile)
6724 {
6725 smsLog(pMac, LOGP, FL("No profile specified"));
6726 return eHAL_STATUS_FAILURE;
6727 }
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05306728 smsLog(pMac, LOG1, FL("called BSSType = %s (%d) authtype = %d "
6729 "encryType = %d"),
6730 lim_BssTypetoString(pProfile->BSSType),
6731 pProfile->BSSType,
6732 pProfile->AuthType.authType[0],
6733 pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006734 csrRoamCancelRoaming(pMac, sessionId);
6735 csrScanRemoveFreshScanCommand(pMac, sessionId);
6736 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306737 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006738 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07006739 if(csrIsConnStateConnected(pMac, sessionId))
6740 {
6741 if(pProfile)
6742 {
6743 if(pProfile->SSIDs.numOfSSIDs &&
6744 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6745 {
6746 fCallCallback = eANI_BOOLEAN_FALSE;
6747 }
6748 else
6749 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006750 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006751 }
6752 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306753 else if (!vos_mem_compare(&modProfileFields,
6754 &pSession->connectedProfile.modifyProfileFields,
6755 sizeof(tCsrRoamModifyProfileFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -07006756 {
6757 fCallCallback = eANI_BOOLEAN_FALSE;
6758 }
6759 else
6760 {
6761 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006762 "in tCsrRoamModifyProfileFields got modified"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006763 }
6764 }
6765 else
6766 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006767 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006768 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006769 if(!fCallCallback)
6770 {
6771 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6772 if(pRoamId)
6773 {
6774 *pRoamId = roamId;
6775 }
6776
Jeff Johnson295189b2012-06-20 16:38:30 -07006777 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
6778 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006779 }
6780 else
6781 {
6782 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
6783 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6784 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006785 return status;
6786}
Jeff Johnson295189b2012-06-20 16:38:30 -07006787eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6788{
6789 eHalStatus status = eHAL_STATUS_FAILURE;
6790 tScanResultHandle hBSSList = NULL;
6791 tCsrScanResultFilter *pScanFilter = NULL;
6792 tANI_U32 roamId;
6793 tCsrRoamProfile *pProfile = NULL;
6794 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006795
6796 if(!pSession)
6797 {
6798 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6799 return eHAL_STATUS_FAILURE;
6800 }
6801
Jeff Johnson295189b2012-06-20 16:38:30 -07006802 do
6803 {
6804 if(pSession->pCurRoamProfile)
6805 {
6806 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306807 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006808 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
Kiet Lam64c1b492013-07-12 13:56:44 +05306809 pProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
6810 if ( NULL == pProfile )
6811 status = eHAL_STATUS_FAILURE;
6812 else
6813 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006814 if(!HAL_STATUS_SUCCESS(status))
6815 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05306816 vos_mem_set(pProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006817 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05306818 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006819 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05306820 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
6821 if ( NULL == pScanFilter )
6822 status = eHAL_STATUS_FAILURE;
6823 else
6824 status = eHAL_STATUS_SUCCESS;
6825
Jeff Johnson295189b2012-06-20 16:38:30 -07006826 if(!HAL_STATUS_SUCCESS(status))
6827 {
6828 break;
6829 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306830 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006831 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6832 if(!HAL_STATUS_SUCCESS(status))
6833 {
6834 break;
6835 }
6836 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6837 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
6838 if(HAL_STATUS_SUCCESS(status))
6839 {
6840 //we want to put the last connected BSS to the very beginning, if possible
6841 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
6842 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6843 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6844 if(!HAL_STATUS_SUCCESS(status))
6845 {
6846 csrScanResultPurge(pMac, hBSSList);
6847 break;
6848 }
6849 }
6850 else
6851 {
6852 //Do a scan on this profile
6853 //scan for this SSID only in case the AP suppresses SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006854 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006855 if(!HAL_STATUS_SUCCESS(status))
6856 {
6857 break;
6858 }
6859 }
6860 }//We have a profile
6861 else
6862 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006863 smsLog(pMac, LOGW, FL("cannot find a roaming profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006864 break;
6865 }
6866 }while(0);
6867 if(pScanFilter)
6868 {
6869 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05306870 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006871 }
6872 if(NULL != pProfile)
6873 {
6874 csrReleaseProfile(pMac, pProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05306875 vos_mem_free(pProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07006876 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006877 return (status);
6878}
Jeff Johnson295189b2012-06-20 16:38:30 -07006879eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
6880{
6881 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006882 if(csrIsConnStateConnected(pMac, sessionId))
6883 {
6884 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6885 if(HAL_STATUS_SUCCESS(status))
6886 {
6887 status = csrRoamJoinLastProfile(pMac, sessionId);
6888 }
6889 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006890 return (status);
6891}
6892
Jeff Johnson295189b2012-06-20 16:38:30 -07006893eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6894{
6895 eHalStatus status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006896 smsLog(pMac, LOGW, FL("is called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006897 csrRoamCancelRoaming(pMac, sessionId);
6898 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6899 if(csrIsConnStateDisconnected(pMac, sessionId))
6900 {
6901 status = csrRoamJoinLastProfile(pMac, sessionId);
6902 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006903 return (status);
6904}
6905
Jeff Johnson295189b2012-06-20 16:38:30 -07006906eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
6907{
6908 eHalStatus status = eHAL_STATUS_SUCCESS;
6909 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
6910 eCsrRoamSubState NewSubstate;
6911 tANI_U32 sessionId = pCommand->sessionId;
6912
6913 // change state to 'Roaming'...
6914 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
6915
6916 if ( csrIsConnStateIbss( pMac, sessionId ) )
6917 {
6918 // If we are in an IBSS, then stop the IBSS...
6919 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6920 fComplete = (!HAL_STATUS_SUCCESS(status));
6921 }
6922 else if ( csrIsConnStateInfra( pMac, sessionId ) )
6923 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006924 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 -07006925 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
6926 //Restore AC weight in case we change it
6927 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
6928 // in Infrasturcture, we need to disassociate from the Infrastructure network...
6929 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
6930 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
6931 {
6932 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
6933 }
Abhishek Singhcf4590b2014-04-16 18:58:08 +05306934 else
6935 {
6936 // If we are in neighbor preauth done state then on receiving
6937 // disassoc or deauth we dont roam instead we just disassoc
6938 // from current ap and then go to disconnected state
6939 // This happens for ESE and 11r FT connections ONLY.
6940#ifdef WLAN_FEATURE_VOWIFI_11R
6941 if (csrRoamIs11rAssoc(pMac) &&
6942 (csrNeighborRoamStatePreauthDone(pMac)))
6943 {
6944 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
6945 }
6946#endif
6947#ifdef FEATURE_WLAN_ESE
6948 if (csrRoamIsESEAssoc(pMac) &&
6949 (csrNeighborRoamStatePreauthDone(pMac)))
6950 {
6951 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
6952 }
6953#endif
6954#ifdef FEATURE_WLAN_LFR
6955 if (csrRoamIsFastRoamEnabled(pMac, sessionId) &&
6956 (csrNeighborRoamStatePreauthDone(pMac)))
6957 {
6958 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
6959 }
6960#endif
6961 }
6962
Jeff Johnson295189b2012-06-20 16:38:30 -07006963 if( fDisassoc )
6964 {
6965 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
6966 }
6967 else
6968 {
6969 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
6970 }
6971 fComplete = (!HAL_STATUS_SUCCESS(status));
6972 }
6973 else if ( csrIsConnStateWds( pMac, sessionId ) )
6974 {
6975 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
6976 {
6977 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
6978 fComplete = (!HAL_STATUS_SUCCESS(status));
6979 }
6980 //This has to be WDS station
6981 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
6982 {
6983
6984 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
6985 if( fDisassoc )
6986 {
6987 status = csrRoamIssueDisassociate( pMac, sessionId,
6988 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
6989 fComplete = (!HAL_STATUS_SUCCESS(status));
6990 }
6991 }
6992 } else {
6993 // we got a dis-assoc request while not connected to any peer
6994 // just complete the command
6995 fComplete = eANI_BOOLEAN_TRUE;
6996 status = eHAL_STATUS_FAILURE;
6997 }
6998 if(fComplete)
6999 {
7000 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7001 }
7002
7003 if(HAL_STATUS_SUCCESS(status))
7004 {
7005 if ( csrIsConnStateInfra( pMac, sessionId ) )
7006 {
7007 //Set the state to disconnect here
7008 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7009 }
7010 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007011 else
7012 {
7013 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
7014 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007015 return (status);
7016}
7017
Jeff Johnson295189b2012-06-20 16:38:30 -07007018/* This is been removed from latest code base */
7019/*
7020static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
7021{
7022 eHalStatus status;
7023 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007024 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
7025 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007026 return ( status );
7027}
7028*/
7029
Jeff Johnson295189b2012-06-20 16:38:30 -07007030eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
7031{
7032 eHalStatus status = eHAL_STATUS_SUCCESS;
7033 tSmeCmd *pCommand;
7034 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007035 do
7036 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08007037 smsLog( pMac, LOG1, FL(" reason = %d"), reason );
Jeff Johnson295189b2012-06-20 16:38:30 -07007038 pCommand = csrGetCommandBuffer( pMac );
7039 if ( !pCommand )
7040 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007041 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007042 status = eHAL_STATUS_RESOURCES;
7043 break;
7044 }
7045 //Change the substate in case it is wait-for-key
7046 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7047 {
7048 csrRoamStopWaitForKeyTimer( pMac );
7049 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7050 }
7051 pCommand->command = eSmeCommandRoam;
7052 pCommand->sessionId = (tANI_U8)sessionId;
7053 switch ( reason )
7054 {
7055 case eCSR_DISCONNECT_REASON_MIC_ERROR:
7056 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
7057 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007058 case eCSR_DISCONNECT_REASON_DEAUTH:
7059 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
7060 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007061 case eCSR_DISCONNECT_REASON_HANDOFF:
7062 fHighPriority = eANI_BOOLEAN_TRUE;
7063 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
7064 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007065 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
7066 case eCSR_DISCONNECT_REASON_DISASSOC:
7067 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
7068 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007069 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
7070 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
7071 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007072 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
7073 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
7074 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007075 default:
7076 break;
7077 }
7078 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7079 if( !HAL_STATUS_SUCCESS( status ) )
7080 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007081 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007082 csrReleaseCommandRoam( pMac, pCommand );
7083 }
7084 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07007085 return( status );
7086}
7087
Jeff Johnson295189b2012-06-20 16:38:30 -07007088eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
7089{
7090 eHalStatus status = eHAL_STATUS_SUCCESS;
7091 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007092 pCommand = csrGetCommandBuffer( pMac );
7093 if ( NULL != pCommand )
7094 {
7095 //Change the substate in case it is wait-for-key
7096 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
7097 {
7098 csrRoamStopWaitForKeyTimer( pMac );
7099 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7100 }
7101 pCommand->command = eSmeCommandRoam;
7102 pCommand->sessionId = (tANI_U8)sessionId;
7103 pCommand->u.roamCmd.roamReason = eCsrStopBss;
7104 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7105 if( !HAL_STATUS_SUCCESS( status ) )
7106 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007107 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007108 csrReleaseCommandRoam( pMac, pCommand );
7109 }
7110 }
7111 else
7112 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007113 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007114 status = eHAL_STATUS_RESOURCES;
7115 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007116 return ( status );
7117}
7118
Jeff Johnson295189b2012-06-20 16:38:30 -07007119eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7120{
7121 eHalStatus status = eHAL_STATUS_SUCCESS;
7122 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007123
7124 if(!pSession)
7125 {
7126 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7127 return eHAL_STATUS_FAILURE;
7128 }
7129
Jeff Johnson295189b2012-06-20 16:38:30 -07007130#ifdef FEATURE_WLAN_BTAMP_UT_RF
7131 //Stop te retry
7132 pSession->maxRetryCount = 0;
7133 csrRoamStopJoinRetryTimer(pMac, sessionId);
7134#endif
7135 //Not to call cancel roaming here
7136 //Only issue disconnect when necessary
7137 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
7138 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
7139 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
7140
7141 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007142 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007143 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
7144 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307145 else
7146 {
7147 smsLog( pMac, LOGE, FL("Roam command is not present"));
7148 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007149 return (status);
7150}
7151
Jeff Johnson295189b2012-06-20 16:38:30 -07007152eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7153{
7154 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007155
7156 if(!pSession)
7157 {
7158 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7159 return eHAL_STATUS_FAILURE;
7160 }
7161
Jeff Johnson295189b2012-06-20 16:38:30 -07007162 csrRoamCancelRoaming(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007163 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
7164
7165 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
7166}
7167
Jeff Johnson295189b2012-06-20 16:38:30 -07007168eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
7169 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
7170{
7171 eHalStatus status = eHAL_STATUS_SUCCESS;
7172 tDot11fBeaconIEs *pIesTemp = pIes;
7173 tANI_U8 index;
7174 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7175 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007176
7177 if(!pSession)
7178 {
7179 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7180 return eHAL_STATUS_FAILURE;
7181 }
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007182 if(pConnectProfile->pAddIEAssoc)
7183 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307184 vos_mem_free(pConnectProfile->pAddIEAssoc);
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007185 pConnectProfile->pAddIEAssoc = NULL;
7186 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307187 vos_mem_set(&pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007188 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
7189 pConnectProfile->AuthInfo = pProfile->AuthType;
7190 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
7191 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
7192 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
7193 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
7194 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
7195 pConnectProfile->BSSType = pProfile->BSSType;
7196 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
7197 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07007198 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
AnjaneeDevi Kapparapu4b043912014-02-18 13:22:35 +05307199 if (!pConnectProfile->beaconInterval)
7200 {
7201 smsLog(pMac, LOGW, FL("ERROR: Beacon interval is ZERO"));
7202 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307203 vos_mem_copy(&pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007204 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
7205 if(pProfile->nAddIEAssocLength)
7206 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307207 pConnectProfile->pAddIEAssoc = vos_mem_malloc(pProfile->nAddIEAssocLength);
7208 if ( NULL == pConnectProfile->pAddIEAssoc )
7209 status = eHAL_STATUS_FAILURE;
7210 else
7211 status = eHAL_STATUS_SUCCESS;
7212 if (!HAL_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007213 {
7214 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
7215 return eHAL_STATUS_FAILURE;
7216 }
7217 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05307218 vos_mem_copy(pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
7219 pProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007220 }
7221
Jeff Johnson295189b2012-06-20 16:38:30 -07007222 //Save bssid
7223 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
7224#ifdef WLAN_FEATURE_VOWIFI_11R
7225 if (pSirBssDesc->mdiePresent)
7226 {
7227 pConnectProfile->MDID.mdiePresent = 1;
7228 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
7229 }
7230#endif
Leela Venkata Kiran Kumar Reddy Chiralad48e3272013-04-12 14:21:07 -07007231 if( NULL == pIesTemp )
7232 {
7233 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
7234 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007235#ifdef FEATURE_WLAN_ESE
7236 if ((csrIsProfileESE(pProfile) ||
7237 ((pIesTemp->ESEVersion.present)
Sandeep Puligilla798d6f22014-04-24 23:30:36 +05307238 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007239 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07007240 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007241 pConnectProfile->isESEAssoc = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007242 }
7243#endif
7244 //save ssid
Jeff Johnson295189b2012-06-20 16:38:30 -07007245 if(HAL_STATUS_SUCCESS(status))
7246 {
7247 if(pIesTemp->SSID.present)
7248 {
7249 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +05307250 vos_mem_copy(pConnectProfile->SSID.ssId, pIesTemp->SSID.ssid,
7251 pIesTemp->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07007252 }
7253
7254 //Save the bss desc
7255 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307256
7257 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07007258 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307259 //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 -07007260 pConnectProfile->qap = TRUE;
7261 }
7262 else
7263 {
7264 pConnectProfile->qap = FALSE;
7265 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007266 if ( NULL == pIes )
7267 {
7268 //Free memory if it allocated locally
Kiet Lam64c1b492013-07-12 13:56:44 +05307269 vos_mem_free(pIesTemp);
Jeff Johnson295189b2012-06-20 16:38:30 -07007270 }
7271 }
7272 //Save Qos connection
7273 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
7274
7275 if(!HAL_STATUS_SUCCESS(status))
7276 {
7277 csrFreeConnectBssDesc(pMac, sessionId);
7278 }
7279 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
7280 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307281 if ((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
7282 vos_mem_compare(pProfile->SSIDs.SSIDList[index].SSID.ssId,
7283 pConnectProfile->SSID.ssId,
7284 pConnectProfile->SSID.length))
Jeff Johnson295189b2012-06-20 16:38:30 -07007285 {
7286 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
7287 break;
7288 }
7289 pConnectProfile->handoffPermitted = FALSE;
7290 }
7291
7292 return (status);
7293}
7294
Jeff Johnson295189b2012-06-20 16:38:30 -07007295static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
7296{
7297 tListElem *pEntry = NULL;
7298 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007299 //The head of the active list is the request we sent
7300 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7301 if(pEntry)
7302 {
7303 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7304 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007305 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7306 {
7307 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
7308 {
7309#ifndef WLAN_MDM_CODE_REDUCTION_OPT
7310 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7311#endif
7312 }
7313 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
7314 }
7315 else
7316 {
7317 tANI_U32 roamId = 0;
7318 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007319 if(!pSession)
7320 {
7321 smsLog(pMac, LOGE, FL(" session %d not found "), pSmeJoinRsp->sessionId);
7322 return;
7323 }
7324
Jeff Johnson295189b2012-06-20 16:38:30 -07007325
7326 //The head of the active list is the request we sent
7327 //Try to get back the same profile and roam again
7328 if(pCommand)
7329 {
7330 roamId = pCommand->u.roamCmd.roamId;
7331 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007332 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
7333 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007334 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007335#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7336 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
7337 if (csrRoamIsHandoffInProgress(pMac))
7338 {
7339 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
7340 /* Should indicate neighbor roam algorithm about the connect failure here */
7341 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
7342 }
7343#endif
7344 if (pCommand)
7345 {
7346 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
7347 {
7348 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7349 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
7350 csrRoamReissueRoamCommand(pMac);
7351 }
7352 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
7353 {
7354 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7355 }
7356 else
7357 {
7358 csrRoam(pMac, pCommand);
7359 }
7360 }
7361 else
7362 {
7363 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7364 }
7365 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
7366}
7367
Jeff Johnson295189b2012-06-20 16:38:30 -07007368eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7369 tDot11fBeaconIEs *pIes,
7370 tCsrRoamProfile *pProfile, tANI_U32 roamId )
7371{
7372 eHalStatus status;
Arif Hussain24bafea2013-11-15 15:10:03 -08007373 smsLog( pMac, LOG1, "Attempting to Join Bssid= "MAC_ADDRESS_STR,
7374 MAC_ADDR_ARRAY(pSirBssDesc->bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07007375
7376 // Set the roaming substate to 'join attempt'...
7377 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007378 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007379 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007380 return (status);
7381}
7382
Jeff Johnson295189b2012-06-20 16:38:30 -07007383static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7384 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
7385{
7386 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007387 // Set the roaming substate to 'join attempt'...
7388 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
7389
Kaushik, Sushant8489f472014-01-27 11:41:22 +05307390 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7391 FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007392
7393 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007394 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07007395}
7396
Jeff Johnson295189b2012-06-20 16:38:30 -07007397void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
7398{
7399 tListElem *pEntry;
7400 tSmeCmd *pCommand;
7401 tCsrRoamInfo roamInfo;
7402 tANI_U32 sessionId;
7403 tCsrRoamSession *pSession;
7404
7405 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7406 if(pEntry)
7407 {
7408 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7409 if ( eSmeCommandRoam == pCommand->command )
7410 {
7411 sessionId = pCommand->sessionId;
7412 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007413
7414 if(!pSession)
7415 {
7416 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7417 return;
7418 }
Abhishek Singhaf15f152013-11-30 16:08:55 +05307419 /* While switching between two AP, csr will reissue roam command again
7420 to the nextbss if it was interrupted by the dissconnect req for the
7421 previous bss.During this csr is incrementing bRefAssocStartCnt twice.
7422 so reset the bRefAssocStartCnt.
7423 */
7424 if(pSession->bRefAssocStartCnt > 0)
7425 {
7426 pSession->bRefAssocStartCnt--;
7427 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007428 if( pCommand->u.roamCmd.fStopWds )
7429 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307430 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007431 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
7432 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
7433 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007434 if (CSR_IS_WDS(&pSession->connectedProfile)){
Jeff Johnson295189b2012-06-20 16:38:30 -07007435 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
7436 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7437 eCSR_ROAM_WDS_IND,
7438 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
Jeff Johnson295189b2012-06-20 16:38:30 -07007439 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
7440 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
7441 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7442 eCSR_ROAM_INFRA_IND,
7443 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
7444 }
7445
Jeff Johnson295189b2012-06-20 16:38:30 -07007446
Jeff Johnson295189b2012-06-20 16:38:30 -07007447 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
7448 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007449 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007450 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7451 }
7452 }
7453 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
7454 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007455 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007456 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7457 }
7458 }
7459 else
7460 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007461 smsLog(pMac, LOGW, " Command is not roaming after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007462 }
7463 }
7464 else
7465 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007466 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available");
Jeff Johnson295189b2012-06-20 16:38:30 -07007467 }
7468}
7469
Jeff Johnson295189b2012-06-20 16:38:30 -07007470tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
7471{
7472 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7473 tListElem *pEntry;
7474 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007475 //alwasy lock active list before locking pending list
7476 csrLLLock( &pMac->sme.smeCmdActiveList );
7477 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7478 if(pEntry)
7479 {
7480 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7481 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7482 {
7483 fRet = eANI_BOOLEAN_TRUE;
7484 }
7485 }
7486 if(eANI_BOOLEAN_FALSE == fRet)
7487 {
7488 csrLLLock(&pMac->sme.smeCmdPendingList);
7489 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
7490 while(pEntry)
7491 {
7492 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7493 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7494 {
7495 fRet = eANI_BOOLEAN_TRUE;
7496 break;
7497 }
7498 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7499 }
7500 csrLLUnlock(&pMac->sme.smeCmdPendingList);
7501 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307502 if (eANI_BOOLEAN_FALSE == fRet)
7503 {
7504 csrLLLock(&pMac->roam.roamCmdPendingList);
7505 pEntry = csrLLPeekHead(&pMac->roam.roamCmdPendingList, LL_ACCESS_NOLOCK);
7506 while (pEntry)
7507 {
7508 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7509 if (( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7510 {
7511 fRet = eANI_BOOLEAN_TRUE;
7512 break;
7513 }
7514 pEntry = csrLLNext(&pMac->roam.roamCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7515 }
7516 csrLLUnlock(&pMac->roam.roamCmdPendingList);
7517 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007518 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007519 return (fRet);
7520}
7521
Jeff Johnson295189b2012-06-20 16:38:30 -07007522tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
7523{
7524 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7525 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07007526 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
7527 {
7528 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
7529 {
7530 break;
7531 }
7532 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007533 return ( fRet );
7534}
7535
Jeff Johnson295189b2012-06-20 16:38:30 -07007536tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
7537{
7538 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007539 //alwasy lock active list before locking pending list
7540 csrLLLock( &pMac->sme.smeCmdActiveList );
7541 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7542 if(eANI_BOOLEAN_FALSE == fRet)
7543 {
7544 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
7545 }
7546 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007547 return (fRet);
7548}
7549
Jeff Johnson295189b2012-06-20 16:38:30 -07007550tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
7551{
7552 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7553 tListElem *pEntry;
7554 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007555 //alwasy lock active list before locking pending list
7556 csrLLLock( &pMac->sme.smeCmdActiveList );
7557 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7558 if( pEntry )
7559 {
7560 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
7561 if( ( eCsrRoamCommandScan == pCommand->command ) &&
7562 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
7563 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
7564 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
7565 {
7566 fRet = eANI_BOOLEAN_TRUE;
7567 }
7568 }
7569 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007570 return (fRet);
7571}
Jeff Johnson295189b2012-06-20 16:38:30 -07007572eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
7573{
7574 eHalStatus status = eHAL_STATUS_SUCCESS;
7575 tSmeCmd *pCommand = NULL;
7576 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
7577 tANI_BOOLEAN fRemoveCmd = FALSE;
7578 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07007579 // Delete the old assoc command. All is setup for reassoc to be serialized
7580 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7581 if ( pEntry )
7582 {
7583 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
7584 if ( !pCommand )
7585 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007586 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007587 return eHAL_STATUS_RESOURCES;
7588 }
7589 if ( eSmeCommandRoam == pCommand->command )
7590 {
7591 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
7592 {
7593 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7594 }
7595 else
7596 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007597 smsLog( pMac, LOGE, FL(" Unexpected active roam command present ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007598 }
7599 if (fRemoveCmd == FALSE)
7600 {
7601 // Implies we did not get the serialized assoc command we
7602 // were expecting
7603 pCommand = NULL;
7604 }
7605 }
7606 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007607 if(NULL == pCommand)
7608 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007609 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007610 return eHAL_STATUS_RESOURCES;
7611 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007612 do
7613 {
7614 //Change the substate in case it is wait-for-key
7615 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7616 {
7617 csrRoamStopWaitForKeyTimer( pMac );
7618 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
7619 }
7620 pCommand->command = eSmeCommandRoam;
7621 pCommand->sessionId = (tANI_U8)sessionId;
7622 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07007623 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7624 if( !HAL_STATUS_SUCCESS( status ) )
7625 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007626 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007627 csrReleaseCommandRoam( pMac, pCommand );
7628 }
7629 } while( 0 );
7630
Jeff Johnson295189b2012-06-20 16:38:30 -07007631 return( status );
7632}
7633static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
7634{
7635 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7636 tCsrScanResult *pScanResult = NULL;
7637 tSirBssDescription *pBssDesc = NULL;
7638 tSmeCmd *pCommand = NULL;
7639 tANI_U32 sessionId;
7640 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07007641 if(NULL == pEntry)
7642 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307643 smsLog(pMac, LOGE, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07007644 return;
7645 }
7646 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7647 sessionId = pCommand->sessionId;
7648 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007649
7650 if(!pSession)
7651 {
7652 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7653 return;
7654 }
7655
Jeff Johnson295189b2012-06-20 16:38:30 -07007656 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
7657 {
7658 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007659 smsLog(pMac, LOGW, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007660 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7661 }
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07007662 /* If the roaming has stopped, not to continue the roaming command*/
7663 else if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
7664 {
7665 //No need to complete roaming here as it already completes
7666 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed\n"),
7667 pCommand->u.roamCmd.roamReason);
7668 csrSetAbortRoamingCommand( pMac, pCommand );
7669 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7670 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007671 else
7672 {
7673 if ( CCM_IS_RESULT_SUCCESS(result) )
7674 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007675 smsLog(pMac, LOG2, "Cfg sequence complete");
Jeff Johnson295189b2012-06-20 16:38:30 -07007676 // Successfully set the configuration parameters for the new Bss. Attempt to
7677 // join the roaming Bss.
7678 if(pCommand->u.roamCmd.pRoamBssEntry)
7679 {
7680 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
7681 pBssDesc = &pScanResult->Result.BssDescriptor;
7682 }
7683 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
7684 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07007685 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07007686 )
7687 {
7688 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
7689 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
7690 pBssDesc, pCommand->u.roamCmd.roamId )))
7691 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307692 smsLog(pMac, LOGE, " CSR start BSS failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07007693 //We need to complete the command
7694 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7695 }
7696 }
7697 else
7698 {
7699 if (!pCommand->u.roamCmd.pRoamBssEntry)
7700 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307701 smsLog(pMac, LOGE, " pRoamBssEntry is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07007702 //We need to complete the command
7703 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
7704 return;
7705 }
7706 // If we are roaming TO an Infrastructure BSS...
7707 VOS_ASSERT(pScanResult != NULL);
7708 if ( csrIsInfraBssDesc( pBssDesc ) )
7709 {
7710 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07007711 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
7712 {
7713 // ..and currently in an Infrastructure connection....
7714 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
7715 {
7716 // ...and the SSIDs are equal, then we Reassoc.
7717 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
7718 pIesLocal ) )
7719 // ..and currently in an infrastructure connection
7720 {
7721 // then issue a Reassoc.
7722 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
7723 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
7724 &pCommand->u.roamCmd.roamProfile );
7725 }
7726 else
7727 {
7728
7729 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
7730 // previously associated AP.
7731 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7732 pIesLocal,
7733 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
7734 {
7735 //try something else
7736 csrRoam( pMac, pCommand );
7737 }
7738 }
7739 }
7740 else
7741 {
7742 eHalStatus status = eHAL_STATUS_SUCCESS;
7743
7744 /* We need to come with other way to figure out that this is because of HO in BMP
7745 The below API will be only available for Android as it uses a different HO algorithm */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007746 /* Reassoc request will be used only for ESE and 11r handoff whereas other legacy roaming should
Jeff Johnson295189b2012-06-20 16:38:30 -07007747 * use join request */
7748#ifdef WLAN_FEATURE_VOWIFI_11R
7749 if (csrRoamIsHandoffInProgress(pMac) &&
7750 csrRoamIs11rAssoc(pMac))
7751 {
7752 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
7753 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
7754 }
7755 else
7756#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007757#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07007758 if (csrRoamIsHandoffInProgress(pMac) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007759 csrRoamIsESEAssoc(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07007760 {
7761 // Now serialize the reassoc command.
7762 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7763 }
7764 else
7765#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007766#ifdef FEATURE_WLAN_LFR
7767 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05307768 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007769 {
7770 // Now serialize the reassoc command.
7771 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7772 }
7773 else
7774#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007775 // else we are not connected and attempting to Join. Issue the
7776 // Join request.
7777 {
7778 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7779 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
7780 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
7781 }
7782 if(!HAL_STATUS_SUCCESS(status))
7783 {
7784 //try something else
7785 csrRoam( pMac, pCommand );
7786 }
7787 }
7788 if( !pScanResult->Result.pvIes )
7789 {
7790 //Locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05307791 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07007792 }
7793 }
7794 }//if ( csrIsInfraBssDesc( pBssDesc ) )
7795 else
7796 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007797 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007798 }
7799 }//else
7800 }//if ( WNI_CFG_SUCCESS == result )
7801 else
7802 {
7803 // In the event the configuration failed, for infra let the roam processor
7804 //attempt to join something else...
7805 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
7806 {
7807 csrRoam(pMac, pCommand);
7808 }
7809 else
7810 {
7811 //We need to complete the command
7812 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
7813 {
7814 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7815 }
7816 else
7817 {
7818 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7819 }
7820 }
7821 }
7822 }//we have active entry
7823}
7824
Jeff Johnson295189b2012-06-20 16:38:30 -07007825static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
7826{
7827 //No one is sending eWNI_SME_AUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007828 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007829 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
7830 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007831 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007832 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
7833 // join the new one...
7834 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07007835 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
7836 }
7837 else {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007838 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08X [%d]", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007839 /***profHandleLostLinkAfterReset(pAdapter);
7840 // In the event the authenticate fails, let the roam processor attempt to join something else...
7841 roamRoam( pAdapter );***/
7842 }
7843}
7844
Jeff Johnson295189b2012-06-20 16:38:30 -07007845static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
7846{
7847 eCsrRoamCompleteResult result;
7848 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
7849 tCsrRoamInfo roamInfo;
7850 tANI_U32 roamId = 0;
7851
7852 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7853 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007854 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007855 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07007856 /* Defeaturize this part later if needed */
7857#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
7858 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
7859 * we need the response contents while processing the result in csrRoamProcessResults() */
7860 if (csrRoamIsHandoffInProgress(pMac))
7861 {
7862 /* Need to dig more on indicating events to SME QoS module */
7863 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7864 csrRoamComplete( pMac, result, pSmeJoinRsp);
7865 }
7866 else
7867#endif
7868 {
7869 csrRoamComplete( pMac, result, NULL );
7870 }
7871 }
7872 /* Should we handle this similar to handling the join failure? Is it ok
7873 * to call csrRoamComplete() with state as CsrJoinFailure */
7874 else
7875 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007876 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007877 result = eCsrReassocFailure;
7878#ifdef WLAN_FEATURE_VOWIFI_11R
7879 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
7880 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode))
7881 {
7882 // Inform HDD to turn off FT flag in HDD
7883 if (pNeighborRoamInfo)
7884 {
7885 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
7886 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
7887 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07007888 /*
7889 * Since the above callback sends a disconnect
7890 * to HDD, we should clean-up our state
7891 * machine as well to be in sync with the upper
7892 * layers. There is no need to send a disassoc
7893 * since: 1) we will never reassoc to the current
7894 * AP in LFR, and 2) there is no need to issue a
7895 * disassoc to the AP with which we were trying
7896 * to reassoc.
7897 */
7898 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7899 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07007900 }
7901 }
7902#endif
7903 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
7904 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
7905 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
7906 //The disassoc rsp message will remove the command from active list
7907 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
7908 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
7909 {
7910 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
7911 }
7912 }
7913}
7914
Jeff Johnson295189b2012-06-20 16:38:30 -07007915static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
7916{
Jeff Johnson295189b2012-06-20 16:38:30 -07007917#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
7918 {
7919 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07007920 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
7921 if(pIbssLog)
7922 {
7923 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
7924 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
7925 {
7926 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
7927 }
7928 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
7929 }
7930 }
7931#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07007932 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7933 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
7934 {
7935 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7936 }
7937 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
7938 {
7939 csrRoamReissueRoamCommand(pMac);
7940 }
7941}
7942
Jeff Johnson295189b2012-06-20 16:38:30 -07007943void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
7944{
7945 tSirResultCodes statusCode;
7946#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7947 tScanResultHandle hBSSList;
7948 tANI_BOOLEAN fCallCallback, fRemoveCmd;
7949 eHalStatus status;
7950 tCsrRoamInfo roamInfo;
7951 tCsrScanResultFilter *pScanFilter = NULL;
7952 tANI_U32 roamId = 0;
7953 tCsrRoamProfile *pCurRoamProfile = NULL;
7954 tListElem *pEntry = NULL;
7955 tSmeCmd *pCommand = NULL;
7956#endif
7957 tANI_U32 sessionId;
7958 tCsrRoamSession *pSession;
Jeff Johnsone7245742012-09-05 17:12:55 -07007959
Jeff Johnson295189b2012-06-20 16:38:30 -07007960 tSirSmeDisassocRsp SmeDisassocRsp;
7961
7962 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
7963 sessionId = SmeDisassocRsp.sessionId;
7964 statusCode = SmeDisassocRsp.statusCode;
7965
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007966 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007967
7968 if ( csrIsConnStateInfra( pMac, sessionId ) )
7969 {
7970 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7971 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007972 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007973
7974 if(!pSession)
7975 {
7976 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7977 return;
7978 }
7979
Jeff Johnson295189b2012-06-20 16:38:30 -07007980 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
7981 {
7982 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7983 }
7984 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
7985 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
7986 {
7987 if ( eSIR_SME_SUCCESS == statusCode )
7988 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007989 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007990 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
7991 }
7992 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7993 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007994 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
7995 {
Kaushik, Sushant8489f472014-01-27 11:41:22 +05307996 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH,
7997 "CSR SmeDisassocReq due to HO on session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07007998#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08007999 /*
8000 * First ensure if the roam profile is in the scan cache.
8001 * If not, post a reassoc failure and disconnect.
8002 */
Kiet Lam64c1b492013-07-12 13:56:44 +05308003 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
8004 if ( NULL == pScanFilter )
8005 status = eHAL_STATUS_FAILURE;
8006 else
8007 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008008 if(HAL_STATUS_SUCCESS(status))
8009 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308010 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008011 status = csrRoamPrepareFilterFromProfile(pMac,
8012 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
8013 if(!HAL_STATUS_SUCCESS(status))
8014 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008015 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008016 __func__, status);
8017 goto POST_ROAM_FAILURE;
8018 }
8019 else
8020 {
8021 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
8022 if (!HAL_STATUS_SUCCESS(status))
8023 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008024 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008025 __func__, status);
8026 goto POST_ROAM_FAILURE;
8027 }
8028 }
8029 }
8030 else
8031 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008032 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008033 __func__, status);
8034 goto POST_ROAM_FAILURE;
8035 }
8036
8037 /*
8038 * After ensuring that the roam profile is in the scan result list,
8039 * dequeue the command from the active list.
8040 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008041 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
8042 if ( pEntry )
8043 {
8044 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008045 /* If the head of the queue is Active and it is a ROAM command, remove
8046 * and put this on the Free queue.
8047 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008048 if ( eSmeCommandRoam == pCommand->command )
8049 {
Jeff Johnsone7245742012-09-05 17:12:55 -07008050
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008051 /*
8052 * we need to process the result first before removing it from active list
8053 * because state changes still happening insides roamQProcessRoamResults so
8054 * no other roam command should be issued.
8055 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008056 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
8057 if(pCommand->u.roamCmd.fReleaseProfile)
8058 {
8059 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
8060 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
8061 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008062 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07008063 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07008064 else
8065 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008066 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008067 __func__, pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07008068 }
8069 }
8070 else
8071 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008072 smsLog( pMac, LOGE, "%s: roam command not active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008073 }
8074 }
8075 else
8076 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008077 smsLog( pMac, LOGE, "%s: NO commands are active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008078 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008079
8080 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07008081 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
8082
Kiet Lam64c1b492013-07-12 13:56:44 +05308083 vos_mem_copy(roamInfo.bssid,
8084 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
8085 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008086
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008087 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
8088 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008089
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008090 /* Copy the connected profile to apply the same for this connection as well */
Kiet Lam64c1b492013-07-12 13:56:44 +05308091 pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
8092 if ( pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07008093 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308094 vos_mem_set(pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008095 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
8096 //make sure to put it at the head of the cmd queue
8097 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
8098 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
8099 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
8100
Jeff Johnson295189b2012-06-20 16:38:30 -07008101 if(!HAL_STATUS_SUCCESS(status))
8102 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008103 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008104 __func__, status);
8105 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008106 }
8107
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008108 /* Notify sub-modules like QoS etc. that handoff happening */
8109 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08008110 csrReleaseProfile(pMac, pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05308111 vos_mem_free(pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07008112 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308113 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008114 return;
8115 }
8116
8117POST_ROAM_FAILURE:
8118 if (pScanFilter)
8119 {
8120 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308121 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008122 }
8123 if (pCurRoamProfile)
Kiet Lam64c1b492013-07-12 13:56:44 +05308124 vos_mem_free(pCurRoamProfile);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008125
8126 /* Inform the upper layers that the reassoc failed */
8127 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
8128 csrRoamCallCallback(pMac, sessionId,
8129 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
8130
8131 /*
8132 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
8133 * Upon success, we would re-enter this routine after receiving the disassoc
8134 * response and will fall into the reassoc fail sub-state. And, eventually
8135 * call csrRoamComplete which would remove the roam command from SME active
8136 * queue.
8137 */
8138 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
8139 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
8140 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008141 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008142 __func__, status);
8143 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07008144 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008145#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008146
Jeff Johnson295189b2012-06-20 16:38:30 -07008147 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
8148 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
8149 {
8150 // Disassoc due to Reassoc failure falls into this codepath....
8151 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8152 }
8153 else
8154 {
8155 if ( eSIR_SME_SUCCESS == statusCode )
8156 {
8157 // Successfully disassociated from the 'old' Bss...
8158 //
8159 // We get Disassociate response in three conditions.
8160 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
8161 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
8162 // Infrastructure network.
8163 // - Third is where we are doing an Infra to Infra roam between networks with different
8164 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
8165
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008166 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008167 }
8168 else
8169 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008170 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008171 }
8172 //We are not done yet. Get the data and continue roaming
8173 csrRoamReissueRoamCommand(pMac);
8174 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008175}
8176
Jeff Johnson295189b2012-06-20 16:38:30 -07008177static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
8178{
8179 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008180 //No one is sending eWNI_SME_DEAUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008181 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008182 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08008183 pMac->roam.deauthRspStatus = statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008184 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
8185 {
8186 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8187 }
8188 else
8189 {
8190 if ( eSIR_SME_SUCCESS == statusCode )
8191 {
8192 // Successfully deauth from the 'old' Bss...
8193 //
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008194 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008195 }
8196 else
8197 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008198 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008199 }
8200 //We are not done yet. Get the data and continue roaming
8201 csrRoamReissueRoamCommand(pMac);
8202 }
8203}
8204
Jeff Johnson295189b2012-06-20 16:38:30 -07008205static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
8206{
8207 eCsrRoamCompleteResult result;
8208
8209 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
8210 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008211 smsLog( pMac, LOGW, "SmeStartBssReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008212 result = eCsrStartBssSuccess;
8213 }
8214 else
8215 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008216 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08X", pSmeStartBssRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008217 //Let csrRoamComplete decide what to do
8218 result = eCsrStartBssFailure;
8219 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008220 csrRoamComplete( pMac, result, pSmeStartBssRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -07008221}
8222
Jeff Johnson295189b2012-06-20 16:38:30 -07008223/*
8224 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
8225 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
8226 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
8227 For the messages where sender allocates memory for specific structures, then it can be
8228 cast accordingly.
8229*/
8230void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8231{
8232 tSirSmeRsp *pSmeRsp;
8233 tSmeIbssPeerInd *pIbssPeerInd;
8234 tCsrRoamInfo roamInfo;
8235 // TODO Session Id need to be acquired in this function
8236 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008237 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308238 smsLog(pMac, LOG2, FL("Message %d[0x%04X] received in substate %s"),
8239 pSmeRsp->messageType, pSmeRsp->messageType,
8240 macTraceGetcsrRoamSubState(
8241 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008242 pSmeRsp->messageType = (pSmeRsp->messageType);
8243 pSmeRsp->length = (pSmeRsp->length);
8244 pSmeRsp->statusCode = (pSmeRsp->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008245 switch (pSmeRsp->messageType)
8246 {
8247
8248 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
8249 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
8250 {
8251 //We sent a JOIN_REQ
8252 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
8253 }
8254 break;
8255
8256 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
8257 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
8258 {
8259 //We sent a AUTH_REQ
8260 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
8261 }
8262 break;
8263
8264 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
8265 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
8266 {
8267 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
8268 }
8269 break;
8270
8271 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
8272 {
8273 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
8274 }
8275 break;
8276
8277 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
8278 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
8279 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
8280 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
8281 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
8282 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
8283//HO
8284 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
8285 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308286 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %s"),
8287 macTraceGetcsrRoamSubState(
8288 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008289 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
8290 }
8291 break;
8292
8293 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
8294 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
8295 {
8296 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
8297 }
8298 break;
8299
8300 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
8301 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
8302 {
8303 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
8304 }
8305 break;
8306
8307 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
8308 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
8309 {
8310 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
8311 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008312 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008313 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
8314 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
8315 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008316 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state");
Kiet Lam64c1b492013-07-12 13:56:44 +05308317 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
8318 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008319 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
8320 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05308321 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
8322 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008323 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
8324 eCSR_ROAM_CONNECT_STATUS_UPDATE,
8325 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
8326 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008327 default:
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308328 smsLog(pMac, LOG1,
8329 FL("Unexpected message type = %d[0x%X] received in substate %s"),
8330 pSmeRsp->messageType, pSmeRsp->messageType,
8331 macTraceGetcsrRoamSubState(
8332 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008333
8334 //If we are connected, check the link status change
8335 if(!csrIsConnStateDisconnected(pMac, sessionId))
8336 {
8337 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
8338 }
8339 break;
8340 }
8341}
8342
Jeff Johnson295189b2012-06-20 16:38:30 -07008343void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8344{
8345 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07008346 switch (pSirMsg->messageType)
8347 {
8348 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008349 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008350 csrRoamStatsRspProcessor( pMac, pSirMsg );
8351 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008352 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
8353 {
8354 tCsrRoamSession *pSession;
8355 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
8356 tCsrRoamInfo roamInfo;
8357 tCsrRoamInfo *pRoamInfo = NULL;
8358 tANI_U32 sessionId;
8359 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008360 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer "));
Kiet Lam64c1b492013-07-12 13:56:44 +05308361 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008362 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07008363 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
8364 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
8365 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008366
8367 if(!pSession)
8368 {
8369 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8370 return;
8371 }
8372
Jeff Johnson295189b2012-06-20 16:38:30 -07008373 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
8374 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07008375 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
8376 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
8377 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07008378 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
8379 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05308380 vos_mem_copy(pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr,
8381 sizeof(tSirMacAddr));
8382 vos_mem_copy(&pRoamInfo->bssid, pUpperLayerAssocCnf->bssId,
8383 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008384 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07008385 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
8386 {
8387 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
8388 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
8389 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
8390 }
8391 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8392 {
8393 vos_sleep( 100 );
8394 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
8395 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
8396 }
8397
Jeff Johnson295189b2012-06-20 16:38:30 -07008398 }
8399 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008400 default:
8401 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
8402 break;
8403 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008404}
8405
Jeff Johnson295189b2012-06-20 16:38:30 -07008406eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
8407 tSirBssDescription *pBssDescription,
8408 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
8409 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
8410 tANI_U8 keyId, tANI_U16 keyLength,
8411 tANI_U8 *pKey, tANI_U8 paeRole )
8412{
8413 eHalStatus status = eHAL_STATUS_SUCCESS;
8414 tAniEdType edType;
8415
8416 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
8417 {
8418 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
8419 }
8420
8421 edType = csrTranslateEncryptTypeToEdType( EncryptType );
8422
8423 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
8424 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
8425 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
8426 addKey )
8427 {
8428 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07008429 setKey.encType = EncryptType;
8430 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308431 vos_mem_copy(&setKey.peerMac, bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008432 setKey.paeRole = paeRole; //0 for supplicant
8433 setKey.keyId = keyId; // Kye index
8434 setKey.keyLength = keyLength;
8435 if( keyLength )
8436 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308437 vos_mem_copy(setKey.Key, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008438 }
8439 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
8440 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008441 return (status);
8442}
8443
Jeff Johnson295189b2012-06-20 16:38:30 -07008444static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8445 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8446{
8447 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8448 tSmeCmd *pCommand = NULL;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008449#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008450 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008451#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07008452
8453 do
8454 {
8455 pCommand = csrGetCommandBuffer(pMac);
8456 if(NULL == pCommand)
8457 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008458 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008459 status = eHAL_STATUS_RESOURCES;
8460 break;
8461 }
8462 pCommand->command = eSmeCommandSetKey;
8463 pCommand->sessionId = (tANI_U8)sessionId;
8464 // validate the key length, Adjust if too long...
8465 // for static WEP the keys are not set thru' SetContextReq
8466 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
8467 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
8468 {
8469 //KeyLength maybe 0 for static WEP
8470 if( pSetKey->keyLength )
8471 {
8472 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
8473 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008474 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008475 break;
8476 }
8477
8478 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308479 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8480 CSR_WEP40_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008481 }
8482 }
8483 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
8484 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
8485 {
8486 //KeyLength maybe 0 for static WEP
8487 if( pSetKey->keyLength )
8488 {
8489 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
8490 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008491 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008492 break;
8493 }
8494
8495 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308496 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8497 CSR_WEP104_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008498 }
8499 }
8500 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
8501 {
8502 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
8503 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008504 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008505 break;
8506 }
8507 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308508 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8509 CSR_TKIP_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008510 }
8511 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
8512 {
8513 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
8514 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008515 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008516 break;
8517 }
8518 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308519 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8520 CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008521 }
8522#ifdef FEATURE_WLAN_WAPI
8523 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
8524 {
8525 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
8526 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008527 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008528 break;
8529 }
8530 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308531 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8532 CSR_WAPI_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008533 }
8534#endif /* FEATURE_WLAN_WAPI */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008535#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008536 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8537 {
8538 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
8539 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008540 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008541 break;
8542 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008543 vos_mem_copy(pSession->eseCckmInfo.krk, pSetKey->Key,
Kiet Lam64c1b492013-07-12 13:56:44 +05308544 CSR_KRK_KEY_LEN);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008545 pSession->eseCckmInfo.reassoc_req_num=1;
8546 pSession->eseCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008547 status = eHAL_STATUS_SUCCESS;
8548 break;
8549 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008550#endif /* FEATURE_WLAN_ESE */
Jeff Johnsone7245742012-09-05 17:12:55 -07008551
Jeff Johnson295189b2012-06-20 16:38:30 -07008552#ifdef WLAN_FEATURE_11W
8553 //Check for 11w BIP
Chet Lanctot186b5732013-03-18 10:26:30 -07008554 else if (eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008555 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008556 if (pSetKey->keyLength < CSR_AES_KEY_LEN)
Jeff Johnson295189b2012-06-20 16:38:30 -07008557 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008558 smsLog(pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008559 break;
8560 }
8561 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308562 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008563 }
8564#endif
8565 status = eHAL_STATUS_SUCCESS;
8566 pCommand->u.setKeyCmd.roamId = roamId;
8567 pCommand->u.setKeyCmd.encType = pSetKey->encType;
8568 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308569 vos_mem_copy(&pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac,
8570 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008571 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
8572 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
Kiet Lam64c1b492013-07-12 13:56:44 +05308573 vos_mem_copy(pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008574 //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
8575
8576 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
8577 if( !HAL_STATUS_SUCCESS( status ) )
8578 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008579 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008580 }
8581 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008582 // Free the command if there has been a failure, or it is a
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008583 // "local" operation like the set ESE CCKM KRK key.
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008584 if ( ( NULL != pCommand ) &&
8585 ( (!HAL_STATUS_SUCCESS( status ) )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008586#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008587 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008588#endif /* FEATURE_WLAN_ESE */
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008589 ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008590 {
8591 csrReleaseCommandSetKey( pMac, pCommand );
8592 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008593 return( status );
8594}
8595
Jeff Johnson295189b2012-06-20 16:38:30 -07008596eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8597 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
8598{
8599 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8600 tSmeCmd *pCommand = NULL;
8601 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008602 do
8603 {
8604 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8605 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008606 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008607 status = eHAL_STATUS_CSR_WRONG_STATE;
8608 break;
8609 }
8610 pCommand = csrGetCommandBuffer(pMac);
8611 if(NULL == pCommand)
8612 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008613 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008614 status = eHAL_STATUS_RESOURCES;
8615 break;
8616 }
8617 pCommand->command = eSmeCommandRemoveKey;
8618 pCommand->sessionId = (tANI_U8)sessionId;
8619 pCommand->u.removeKeyCmd.roamId = roamId;
8620 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
Kiet Lam64c1b492013-07-12 13:56:44 +05308621 vos_mem_copy(&pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac,
8622 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008623 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
8624 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8625 {
8626 //in this case, put it to the end of the Q incase there is a set key pending.
8627 fImediate = eANI_BOOLEAN_FALSE;
8628 }
Arif Hussain24bafea2013-11-15 15:10:03 -08008629 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac="MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07008630 pRemoveKey->encType, pRemoveKey->keyId,
Arif Hussain24bafea2013-11-15 15:10:03 -08008631 MAC_ADDR_ARRAY(pCommand->u.removeKeyCmd.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07008632 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
8633 if( !HAL_STATUS_SUCCESS( status ) )
8634 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008635 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008636 break;
8637 }
8638 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008639 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
8640 {
8641 csrReleaseCommandRemoveKey( pMac, pCommand );
8642 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008643 return (status );
8644}
8645
Jeff Johnson295189b2012-06-20 16:38:30 -07008646eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8647{
8648 eHalStatus status;
8649 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
8650 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
8651 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
8652 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008653#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8654 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8655 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
lukez3c809222013-05-03 10:23:02 -07008656 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008657 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308658 vos_mem_set(&setKeyEvent,
8659 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008660 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8661 {
8662 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_REQ;
8663 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8664 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8665 }
8666 else
8667 {
8668 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_REQ;
8669 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8670 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8671 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308672 vos_mem_copy(setKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
lukez3c809222013-05-03 10:23:02 -07008673 if(CSR_IS_ENC_TYPE_STATIC(pCommand->u.setKeyCmd.encType))
Jeff Johnson295189b2012-06-20 16:38:30 -07008674 {
8675 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008676 //It has to be static WEP here
8677 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
8678 {
8679 setKeyEvent.keyId = (v_U8_t)defKeyId;
8680 }
8681 }
8682 else
8683 {
8684 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
8685 }
8686 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8687 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8688 }
8689#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008690 if( csrIsSetKeyAllowed(pMac, sessionId) )
8691 {
8692 status = csrSendMBSetContextReqMsg( pMac, sessionId,
8693 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
8694 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
8695 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
8696 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
8697 pCommand->u.setKeyCmd.keyRsc);
8698 }
8699 else
8700 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008701 smsLog( pMac, LOGW, FL(" cannot process not connected") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008702 //Set this status so the error handling take care of the case.
8703 status = eHAL_STATUS_CSR_WRONG_STATE;
8704 }
8705 if( !HAL_STATUS_SUCCESS(status) )
8706 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008707 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008708 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008709#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
lukez3c809222013-05-03 10:23:02 -07008710 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008711 {
8712 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8713 {
8714 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
8715 }
8716 else
8717 {
8718 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
8719 }
8720 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
8721 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8722 }
8723#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008724 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008725 return ( status );
8726}
8727
Jeff Johnson295189b2012-06-20 16:38:30 -07008728eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8729{
8730 eHalStatus status;
8731 tpSirSmeRemoveKeyReq pMsg = NULL;
8732 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
8733 tANI_U8 *p;
8734 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008735#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8736 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8737 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +05308738 vos_mem_set(&removeKeyEvent,
8739 sizeof(vos_event_wlan_security_payload_type),0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008740 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
8741 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8742 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05308743 vos_mem_copy(removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07008744 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
8745 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8746 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8747#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008748 if( csrIsSetKeyAllowed(pMac, sessionId) )
8749 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308750 pMsg = vos_mem_malloc(wMsgLen);
8751 if ( NULL == pMsg )
8752 status = eHAL_STATUS_FAILURE;
8753 else
8754 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008755 }
8756 else
8757 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008758 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008759 //Set the error status so error handling kicks in below
8760 status = eHAL_STATUS_CSR_WRONG_STATE;
8761 }
8762 if( HAL_STATUS_SUCCESS( status ) )
8763 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308764 vos_mem_set(pMsg, wMsgLen ,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008765 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
8766 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008767 pMsg->sessionId = (tANI_U8)sessionId;
8768 pMsg->transactionId = 0;
8769 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
8770 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
8771 // bssId - copy from session Info
Kiet Lam64c1b492013-07-12 13:56:44 +05308772 vos_mem_copy(p,
8773 &pMac->roam.roamSession[sessionId].connectedProfile.bssid,
8774 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008775 p += sizeof(tSirMacAddr);
8776 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +05308777 vos_mem_copy(p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008778 p += sizeof(tSirMacAddr);
8779 // edType
8780 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
8781 p++;
8782 // weptype
8783 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
8784 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
8785 {
8786 *p = (tANI_U8)eSIR_WEP_STATIC;
8787 }
8788 else
8789 {
8790 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
8791 }
8792 p++;
8793 //keyid
8794 *p = pCommand->u.removeKeyCmd.keyId;
8795 p++;
8796 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008797 status = palSendMBMessage(pMac->hHdd, pMsg);
8798 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008799 if( !HAL_STATUS_SUCCESS( status ) )
8800 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008801 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008802#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8803 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07008804 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008805 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8806#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008807 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
8808 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008809 return ( status );
8810}
8811
Jeff Johnson295189b2012-06-20 16:38:30 -07008812eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8813{
8814 eHalStatus status;
8815
8816 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8817 {
8818 status = eHAL_STATUS_CSR_WRONG_STATE;
8819 }
8820 else
8821 {
8822 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
8823 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008824 return ( status );
8825}
8826
Jeff Johnson295189b2012-06-20 16:38:30 -07008827/*
8828 Prepare a filter base on a profile for parsing the scan results.
8829 Upon successful return, caller MUST call csrFreeScanFilter on
8830 pScanFilter when it is done with the filter.
8831*/
8832eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
8833 tCsrScanResultFilter *pScanFilter)
8834{
8835 eHalStatus status = eHAL_STATUS_SUCCESS;
8836 tANI_U32 size = 0;
8837 tANI_U8 index = 0;
8838
8839 do
8840 {
8841 if(pProfile->BSSIDs.numOfBSSIDs)
8842 {
8843 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308844 pScanFilter->BSSIDs.bssid = vos_mem_malloc(size);
8845 if ( NULL == pScanFilter->BSSIDs.bssid )
8846 status = eHAL_STATUS_FAILURE;
8847 else
8848 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008849 if(!HAL_STATUS_SUCCESS(status))
8850 {
8851 break;
8852 }
8853 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308854 vos_mem_copy(pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07008855 }
8856 if(pProfile->SSIDs.numOfSSIDs)
8857 {
8858 if( !CSR_IS_WDS_STA( pProfile ) )
8859 {
8860 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
8861 }
8862 else
8863 {
8864 //For WDS station
8865 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
8866 pScanFilter->SSIDs.numOfSSIDs = 1;
8867 }
8868 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308869 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(size);
8870 if ( NULL == pScanFilter->SSIDs.SSIDList )
8871 status = eHAL_STATUS_FAILURE;
8872 else
8873 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008874 if(!HAL_STATUS_SUCCESS(status))
8875 {
8876 break;
8877 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308878 vos_mem_copy(pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList,
8879 size);
Jeff Johnson295189b2012-06-20 16:38:30 -07008880 }
8881 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
8882 {
8883 pScanFilter->ChannelInfo.numOfChannels = 0;
8884 pScanFilter->ChannelInfo.ChannelList = NULL;
8885 }
8886 else if(pProfile->ChannelInfo.numOfChannels)
8887 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308888 pScanFilter->ChannelInfo.ChannelList = vos_mem_malloc(
8889 sizeof(*pScanFilter->ChannelInfo.ChannelList) *
8890 pProfile->ChannelInfo.numOfChannels);
8891 if ( NULL == pScanFilter->ChannelInfo.ChannelList )
8892 status = eHAL_STATUS_FAILURE;
8893 else
8894 status = eHAL_STATUS_SUCCESS;
8895
Jeff Johnson295189b2012-06-20 16:38:30 -07008896 pScanFilter->ChannelInfo.numOfChannels = 0;
8897 if(HAL_STATUS_SUCCESS(status))
8898 {
8899 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
8900 {
8901 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
8902 {
8903 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
8904 = pProfile->ChannelInfo.ChannelList[index];
8905 pScanFilter->ChannelInfo.numOfChannels++;
8906 }
8907 else
8908 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008909 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid"), pProfile->ChannelInfo.ChannelList[index]);
Jeff Johnson295189b2012-06-20 16:38:30 -07008910 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008911 }
8912 }
8913 else
8914 {
8915 break;
8916 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008917 }
8918 else
8919 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05308920 smsLog(pMac, LOGE, FL("Channel list empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008921 status = eHAL_STATUS_FAILURE;
8922 break;
8923 }
8924 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
8925 pScanFilter->authType = pProfile->AuthType;
8926 pScanFilter->EncryptionType = pProfile->EncryptionType;
8927 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
8928 pScanFilter->BSSType = pProfile->BSSType;
8929 pScanFilter->phyMode = pProfile->phyMode;
8930#ifdef FEATURE_WLAN_WAPI
8931 //check if user asked for WAPI with 11n or auto mode, in that case modify
8932 //the phymode to 11g
8933 if(csrIsProfileWapi(pProfile))
8934 {
8935 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
8936 {
8937 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
8938 }
8939 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
8940 {
8941 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
8942 }
8943 if(!pScanFilter->phyMode)
8944 {
8945 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
8946 }
8947 }
8948#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07008949 /*Save the WPS info*/
8950 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -07008951 pScanFilter->bOSENAssociation = pProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07008952 if( pProfile->countryCode[0] )
8953 {
8954 //This causes the matching function to use countryCode as one of the criteria.
Kiet Lam64c1b492013-07-12 13:56:44 +05308955 vos_mem_copy(pScanFilter->countryCode, pProfile->countryCode,
8956 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008957 }
8958#ifdef WLAN_FEATURE_VOWIFI_11R
8959 if (pProfile->MDID.mdiePresent)
8960 {
8961 pScanFilter->MDID.mdiePresent = 1;
8962 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
8963 }
8964#endif
8965
8966 }while(0);
8967
8968 if(!HAL_STATUS_SUCCESS(status))
8969 {
8970 csrFreeScanFilter(pMac, pScanFilter);
8971 }
8972
8973 return(status);
8974}
8975
Jeff Johnson295189b2012-06-20 16:38:30 -07008976tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
8977 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
8978{
8979 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
8980 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07008981 do
8982 {
8983 // Validate the type is ok...
8984 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
8985 pCommand = csrGetCommandBuffer( pMac );
8986 if ( !pCommand )
8987 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008988 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008989 break;
8990 }
8991 //Change the substate in case it is waiting for key
8992 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8993 {
8994 csrRoamStopWaitForKeyTimer( pMac );
8995 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
8996 }
8997 pCommand->command = eSmeCommandWmStatusChange;
8998 pCommand->sessionId = (tANI_U8)sessionId;
8999 pCommand->u.wmStatusChangeCmd.Type = Type;
9000 if ( eCsrDisassociated == Type )
9001 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309002 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg,
9003 pSmeRsp,
9004 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07009005 }
9006 else
9007 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309008 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg,
9009 pSmeRsp,
9010 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07009011 }
9012 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
9013 {
9014 fCommandQueued = eANI_BOOLEAN_TRUE;
9015 }
9016 else
9017 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009018 smsLog( pMac, LOGE, FL(" fail to send message ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009019 csrReleaseCommandWmStatusChange( pMac, pCommand );
9020 }
9021
Jeff Johnson295189b2012-06-20 16:38:30 -07009022 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
9023 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07009024 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07009025 return( fCommandQueued );
9026}
9027
Jeff Johnson295189b2012-06-20 16:38:30 -07009028static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
9029{
9030 v_S7_t rssi = 0;
9031 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
9032 if(pGetRssiReq)
9033 {
9034 if(NULL != pGetRssiReq->pVosContext)
9035 {
9036 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
9037 }
9038 else
9039 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009040 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009041 return;
9042 }
9043
9044 if(NULL != pGetRssiReq->rssiCallback)
9045 {
9046 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
9047 }
9048 else
9049 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009050 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009051 return;
9052 }
9053 }
9054 else
9055 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009056 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009057 }
9058 return;
9059}
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309060
9061static void csrUpdateSnr(tpAniSirGlobal pMac, void* pMsg)
9062{
9063 tANI_S8 snr = 0;
9064 tAniGetSnrReq *pGetSnrReq = (tAniGetSnrReq*)pMsg;
9065
9066 if (pGetSnrReq)
9067 {
9068 if (VOS_STATUS_SUCCESS !=
9069 WDA_GetSnr(pGetSnrReq->staId, &snr))
9070 {
9071 smsLog(pMac, LOGE, FL("Error in WLANTL_GetSnr"));
9072 return;
9073 }
9074
9075 if (pGetSnrReq->snrCallback)
9076 {
9077 ((tCsrSnrCallback)(pGetSnrReq->snrCallback))(snr, pGetSnrReq->staId,
9078 pGetSnrReq->pDevContext);
9079 }
9080 else
9081 {
9082 smsLog(pMac, LOGE, FL("pGetSnrReq->snrCallback is NULL"));
9083 return;
9084 }
9085 }
9086 else
9087 {
9088 smsLog(pMac, LOGE, FL("pGetSnrReq is NULL"));
9089 }
9090 return;
9091}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009092#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009093void csrRoamRssiRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9094{
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009095 tAniGetRoamRssiRsp* pRoamRssiRsp = (tAniGetRoamRssiRsp*)pMsg;
9096
Jeff Johnson36d483b2013-04-08 11:08:53 -07009097 if (NULL != pRoamRssiRsp)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009098 {
Jeff Johnson36d483b2013-04-08 11:08:53 -07009099 /* Get roam Rssi request is backed up and passed back to the response,
9100 Extract the request message to fetch callback */
9101 tpAniGetRssiReq reqBkp = (tAniGetRssiReq*)pRoamRssiRsp->rssiReq;
9102 v_S7_t rssi = pRoamRssiRsp->rssi;
9103
9104 if ((NULL != reqBkp) && (NULL != reqBkp->rssiCallback))
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009105 {
9106 ((tCsrRssiCallback)(reqBkp->rssiCallback))(rssi, pRoamRssiRsp->staId, reqBkp->pDevContext);
9107 reqBkp->rssiCallback = NULL;
9108 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009109 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009110 }
9111 else
9112 {
9113 smsLog( pMac, LOGE, FL("reqBkp->rssiCallback is NULL"));
9114 if (NULL != reqBkp)
9115 {
9116 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009117 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009118 }
9119 }
9120 }
9121 else
9122 {
9123 smsLog( pMac, LOGE, FL("pRoamRssiRsp is NULL"));
9124 }
9125 return;
9126}
9127#endif
9128
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009129
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009130#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009131void csrTsmStatsRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9132{
9133 tAniGetTsmStatsRsp* pTsmStatsRsp = (tAniGetTsmStatsRsp*)pMsg;
9134
9135 if (NULL != pTsmStatsRsp)
9136 {
9137 /* Get roam Rssi request is backed up and passed back to the response,
9138 Extract the request message to fetch callback */
9139 tpAniGetTsmStatsReq reqBkp = (tAniGetTsmStatsReq*)pTsmStatsRsp->tsmStatsReq;
9140
9141 if (NULL != reqBkp)
9142 {
9143 if (NULL != reqBkp->tsmStatsCallback)
9144 {
9145 ((tCsrTsmStatsCallback)(reqBkp->tsmStatsCallback))(pTsmStatsRsp->tsmMetrics,
9146 pTsmStatsRsp->staId, reqBkp->pDevContext);
9147 reqBkp->tsmStatsCallback = NULL;
9148 }
9149 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009150 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009151 }
9152 else
9153 {
9154 smsLog( pMac, LOGE, FL("reqBkp is NULL"));
9155 if (NULL != reqBkp)
9156 {
9157 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009158 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009159 }
9160 }
9161 }
9162 else
9163 {
9164 smsLog( pMac, LOGE, FL("pTsmStatsRsp is NULL"));
9165 }
9166 return;
9167}
9168
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009169void csrSendEseAdjacentApRepInd(tpAniSirGlobal pMac, tCsrRoamSession *pSession)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009170{
9171 tANI_U32 roamTS2 = 0;
9172 tCsrRoamInfo roamInfo;
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009173 tpPESession pSessionEntry = NULL;
9174 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009175
9176 if (NULL == pSession)
9177 {
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009178 smsLog(pMac, LOGE, FL("pSession is NULL"));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009179 return;
9180 }
9181
9182 roamTS2 = vos_timer_get_system_time();
9183 roamInfo.tsmRoamDelay = roamTS2 - pSession->roamTS1;
Arif Hussaina7c8e412013-11-20 11:06:42 -08009184 smsLog(pMac, LOG1, "Bssid("MAC_ADDRESS_STR") Roaming Delay(%u ms)",
9185 MAC_ADDR_ARRAY(pSession->connectedProfile.bssid),
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009186 roamInfo.tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009187
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009188 pSessionEntry = peFindSessionByBssid(pMac, pSession->connectedProfile.bssid, &sessionId);
9189 if (NULL == pSessionEntry)
9190 {
9191 smsLog(pMac, LOGE, FL("session %d not found"), sessionId);
9192 return;
9193 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009194 pSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly = roamInfo.tsmRoamDelay;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009195 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009196 0, eCSR_ROAM_ESE_ADJ_AP_REPORT_IND, 0);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009197}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009198#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009199
Jeff Johnsone7245742012-09-05 17:12:55 -07009200static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
9201{
9202 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
9203 if(pTlRssiInd)
9204 {
9205 if(NULL != pTlRssiInd->tlCallback)
9206 {
9207 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -08009208 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07009209 }
9210 else
9211 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009212 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009213 }
9214 }
9215 else
9216 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009217 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009218 }
9219 return;
9220}
Jeff Johnson295189b2012-06-20 16:38:30 -07009221
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309222eHalStatus csrSendResetApCapsChanged(tpAniSirGlobal pMac, tSirMacAddr *bssId)
9223{
9224 tpSirResetAPCapsChange pMsg;
9225 tANI_U16 len;
9226 eHalStatus status = eHAL_STATUS_SUCCESS;
9227
9228 /* Create the message and send to lim */
9229 len = sizeof(tSirResetAPCapsChange);
Kiet Lam64c1b492013-07-12 13:56:44 +05309230 pMsg = vos_mem_malloc(len);
9231 if ( NULL == pMsg )
9232 status = eHAL_STATUS_FAILURE;
9233 else
9234 status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309235 if (HAL_STATUS_SUCCESS(status))
9236 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309237 vos_mem_set(pMsg, sizeof(tSirResetAPCapsChange), 0);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309238 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
9239 pMsg->length = len;
Kiet Lam64c1b492013-07-12 13:56:44 +05309240 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08009241 smsLog( pMac, LOG1, FL("CSR reset caps change for Bssid= "MAC_ADDRESS_STR),
9242 MAC_ADDR_ARRAY(pMsg->bssId));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309243 status = palSendMBMessage(pMac->hHdd, pMsg);
9244 }
9245 else
9246 {
9247 smsLog( pMac, LOGE, FL("Memory allocation failed\n"));
9248 }
9249 return status;
9250}
9251
Jeff Johnson295189b2012-06-20 16:38:30 -07009252void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
9253{
9254 tSirSmeAssocInd *pAssocInd;
9255 tSirSmeDisassocInd *pDisassocInd;
9256 tSirSmeDeauthInd *pDeauthInd;
9257 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
9258 tSirSmeNewBssInfo *pNewBss;
9259 tSmeIbssPeerInd *pIbssPeerInd;
9260 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
9261 tSirSmeApNewCaps *pApNewCaps;
9262 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
9263 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
9264 tCsrRoamInfo *pRoamInfo = NULL;
9265 tCsrRoamInfo roamInfo;
9266 eHalStatus status;
9267 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
9268 tCsrRoamSession *pSession = NULL;
9269 tpSirSmeSwitchChannelInd pSwitchChnInd;
9270 tSmeMaxAssocInd *pSmeMaxAssocInd;
Kiet Lam64c1b492013-07-12 13:56:44 +05309271 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
krunal soni587bf012014-02-04 12:35:11 -08009272
9273
9274 if (NULL == pSirMsg)
9275 { smsLog(pMac, LOGE, FL("pSirMsg is NULL"));
9276 return;
9277 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009278 switch( pSirMsg->messageType )
9279 {
9280 case eWNI_SME_ASSOC_IND:
9281 {
9282 tCsrRoamSession *pSession;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009283 smsLog( pMac, LOG1, FL("ASSOCIATION Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009284 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
9285 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
9286 if( HAL_STATUS_SUCCESS( status ) )
9287 {
9288 pSession = CSR_GET_SESSION(pMac, sessionId);
9289
Jeff Johnson32d95a32012-09-10 13:15:23 -07009290 if(!pSession)
9291 {
9292 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9293 return;
9294 }
9295
Jeff Johnson295189b2012-06-20 16:38:30 -07009296 pRoamInfo = &roamInfo;
9297
9298 // Required for indicating the frames to upper layer
9299 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
9300 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
9301
9302 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
9303 pRoamInfo->beaconLength = pAssocInd->beaconLength;
9304 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
9305 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9306
9307 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
9308 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
9309 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
9310
9311 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
9312 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05309313 vos_mem_copy(pRoamInfo->peerMac, pAssocInd->peerMacAddr,
9314 sizeof(tSirMacAddr));
9315 vos_mem_copy(&pRoamInfo->bssid, pAssocInd->bssId,
9316 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009317 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
9318 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07009319 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -07009320 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
9321 {
9322 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
9323 {
9324 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
9325 pSession->pConnectBssDesc,
9326 &(pRoamInfo->peerMac),
9327 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9328 pRoamInfo->fAuthRequired = FALSE;
9329 }
9330 else
9331 {
9332 pRoamInfo->fAuthRequired = TRUE;
9333 }
9334 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
9335 if (!HAL_STATUS_SUCCESS(status))
9336 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
9337 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009338 /* Send Association completion message to PE */
9339 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
9340
9341 /* send a message to CSR itself just to avoid the EAPOL frames going
9342 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -07009343 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
9344 {
9345 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9346 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009347 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
9348 {
9349 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
9350 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
9351 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9352 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009353 }
9354 }
9355 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009356 case eWNI_SME_DISASSOC_IND:
Jeff Johnson295189b2012-06-20 16:38:30 -07009357 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309358 // Check if AP dis-associated us because of MIC failure. If so,
9359 // then we need to take action immediately and not wait till the
9360 // the WmStatusChange requests is pushed and processed
9361 tSmeCmd *pCommand;
9362
9363 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
9364 status = csrRoamGetSessionIdFromBSSID( pMac,
9365 (tCsrBssid *)pDisassocInd->bssId, &sessionId );
9366 if( HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009367 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309368 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC"
9369 " for session %d "), sessionId);
9370 smsLog( pMac, LOGE, FL("DISASSOCIATION from peer ="
9371 MAC_ADDRESS_STR " "
9372 " reason = %d status = %d "),
9373 MAC_ADDR_ARRAY(pDisassocInd->peerMacAddr),
9374 pDisassocInd->reasonCode,
9375 pDisassocInd->statusCode);
9376 // If we are in neighbor preauth done state then on receiving
9377 // disassoc or deauth we dont roam instead we just disassoc
9378 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009379 // This happens for ESE and 11r FT connections ONLY.
Agarwal Ashish4f616132013-12-30 23:32:50 +05309380#ifdef WLAN_FEATURE_VOWIFI_11R
9381 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9382 {
9383 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9384 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009385#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009386#ifdef FEATURE_WLAN_ESE
9387 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Agarwal Ashish4f616132013-12-30 23:32:50 +05309388 {
9389 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9390 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009391#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009392#ifdef FEATURE_WLAN_LFR
Agarwal Ashish4f616132013-12-30 23:32:50 +05309393 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
9394 {
9395 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9396 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009397#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +05309398 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009399
Agarwal Ashish4f616132013-12-30 23:32:50 +05309400 if (!pSession)
9401 {
9402 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9403 return;
9404 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07009405
Agarwal Ashish4f616132013-12-30 23:32:50 +05309406 if ( csrIsConnStateInfra( pMac, sessionId ) )
9407 {
9408 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9409 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009410#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Agarwal Ashish4f616132013-12-30 23:32:50 +05309411 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009412#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +05309413 csrRoamLinkDown(pMac, sessionId);
9414 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
9415 if (CSR_IS_INFRA_AP(&pSession->connectedProfile))
9416 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309417 pRoamInfo = &roamInfo;
9418 pRoamInfo->statusCode = pDisassocInd->statusCode;
9419 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9420 pRoamInfo->staId = (tANI_U8)pDisassocInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009421
Agarwal Ashish4f616132013-12-30 23:32:50 +05309422 vos_mem_copy(pRoamInfo->peerMac, pDisassocInd->peerMacAddr,
9423 sizeof(tSirMacAddr));
9424 vos_mem_copy(&pRoamInfo->bssid, pDisassocInd->bssId,
9425 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009426
Agarwal Ashish4f616132013-12-30 23:32:50 +05309427 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9428 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DISASSOC_IND);
Jeff Johnson295189b2012-06-20 16:38:30 -07009429
Agarwal Ashish4f616132013-12-30 23:32:50 +05309430 /*
9431 * STA/P2P client got disassociated so remove any pending deauth
9432 * commands in sme pending list
9433 */
Kaushik, Sushant488df382014-03-05 11:43:47 +05309434 pCommand = csrGetCommandBuffer(pMac);
9435 if (NULL == pCommand)
9436 {
9437 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
9438 status = eHAL_STATUS_RESOURCES;
9439 return;
9440 }
Agarwal Ashish4f616132013-12-30 23:32:50 +05309441 pCommand->command = eSmeCommandRoam;
9442 pCommand->sessionId = (tANI_U8)sessionId;
9443 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
9444 vos_mem_copy(pCommand->u.roamCmd.peerMac,
9445 pDisassocInd->peerMacAddr,
9446 sizeof(tSirMacAddr));
9447 csrRoamRemoveDuplicateCommand(pMac, sessionId, pCommand, eCsrForcedDeauthSta);
9448 csrReleaseCommand( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07009449
Agarwal Ashish4f616132013-12-30 23:32:50 +05309450 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009451 }
Agarwal Ashish4f616132013-12-30 23:32:50 +05309452 else
9453 {
9454 smsLog(pMac, LOGE, FL(" Session Id not found for BSSID " MAC_ADDRESS_STR),
9455 MAC_ADDR_ARRAY(pDisassocInd->bssId));
9456 }
Kiet Lam82004c62013-11-11 13:24:28 +05309457 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009458 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009459 case eWNI_SME_DEAUTH_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009460 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009461 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
9462 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
9463 if( HAL_STATUS_SUCCESS( status ) )
9464 {
9465 // If we are in neighbor preauth done state then on receiving
9466 // disassoc or deauth we dont roam instead we just disassoc
9467 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009468 // This happens for ESE and 11r FT connections ONLY.
Jeff Johnson295189b2012-06-20 16:38:30 -07009469#ifdef WLAN_FEATURE_VOWIFI_11R
9470 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9471 {
9472 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9473 }
9474#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009475#ifdef FEATURE_WLAN_ESE
9476 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson295189b2012-06-20 16:38:30 -07009477 {
9478 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9479 }
9480#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009481#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05309482 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009483 {
9484 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9485 }
9486#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009487 pSession = CSR_GET_SESSION( pMac, sessionId );
9488
Jeff Johnson32d95a32012-09-10 13:15:23 -07009489 if(!pSession)
9490 {
9491 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9492 return;
9493 }
9494
Jeff Johnson295189b2012-06-20 16:38:30 -07009495 if ( csrIsConnStateInfra( pMac, sessionId ) )
9496 {
9497 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9498 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009499#ifndef WLAN_MDM_CODE_REDUCTION_OPT
9500 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
9501#endif
9502 csrRoamLinkDown(pMac, sessionId);
9503 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07009504 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
9505 {
9506
9507 pRoamInfo = &roamInfo;
9508
9509 pRoamInfo->statusCode = pDeauthInd->statusCode;
9510 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9511
9512 pRoamInfo->staId = (tANI_U8)pDeauthInd->staId;
9513
Kiet Lam64c1b492013-07-12 13:56:44 +05309514 vos_mem_copy(pRoamInfo->peerMac, pDeauthInd->peerMacAddr,
9515 sizeof(tSirMacAddr));
9516 vos_mem_copy(&pRoamInfo->bssid, pDeauthInd->bssId,
9517 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009518
9519 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DEAUTH_IND);
9520 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009521 }
9522 break;
9523
9524 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 -08009525 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009526 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
9527 //Update with the new channel id.
9528 //The channel id is hidden in the statusCode.
9529 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
9530 if( HAL_STATUS_SUCCESS( status ) )
9531 {
9532 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009533 if(!pSession)
9534 {
9535 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9536 return;
9537 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009538 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
9539 if(pSession->pConnectBssDesc)
9540 {
9541 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
9542 }
9543 }
9544 break;
9545
9546 case eWNI_SME_DEAUTH_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009547 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009548 {
9549 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
9550 sessionId = pDeauthRsp->sessionId;
9551 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9552 {
9553 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009554 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9555 {
9556 pRoamInfo = &roamInfo;
9557 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309558 vos_mem_copy(pRoamInfo->peerMac, pDeauthRsp->peerMacAddr,
9559 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009560 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9561 pRoamInfo->statusCode = pDeauthRsp->statusCode;
9562 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9563 }
9564 }
9565 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009566 break;
9567
9568 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009569 /* session id is invalid here so cant use it to access the array curSubstate as index */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009570 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -07009571 {
9572 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
9573 sessionId = pDisassocRsp->sessionId;
9574 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9575 {
9576 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009577 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9578 {
9579 pRoamInfo = &roamInfo;
9580 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309581 vos_mem_copy(pRoamInfo->peerMac, pDisassocRsp->peerMacAddr,
9582 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009583 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9584 pRoamInfo->statusCode = pDisassocRsp->statusCode;
9585 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9586 }
9587 }
9588 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009589 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009590 case eWNI_SME_MIC_FAILURE_IND:
9591 {
9592 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
9593 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
9594 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Leo Chang9b01ad92013-09-12 17:26:56 -07009595
9596 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
9597 if( HAL_STATUS_SUCCESS( status ) )
9598 {
Kiet Lamf2f201e2013-11-16 21:24:16 +05309599 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Leo Chang9b01ad92013-09-12 17:26:56 -07009600 roamInfo.u.pMICFailureInfo = &pMicInd->info;
9601 pRoamInfo = &roamInfo;
9602 if(pMicInd->info.multicast)
9603 {
9604 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
9605 }
9606 else
9607 {
9608 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
9609 }
9610 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
9611 }
9612
Jeff Johnson295189b2012-06-20 16:38:30 -07009613#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9614 {
lukez3c809222013-05-03 10:23:02 -07009615 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07009616 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009617 if(!pSession)
9618 {
9619 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9620 return;
9621 }
lukez3c809222013-05-03 10:23:02 -07009622
Kiet Lam64c1b492013-07-12 13:56:44 +05309623 vos_mem_set(&secEvent, sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009624 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
9625 secEvent.encryptionModeMulticast =
9626 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9627 secEvent.encryptionModeUnicast =
9628 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9629 secEvent.authMode =
9630 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309631 vos_mem_copy(secEvent.bssid,
9632 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009633 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
9634 }
9635#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009636 }
9637 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009638 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
9639 {
9640 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
9641 tCsrRoamInfo roamInfo;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009642 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009643
9644 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
9645 if( HAL_STATUS_SUCCESS( status ) )
9646 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309647 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009648 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
9649 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
9650 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
9651 }
9652 }
9653 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009654
Jeff Johnson295189b2012-06-20 16:38:30 -07009655 case eWNI_SME_WM_STATUS_CHANGE_NTF:
9656 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
9657 switch( pStatusChangeMsg->statusChangeCode )
9658 {
9659 case eSIR_SME_IBSS_ACTIVE:
9660 sessionId = csrFindIbssSession( pMac );
9661 if( CSR_SESSION_ID_INVALID != sessionId )
9662 {
9663 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009664 if(!pSession)
9665 {
9666 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9667 return;
9668 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009669 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
9670 if(pSession->pConnectBssDesc)
9671 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309672 vos_mem_copy(&roamInfo.bssid,
9673 pSession->pConnectBssDesc->bssId,
9674 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009675 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
9676 pRoamInfo = &roamInfo;
9677 }
9678 else
9679 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009680 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009681 }
9682 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
9683 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9684 }
9685 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009686 case eSIR_SME_IBSS_INACTIVE:
9687 sessionId = csrFindIbssSession( pMac );
9688 if( CSR_SESSION_ID_INVALID != sessionId )
9689 {
9690 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009691 if(!pSession)
9692 {
9693 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9694 return;
9695 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009696 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
9697 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
9698 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9699 }
9700 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009701 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
9702 sessionId = csrFindIbssSession( pMac );
9703 if( CSR_SESSION_ID_INVALID != sessionId )
9704 {
9705 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009706 if(!pSession)
9707 {
9708 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9709 return;
9710 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009711 // update the connection state information
9712 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009713#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9714 {
9715 vos_log_ibss_pkt_type *pIbssLog;
9716 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -07009717 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9718 if(pIbssLog)
9719 {
9720 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
9721 if(pNewBss)
9722 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309723 vos_mem_copy(pIbssLog->bssid, pNewBss->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009724 if(pNewBss->ssId.length)
9725 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309726 vos_mem_copy(pIbssLog->ssid, pNewBss->ssId.ssId,
9727 pNewBss->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07009728 }
9729 pIbssLog->operatingChannel = pNewBss->channelNumber;
9730 }
9731 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
9732 {
9733 //***U8 is not enough for beacon interval
9734 pIbssLog->beaconInterval = (v_U8_t)bi;
9735 }
9736 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9737 }
9738 }
9739#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009740 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009741
9742 if ((eCSR_ENCRYPT_TYPE_NONE ==
9743 pSession->connectedProfile.EncryptionType ))
9744 {
9745 csrRoamIssueSetContextReq( pMac, sessionId,
9746 pSession->connectedProfile.EncryptionType,
9747 pSession->pConnectBssDesc,
9748 &Broadcastaddr,
9749 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
9750 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009751 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
9752 roamStatus = eCSR_ROAM_IBSS_IND;
Kiet Lam64c1b492013-07-12 13:56:44 +05309753 vos_mem_copy(&roamInfo.bssid, &pNewBss->bssId,
9754 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009755 pRoamInfo = &roamInfo;
9756 //This BSSID is th ereal BSSID, let's save it
9757 if(pSession->pConnectBssDesc)
9758 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309759 vos_mem_copy(pSession->pConnectBssDesc->bssId,
9760 &pNewBss->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009761 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009762 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009763 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Jeff Johnson295189b2012-06-20 16:38:30 -07009764 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009765 // detection by LIM that the capabilities of the associated AP have changed.
9766 case eSIR_SME_AP_CAPS_CHANGED:
9767 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009768 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED");
Jeff Johnson295189b2012-06-20 16:38:30 -07009769 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
9770 if( HAL_STATUS_SUCCESS( status ) )
9771 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009772 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
9773 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309774 (eCSR_ROAM_SUBSTATE_NONE == pMac->roam.curSubState[sessionId]) ||
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009775 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
9776 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
9777 )
9778 {
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309779 smsLog(pMac, LOGW, "Calling csrRoamDisconnectInternal");
9780 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009781 }
9782 else
9783 {
9784 smsLog(pMac, LOGW,
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05309785 FL("Skipping csrScanForCapabilityChange as "
9786 "CSR is in state %s and sub-state %s"),
9787 macTraceGetcsrRoamState(
9788 pMac->roam.curState[sessionId]),
9789 macTraceGetcsrRoamSubState(
9790 pMac->roam.curSubState[sessionId]));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309791 /* We ignore the caps change event if CSR is not in full connected state.
9792 * Send one event to PE to reset limSentCapsChangeNtf
9793 * Once limSentCapsChangeNtf set 0, lim can send sub sequent CAPS change event
9794 * otherwise lim cannot send any CAPS change events to SME */
9795 csrSendResetApCapsChanged(pMac, &pApNewCaps->bssId);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009796 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009797 }
9798 break;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309799
Jeff Johnson295189b2012-06-20 16:38:30 -07009800 default:
9801 roamStatus = eCSR_ROAM_FAILED;
9802 result = eCSR_ROAM_RESULT_NONE;
9803 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009804 } // end switch on statusChangeCode
9805 if(eCSR_ROAM_RESULT_NONE != result)
9806 {
9807 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
9808 }
9809 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009810 case eWNI_SME_IBSS_NEW_PEER_IND:
9811 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07009812#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9813 {
9814 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07009815 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9816 if(pIbssLog)
9817 {
9818 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309819 vos_mem_copy(pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009820 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9821 }
9822 }
9823#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009824 sessionId = csrFindIbssSession( pMac );
9825 if( CSR_SESSION_ID_INVALID != sessionId )
9826 {
9827 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009828
9829 if(!pSession)
9830 {
9831 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9832 return;
9833 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009834 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
9835 if(pSession->pConnectBssDesc)
9836 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309837 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
9838 sizeof(tCsrBssid));
9839 vos_mem_copy(&roamInfo.bssid, pSession->pConnectBssDesc->bssId,
9840 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009841 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
9842 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309843 roamInfo.pbFrames = vos_mem_malloc((pIbssPeerInd->mesgLen
9844 - sizeof(tSmeIbssPeerInd)));
9845 if ( NULL == roamInfo.pbFrames )
9846 status = eHAL_STATUS_FAILURE;
9847 else
9848 status = eHAL_STATUS_SUCCESS;
9849 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07009850 {
9851 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
Kiet Lam64c1b492013-07-12 13:56:44 +05309852 vos_mem_copy(roamInfo.pbFrames,
9853 ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
9854 roamInfo.nBeaconLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07009855 }
9856 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9857 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9858 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05309859 roamInfo.pBssDesc = vos_mem_malloc(pSession->pConnectBssDesc->length);
9860 if ( NULL == roamInfo.pBssDesc )
9861 status = eHAL_STATUS_FAILURE;
9862 else
9863 status = eHAL_STATUS_SUCCESS;
9864 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07009865 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309866 vos_mem_copy(roamInfo.pBssDesc,
9867 pSession->pConnectBssDesc,
9868 pSession->pConnectBssDesc->length);
Jeff Johnson295189b2012-06-20 16:38:30 -07009869 }
9870 if(HAL_STATUS_SUCCESS(status))
9871 {
9872 pRoamInfo = &roamInfo;
9873 }
9874 else
9875 {
9876 if(roamInfo.pbFrames)
9877 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309878 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -07009879 }
9880 if(roamInfo.pBssDesc)
9881 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309882 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07009883 }
9884 }
9885 }
9886 else
9887 {
9888 pRoamInfo = &roamInfo;
9889 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009890 if ((eCSR_ENCRYPT_TYPE_NONE ==
9891 pSession->connectedProfile.EncryptionType ))
9892 {
9893 csrRoamIssueSetContextReq( pMac, sessionId,
9894 pSession->connectedProfile.EncryptionType,
9895 pSession->pConnectBssDesc,
9896 &(pIbssPeerInd->peerAddr),
9897 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9898 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009899 }
9900 else
9901 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009902 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009903 }
9904 //send up the sec type for the new peer
9905 if (pRoamInfo)
9906 {
9907 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9908 }
9909 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9910 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
9911 if(pRoamInfo)
9912 {
9913 if(roamInfo.pbFrames)
9914 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309915 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -07009916 }
9917 if(roamInfo.pBssDesc)
9918 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309919 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07009920 }
9921 }
9922 }
9923 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009924 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
9925 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
9926 sessionId = csrFindIbssSession( pMac );
9927 if( CSR_SESSION_ID_INVALID != sessionId )
9928 {
Jeff Johnson295189b2012-06-20 16:38:30 -07009929#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9930 {
9931 vos_log_ibss_pkt_type *pIbssLog;
9932
9933 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9934 if(pIbssLog)
9935 {
9936 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
9937 if(pIbssPeerInd)
9938 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309939 vos_mem_copy(pIbssLog->peerMacAddr,
9940 &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009941 }
9942 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9943 }
9944 }
9945#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009946 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM");
Jeff Johnson295189b2012-06-20 16:38:30 -07009947 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9948 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
9949 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05309950 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
9951 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009952 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
9953 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
9954 }
9955 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009956 case eWNI_SME_SETCONTEXT_RSP:
9957 {
9958 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
9959 tListElem *pEntry;
9960 tSmeCmd *pCommand;
9961
9962 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
9963 if ( pEntry )
9964 {
9965 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
9966 if ( eSmeCommandSetKey == pCommand->command )
9967 {
Sandeep Puligilla9f384742014-04-11 02:27:04 +05309968 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009969 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009970
9971 if(!pSession)
9972 {
9973 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9974 return;
9975 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009976
9977#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9978 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
9979 {
9980 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +05309981 vos_mem_set(&setKeyEvent,
9982 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009983 if( pRsp->peerMacAddr[0] & 0x01 )
9984 {
9985 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
9986 }
9987 else
9988 {
9989 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
9990 }
9991 setKeyEvent.encryptionModeMulticast =
9992 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9993 setKeyEvent.encryptionModeUnicast =
9994 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309995 vos_mem_copy(setKeyEvent.bssid,
9996 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009997 setKeyEvent.authMode =
9998 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -07009999 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010000 {
10001 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10002 }
10003 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
10004 }
10005#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
10006 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
10007 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010008 csrRoamStopWaitForKeyTimer( pMac );
10009
Jeff Johnson295189b2012-06-20 16:38:30 -070010010 //We are done with authentication, whethere succeed or not
10011 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010012 //We do it here because this linkup function is not called after association
10013 //when a key needs to be set.
10014 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
10015 {
10016 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10017 }
10018 }
Jeff Johnson43971f52012-07-17 12:26:56 -070010019 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010020 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010021 vos_mem_copy(&roamInfo.peerMac,
10022 &pRsp->peerMacAddr, sizeof(tCsrBssid));
Jeff Johnsone7245742012-09-05 17:12:55 -070010023 //Make sure we install the GTK before indicating to HDD as authenticated
10024 //This is to prevent broadcast packets go out after PTK and before GTK.
Kiet Lam64c1b492013-07-12 13:56:44 +053010025 if ( vos_mem_compare( &Broadcastaddr, pRsp->peerMacAddr,
10026 sizeof(tSirMacAddr) ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070010027 {
Yathish9f22e662012-12-10 14:21:35 -080010028#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
10029 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
10030 {
10031 tpSirSetActiveModeSetBncFilterReq pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053010032 pMsg = vos_mem_malloc(sizeof(tSirSetActiveModeSetBncFilterReq));
Yathish9f22e662012-12-10 14:21:35 -080010033 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
10034 pMsg->length = pal_cpu_to_be16(sizeof( tANI_U8));
10035 pMsg->seesionId = sessionId;
10036 status = palSendMBMessage(pMac->hHdd, pMsg );
10037 }
10038#endif
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010039 /* OBSS SCAN Indication will be sent to Firmware to start OBSS Scan */
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010040 if( CSR_IS_CHANNEL_24GHZ(pSession->connectedProfile.operationChannel)
10041 && IS_HT40_OBSS_SCAN_FEATURE_ENABLE )
10042 {
10043 tpSirSmeHT40OBSSScanInd pMsg;
10044 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSScanInd));
10045 pMsg->messageType =
10046 pal_cpu_to_be16((tANI_U16)eWNI_SME_HT40_OBSS_SCAN_IND);
10047 pMsg->length =
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010048 pal_cpu_to_be16(sizeof( tSirSmeHT40OBSSScanInd));
10049 vos_mem_copy(pMsg->peerMacAddr,
10050 pSession->connectedProfile.bssid,
10051 sizeof(tSirMacAddr));
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010052 status = palSendMBMessage(pMac->hHdd,
10053 pMsg );
10054 }
10055 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -070010056 }
10057 else
10058 {
10059 result = eCSR_ROAM_RESULT_NONE;
10060 }
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010061 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010062 }
10063 else
10064 {
10065 result = eCSR_ROAM_RESULT_FAILURE;
Arif Hussaina7c8e412013-11-20 11:06:42 -080010066 smsLog(pMac, LOGE, "CSR: Roam Completion setkey "
10067 "command failed(%d) PeerMac "MAC_ADDRESS_STR,
10068 pRsp->statusCode, MAC_ADDR_ARRAY(pRsp->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070010069 }
10070 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10071 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -070010072 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
10073 // can go ahead and initiate the TSPEC if any are pending
10074 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010075#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070010076 //Send Adjacent AP repot to new AP.
10077 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
10078 pSession->isPrevApInfoValid &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010079 pSession->connectedProfile.isESEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070010080 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010081#ifdef FEATURE_WLAN_ESE_UPLOAD
10082 csrSendEseAdjacentApRepInd(pMac, pSession);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010083#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010084 csrEseSendAdjacentApRepMsg(pMac, pSession);
Jeff Johnson295189b2012-06-20 16:38:30 -070010085#endif
10086 pSession->isPrevApInfoValid = FALSE;
10087 }
10088#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010089 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10090 {
10091 csrReleaseCommandSetKey( pMac, pCommand );
10092 }
10093 }
10094 else
10095 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010096 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010097 }
10098 }
10099 else
10100 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010101 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010102 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010103 smeProcessPendingQueue( pMac );
10104 }
10105 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010106 case eWNI_SME_REMOVEKEY_RSP:
10107 {
10108 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
10109 tListElem *pEntry;
10110 tSmeCmd *pCommand;
10111
10112 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10113 if ( pEntry )
10114 {
10115 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10116 if ( eSmeCommandRemoveKey == pCommand->command )
10117 {
10118 sessionId = pCommand->sessionId;
10119 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010120
10121 if(!pSession)
10122 {
10123 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10124 return;
10125 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010126#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10127 {
10128 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053010129 vos_mem_set(&removeKeyEvent,
10130 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010131 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
10132 removeKeyEvent.encryptionModeMulticast =
10133 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10134 removeKeyEvent.encryptionModeUnicast =
10135 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010136 vos_mem_copy( removeKeyEvent.bssid,
10137 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010138 removeKeyEvent.authMode =
10139 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -070010140 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010141 {
10142 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10143 }
10144 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
10145 }
10146#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -070010147 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010148 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010149 vos_mem_copy(&roamInfo.peerMac, &pRsp->peerMacAddr,
10150 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010151 result = eCSR_ROAM_RESULT_NONE;
10152 pRoamInfo = &roamInfo;
10153 }
10154 else
10155 {
10156 result = eCSR_ROAM_RESULT_FAILURE;
10157 }
10158 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10159 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
10160 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10161 {
10162 csrReleaseCommandRemoveKey( pMac, pCommand );
10163 }
10164 }
10165 else
10166 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010167 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010168 }
10169 }
10170 else
10171 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010172 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010173 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010174 smeProcessPendingQueue( pMac );
10175 }
10176 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010177 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010178 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010179 csrRoamStatsRspProcessor( pMac, pSirMsg );
10180 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010181#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080010182 case eWNI_SME_GET_ROAM_RSSI_RSP:
10183 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
10184 csrRoamRssiRspProcessor( pMac, pSirMsg );
10185 break;
10186#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010187#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010188 case eWNI_SME_GET_TSM_STATS_RSP:
10189 smsLog( pMac, LOG2, FL("TSM Stats rsp from PE"));
10190 csrTsmStatsRspProcessor( pMac, pSirMsg );
10191 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010192#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -070010193 case eWNI_SME_GET_RSSI_REQ:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010194 smsLog( pMac, LOG2, FL("GetRssiReq from self"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010195 csrUpdateRssi( pMac, pSirMsg );
10196 break;
10197
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053010198 case eWNI_SME_GET_SNR_REQ:
10199 smsLog( pMac, LOG2, FL("GetSnrReq from self"));
10200 csrUpdateSnr(pMac, pSirMsg);
10201 break;
10202
Jeff Johnson295189b2012-06-20 16:38:30 -070010203#ifdef WLAN_FEATURE_VOWIFI_11R
10204 case eWNI_SME_FT_PRE_AUTH_RSP:
10205 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
10206 break;
10207#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010208 case eWNI_SME_MAX_ASSOC_EXCEEDED:
10209 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010210 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 -070010211 sessionId = pSmeMaxAssocInd->sessionId;
10212 roamInfo.sessionId = sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053010213 vos_mem_copy(&roamInfo.peerMac, pSmeMaxAssocInd->peerMac,
10214 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010215 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
10216 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
10217 break;
10218
10219 case eWNI_SME_BTAMP_LOG_LINK_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010220 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010221 btampEstablishLogLinkHdlr( pSirMsg );
10222 break;
Jeff Johnsone7245742012-09-05 17:12:55 -070010223 case eWNI_SME_RSSI_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010224 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread"));
Jeff Johnsone7245742012-09-05 17:12:55 -070010225 csrRoamRssiIndHdlr( pMac, pSirMsg );
10226 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010227#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
10228 case eWNI_SME_CANDIDATE_FOUND_IND:
10229 smsLog( pMac, LOG2, FL("Candidate found indication from PE"));
10230 csrNeighborRoamCandidateFoundIndHdlr( pMac, pSirMsg );
10231 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070010232 case eWNI_SME_HANDOFF_REQ:
10233 smsLog( pMac, LOG2, FL("Handoff Req from self"));
10234 csrNeighborRoamHandoffReqHdlr( pMac, pSirMsg );
10235 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010236#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010237
10238 default:
10239 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010240 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -070010241}
10242
Jeff Johnson295189b2012-06-20 16:38:30 -070010243void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
10244 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
10245{
10246 if(pSession)
10247 {
10248 if(pSession->bRefAssocStartCnt)
10249 {
10250 pSession->bRefAssocStartCnt--;
10251 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
10252 //Need to call association_completion because there is an assoc_start pending.
10253 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
10254 eCSR_ROAM_ASSOCIATION_COMPLETION,
10255 eCSR_ROAM_RESULT_FAILURE);
10256 }
10257 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
10258 }
10259 else
10260 {
10261 smsLog(pMac, LOGW, FL(" pSession is NULL"));
10262 }
10263}
10264
10265
10266eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
10267{
10268 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010269 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
10270 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
10271 {
10272 status = csrScanRequestLostLink1( pMac, sessionId );
10273 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010274 return(status);
10275}
10276
Jeff Johnson295189b2012-06-20 16:38:30 -070010277//return a boolean to indicate whether roaming completed or continue.
10278tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
10279 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
10280{
10281 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
10282 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
10283 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10284 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010285 if(!pSession)
10286 {
10287 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10288 return eANI_BOOLEAN_FALSE;
10289 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010290 //Check whether time is up
10291 if(pSession->fCancelRoaming || fForce ||
10292 ((curTime - pSession->roamingStartTime) > roamTime) ||
10293 eCsrReassocRoaming == pSession->roamingReason ||
10294 eCsrDynamicRoaming == pSession->roamingReason)
10295 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010296 smsLog(pMac, LOGW, FL(" indicates roaming completion"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010297 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
10298 {
10299 //roaming is cancelled, tell HDD to indicate disconnect
10300 //Because LIM overload deauth_ind for both deauth frame and missed beacon
10301 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
10302 //to be eSIR_BEACON_MISSED
10303 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
10304 {
10305 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10306 }
10307 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
10308 {
10309 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
10310 }
10311 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
10312 {
10313 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
10314 }
10315 else
10316 {
10317 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10318 }
10319 }
10320 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10321 pSession->roamingReason = eCsrNotRoaming;
10322 }
10323 else
10324 {
10325 pSession->roamResult = roamResult;
10326 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
10327 {
10328 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10329 pSession->roamingReason = eCsrNotRoaming;
10330 }
10331 else
10332 {
10333 fCompleted = eANI_BOOLEAN_FALSE;
10334 }
10335 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010336 return(fCompleted);
10337}
10338
Jeff Johnson295189b2012-06-20 16:38:30 -070010339void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
10340{
10341 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010342
10343 if(!pSession)
10344 {
10345 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10346 return;
10347 }
10348
Jeff Johnson295189b2012-06-20 16:38:30 -070010349 if(CSR_IS_ROAMING(pSession))
10350 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010351 smsLog(pMac, LOGW, " Cancelling roaming");
Jeff Johnson295189b2012-06-20 16:38:30 -070010352 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
10353 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
10354 {
10355 //No need to do anything in here because the handler takes care of it
10356 }
10357 else
10358 {
10359 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
10360 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
10361 //Roaming is stopped after here
10362 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
10363 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053010364 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010365 csrRoamStopRoamingTimer(pMac, sessionId);
10366 }
10367 }
10368}
10369
Jeff Johnson295189b2012-06-20 16:38:30 -070010370void csrRoamRoamingTimerHandler(void *pv)
10371{
10372 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10373 tpAniSirGlobal pMac = pInfo->pMac;
10374 tANI_U32 sessionId = pInfo->sessionId;
10375 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010376
10377 if(!pSession)
10378 {
10379 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10380 return;
10381 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010382
10383 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
10384 {
10385 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
10386 {
10387 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
10388 pSession->roamingReason = eCsrNotRoaming;
10389 }
10390 }
10391}
10392
Jeff Johnson295189b2012-06-20 16:38:30 -070010393eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
10394{
10395 eHalStatus status;
10396 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010397
10398 if(!pSession)
10399 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010400 smsLog(pMac, LOGE, FL(" session %d not found"), sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -070010401 return eHAL_STATUS_FAILURE;
10402 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010403
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010404 smsLog(pMac, LOG1, " csrScanStartRoamingTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070010405 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010406 status = vos_timer_start(&pSession->hTimerRoaming, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010407
10408 return (status);
10409}
10410
Jeff Johnson295189b2012-06-20 16:38:30 -070010411eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
10412{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010413 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerRoaming));
Jeff Johnson295189b2012-06-20 16:38:30 -070010414}
10415
Jeff Johnson295189b2012-06-20 16:38:30 -070010416void csrRoamWaitForKeyTimeOutHandler(void *pv)
10417{
10418 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10419 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010420 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080010421 eHalStatus status = eHAL_STATUS_FAILURE;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010422
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010423 smsLog(pMac, LOGW, FL("WaitForKey timer expired in state=%s sub-state=%s"),
10424 macTraceGetNeighbourRoamState(
10425 pMac->roam.neighborRoamInfo.neighborRoamState),
10426 macTraceGetcsrRoamSubState(
10427 pMac->roam.curSubState[pInfo->sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010428
Jeff Johnson295189b2012-06-20 16:38:30 -070010429 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
10430 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010431#ifdef FEATURE_WLAN_LFR
10432 if (csrNeighborRoamIsHandoffInProgress(pMac))
10433 {
10434 /*
10435 * Enable heartbeat timer when hand-off is in progress
10436 * and Key Wait timer expired.
10437 */
10438 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010439 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010440 pMac->roam.configParam.HeartbeatThresh24);
10441 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10442 pMac->roam.configParam.HeartbeatThresh24,
10443 NULL, eANI_BOOLEAN_FALSE);
10444 }
10445#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010446 smsLog(pMac, LOGW, " SME pre-auth state timeout. ");
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010447
Jeff Johnson295189b2012-06-20 16:38:30 -070010448 //Change the substate so command queue is unblocked.
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010449 if (CSR_ROAM_SESSION_MAX > pInfo->sessionId)
10450 {
10451 csrRoamSubstateChange(pMac, eCSR_ROAM_SUBSTATE_NONE,
10452 pInfo->sessionId);
10453 }
10454
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010455 if (pSession)
10456 {
10457 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
10458 {
10459 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10460 smeProcessPendingQueue(pMac);
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080010461 if( (pSession->connectedProfile.AuthType ==
10462 eCSR_AUTH_TYPE_SHARED_KEY) &&
10463 ( (pSession->connectedProfile.EncryptionType ==
10464 eCSR_ENCRYPT_TYPE_WEP40) ||
10465 (pSession->connectedProfile.EncryptionType ==
10466 eCSR_ENCRYPT_TYPE_WEP104) ))
10467 {
10468 status = sme_AcquireGlobalLock( &pMac->sme );
10469 if ( HAL_STATUS_SUCCESS( status ) )
10470 {
10471 csrRoamDisconnect( pMac, pInfo->sessionId,
10472 eCSR_DISCONNECT_REASON_UNSPECIFIED );
10473 sme_ReleaseGlobalLock( &pMac->sme );
10474 }
10475 }
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010476 }
10477 else
10478 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010479 smsLog(pMac, LOGW, "%s: could not post link up",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010480 __func__);
10481 }
10482 }
10483 else
10484 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010485 smsLog(pMac, LOGW, "%s: session not found", __func__);
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010486 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010487 }
10488
10489}
10490
Jeff Johnson295189b2012-06-20 16:38:30 -070010491eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
10492{
10493 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010494#ifdef FEATURE_WLAN_LFR
10495 if (csrNeighborRoamIsHandoffInProgress(pMac))
10496 {
10497 /* Disable heartbeat timer when hand-off is in progress */
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010498 smsLog(pMac, LOG2, FL("disabling HB timer in state=%s sub-state=%s"),
10499 macTraceGetNeighbourRoamState(
10500 pMac->roam.neighborRoamInfo.neighborRoamState),
10501 macTraceGetcsrRoamSubState(
10502 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]
10503 ));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010504 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
10505 }
10506#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010507 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010508 status = vos_timer_start(&pMac->roam.hTimerWaitForKey, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010509
10510 return (status);
10511}
10512
Jeff Johnson295189b2012-06-20 16:38:30 -070010513eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
10514{
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010515 smsLog(pMac, LOG2, FL("WaitForKey timer stopped in state=%s sub-state=%s"),
10516 macTraceGetNeighbourRoamState(
10517 pMac->roam.neighborRoamInfo.neighborRoamState),
10518 macTraceGetcsrRoamSubState(
10519 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010520#ifdef FEATURE_WLAN_LFR
10521 if (csrNeighborRoamIsHandoffInProgress(pMac))
10522 {
10523 /*
10524 * Enable heartbeat timer when hand-off is in progress
10525 * and Key Wait timer got stopped for some reason
10526 */
10527 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010528 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010529 pMac->roam.configParam.HeartbeatThresh24);
10530 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10531 pMac->roam.configParam.HeartbeatThresh24,
10532 NULL, eANI_BOOLEAN_FALSE);
10533 }
10534#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010535 return (vos_timer_stop(&pMac->roam.hTimerWaitForKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070010536}
10537
Jeff Johnson295189b2012-06-20 16:38:30 -070010538void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
10539 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
10540{
10541 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
10542 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010543 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
10544 /* To silence the KW tool Null chaeck is added */
10545 if(!pSession)
10546 {
10547 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10548 return;
10549 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010550
10551 if(pCommand)
10552 {
10553 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010554 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070010555 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010556 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
10557 {
10558 //if success, force roaming completion
10559 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
10560 }
10561 else
10562 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010563 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010564 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d"), roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -070010565 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
10566 }
10567}
10568
Jeff Johnson295189b2012-06-20 16:38:30 -070010569eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
10570{
10571 eHalStatus status = eHAL_STATUS_SUCCESS;
10572 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
10573 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
10574 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
10575 tCsrRoamInfo *pRoamInfo = NULL;
10576 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010577 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -070010578 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010579 /* To silence the KW tool Null chaeck is added */
10580 if(!pSession)
10581 {
10582 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10583 return eHAL_STATUS_FAILURE;
10584 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010585 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010586 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -070010587 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
10588 if ( eWNI_SME_DISASSOC_IND == type )
10589 {
10590 result = eCSR_ROAM_RESULT_DISASSOC_IND;
10591 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
10592 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010593 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010594 }
10595 else if ( eWNI_SME_DEAUTH_IND == type )
10596 {
10597 result = eCSR_ROAM_RESULT_DEAUTH_IND;
10598 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
10599 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Madan Mohan Koyyalamudi6a808932012-11-06 16:05:54 -080010600 /* Convert into proper reason code */
10601 pSession->joinFailStatusCode.reasonCode =
10602 (pDeauthIndMsg->reasonCode == eSIR_BEACON_MISSED) ?
Agarwal Ashish838f1f32013-03-11 20:54:52 +053010603 0 : pDeauthIndMsg->reasonCode;
10604 /* cfg layer expects 0 as reason code if
10605 the driver dosent know the reason code
10606 eSIR_BEACON_MISSED is defined as locally */
Jeff Johnson295189b2012-06-20 16:38:30 -070010607 }
10608 else
10609 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010610 smsLog(pMac, LOGW, FL("gets an unknown type (%d)"), type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010611 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010612 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070010613 }
10614
10615 // call profile lost link routine here
Jeff Johnson295189b2012-06-20 16:38:30 -070010616 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -070010617 {
10618 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_LOSTLINK_DETECTED, result);
10619 }
10620
10621 if ( eWNI_SME_DISASSOC_IND == type )
10622 {
10623 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
10624 }
10625 else if ( eWNI_SME_DEAUTH_IND == type )
10626 {
10627 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
10628 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010629 if(!HAL_STATUS_SUCCESS(status))
10630 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010631 //If fail to send confirmation to PE, not to trigger roaming
10632 fToRoam = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010633 }
10634
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010635 //prepare to tell HDD to disconnect
Kiet Lam64c1b492013-07-12 13:56:44 +053010636 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010637 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10638 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010639 if( eWNI_SME_DISASSOC_IND == type)
10640 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010641 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010642 vos_mem_copy(roamInfo.peerMac, pDisassocIndMsg->peerMacAddr,
10643 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010644 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
10645 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010646 else if( eWNI_SME_DEAUTH_IND == type )
10647 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010648 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010649 vos_mem_copy(roamInfo.peerMac, pDeauthIndMsg->peerMacAddr,
10650 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010651 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
10652 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010653 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)"), roamInfo.staId);
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010654
10655 /* See if we can possibly roam. If so, start the roaming process and notify HDD
10656 that we are roaming. But if we cannot possibly roam, or if we are unable to
10657 currently roam, then notify HDD of the lost link */
Jeff Johnson295189b2012-06-20 16:38:30 -070010658 if(fToRoam)
10659 {
10660 //Only remove the connected BSS in infrastructure mode
10661 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10662 //Not to do anying for lostlink with WDS
10663 if( pMac->roam.configParam.nRoamingTime )
10664 {
10665 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
10666 ( eWNI_SME_DEAUTH_IND == type ) ?
10667 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
10668 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010669 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010670 //For IBSS, we need to give some more info to HDD
10671 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
10672 {
10673 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
10674 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10675 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
10676 }
10677 else
10678 {
10679 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
10680 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010681 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010682 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
10683 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
10684 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10685 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
10686 }
10687 else
10688 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010689 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010690 fToRoam = eANI_BOOLEAN_FALSE;
10691 }
10692 }
10693 else
10694 {
10695 //We are told not to roam, indicate lostlink
10696 fToRoam = eANI_BOOLEAN_FALSE;
10697 }
10698 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010699 if(!fToRoam)
10700 {
Madan Mohan Koyyalamudiaf854cf2012-10-30 17:56:25 -070010701 //Tell HDD about the lost link
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010702 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010703 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010704 /* Don't call csrRoamCallCallback for GO/SoftAp case as this indication
10705 * was already given as part of eWNI_SME_DISASSOC_IND msg handling in
10706 * csrRoamCheckForLinkStatusChange API.
10707 */
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010708 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
10709 }
10710
10711 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -070010712 Still enable idle scan for polling in case concurrent sessions are running */
10713 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
10714 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010715 csrScanStartIdleScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010716 }
10717 }
10718
10719 return (status);
10720}
10721
Jeff Johnson295189b2012-06-20 16:38:30 -070010722eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
10723{
10724 eHalStatus status = eHAL_STATUS_SUCCESS;
10725 tListElem *pEntry = NULL;
10726 tSmeCmd *pCommand = NULL;
10727 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010728
10729 if(!pSession)
10730 {
10731 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10732 return eHAL_STATUS_FAILURE;
10733 }
10734
Jeff Johnson295189b2012-06-20 16:38:30 -070010735 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010736 //Only remove the connected BSS in infrastructure mode
10737 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10738 if(pMac->roam.configParam.nRoamingTime)
10739 {
10740 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
10741 {
10742 //before starting the lost link logic release the roam command for handoff
10743 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
10744 if(pEntry)
10745 {
10746 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
10747 }
10748 if(pCommand)
10749 {
10750 if (( eSmeCommandRoam == pCommand->command ) &&
10751 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
10752 {
10753 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10754 {
10755 csrReleaseCommandRoam( pMac, pCommand );
10756 }
10757 }
10758 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010759 smsLog( pMac, LOGW, "Lost link roaming started ...");
Jeff Johnson295189b2012-06-20 16:38:30 -070010760 }
10761 }
10762 else
10763 {
10764 //We are told not to roam, indicate lostlink
10765 status = eHAL_STATUS_FAILURE;
10766 }
10767
10768 return (status);
10769}
Jeff Johnson295189b2012-06-20 16:38:30 -070010770void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
10771{
10772 tListElem *pEntry;
10773 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070010774 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10775 if ( pEntry )
10776 {
10777 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10778 if ( eSmeCommandWmStatusChange == pCommand->command )
10779 {
10780 // Nothing to process in a Lost Link completion.... It just kicks off a
10781 // roaming sequence.
10782 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10783 {
10784 csrReleaseCommandWmStatusChange( pMac, pCommand );
10785 }
10786 else
10787 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010788 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command");
Jeff Johnson295189b2012-06-20 16:38:30 -070010789 }
10790
10791 }
10792 else
10793 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010794 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010795 }
10796 }
10797 else
10798 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010799 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010800 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010801 smeProcessPendingQueue( pMac );
10802}
10803
Jeff Johnson295189b2012-06-20 16:38:30 -070010804void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
10805{
10806 eHalStatus status = eHAL_STATUS_FAILURE;
10807 tSirSmeRsp *pSirSmeMsg;
10808 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010809
10810 if(!pSession)
10811 {
10812 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
10813 return;
10814 }
10815
Jeff Johnson295189b2012-06-20 16:38:30 -070010816 switch ( pCommand->u.wmStatusChangeCmd.Type )
10817 {
10818 case eCsrDisassociated:
10819 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
10820 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
10821 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010822 case eCsrDeauthenticated:
10823 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
10824 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
10825 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010826 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010827 smsLog(pMac, LOGW, FL("gets an unknown command %d"), pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010828 break;
10829 }
10830 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
10831 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
10832 {
10833 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
10834 {
10835 //This is not good
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010836 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010837 }
10838 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010839 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
10840 // command here since there is nothing else to do.
10841 csrRoamWmStatusChangeComplete( pMac );
10842}
10843
Jeff Johnson295189b2012-06-20 16:38:30 -070010844//This function returns band and mode information.
10845//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
10846//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -070010847static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10848 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -070010849{
Jeff Johnson295189b2012-06-20 16:38:30 -070010850 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
10851 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
10852 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070010853 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -070010854
Jeff Johnson295189b2012-06-20 16:38:30 -070010855 //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 -070010856 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
10857 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
10858 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
10859 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -070010860 {
10861 switch( pMac->roam.configParam.uCfgDot11Mode )
10862 {
10863 case eCSR_CFG_DOT11_MODE_11A:
10864 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10865 eBand = eCSR_BAND_5G;
10866 break;
10867 case eCSR_CFG_DOT11_MODE_11B:
10868 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10869 eBand = eCSR_BAND_24;
10870 break;
10871 case eCSR_CFG_DOT11_MODE_11G:
10872 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
10873 eBand = eCSR_BAND_24;
10874 break;
10875 case eCSR_CFG_DOT11_MODE_11N:
10876 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010877 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10878 break;
10879#ifdef WLAN_FEATURE_11AC
10880 case eCSR_CFG_DOT11_MODE_11AC:
10881 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10882 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010883 /* If the operating channel is in 2.4 GHz band, check for
10884 * INI item to disable VHT operation in 2.4 GHz band
10885 */
10886 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10887 !pMac->roam.configParam.enableVhtFor24GHz)
10888 {
10889 /* Disable 11AC operation */
10890 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10891 }
10892 else
10893 {
10894 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10895 }
10896 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010897 }
10898 else
10899 {
10900 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10901 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10902 }
10903 break;
10904 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
10905 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10906 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010907 /* If the operating channel is in 2.4 GHz band, check for
10908 * INI item to disable VHT operation in 2.4 GHz band
10909 */
10910 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10911 !pMac->roam.configParam.enableVhtFor24GHz)
10912 {
10913 /* Disable 11AC operation */
10914 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10915 }
10916 else
10917 {
10918 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
10919 }
10920 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010921 }
10922 else
10923 {
10924 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10925 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10926 }
10927 break;
10928#endif
10929 case eCSR_CFG_DOT11_MODE_AUTO:
10930 eBand = pMac->roam.configParam.eBand;
10931 if (eCSR_BAND_24 == eBand)
10932 {
10933 // WiFi tests require IBSS networks to start in 11b mode
10934 // without any change to the default parameter settings
10935 // on the adapter. We use ACU to start an IBSS through
10936 // creation of a startIBSS profile. This startIBSS profile
10937 // has Auto MACProtocol and the adapter property setting
10938 // for dot11Mode is also AUTO. So in this case, let's
10939 // start the IBSS network in 11b mode instead of 11g mode.
10940 // So this is for Auto=profile->MacProtocol && Auto=Global.
10941 // dot11Mode && profile->channel is < 14, then start the IBSS
10942 // in b mode.
10943 //
10944 // Note: we used to have this start as an 11g IBSS for best
10945 // performance... now to specify that the user will have to
10946 // set the do11Mode in the property page to 11g to force it.
10947 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10948 }
10949 else
10950 {
10951#ifdef WLAN_FEATURE_11AC
10952 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
10953 {
Ravi Joshiacc81822013-10-10 15:30:41 -070010954 /* If the operating channel is in 2.4 GHz band, check for
10955 * INI item to disable VHT operation in 2.4 GHz band
10956 */
10957 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
10958 !pMac->roam.configParam.enableVhtFor24GHz)
10959 {
10960 /* Disable 11AC operation */
10961 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10962 }
10963 else
10964 {
10965 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
10966 }
10967 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070010968 }
10969 else
10970 {
10971 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10972 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10973 }
10974#else
10975 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
10976 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
10977#endif
10978 }
10979 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010980 default:
10981 // Global dot11 Mode setting is 11a/b/g.
10982 // use the channel number to determine the Mode setting.
10983 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
10984 {
10985 eBand = pMac->roam.configParam.eBand;
10986 if(eCSR_BAND_24 == eBand)
10987 {
10988 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
10989 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
10990 }
10991 else
10992 {
10993 //prefer 5GHz
10994 eBand = eCSR_BAND_5G;
10995 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
10996 }
10997 }
10998 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
10999 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070011000 // WiFi tests require IBSS networks to start in 11b mode
11001 // without any change to the default parameter settings
11002 // on the adapter. We use ACU to start an IBSS through
11003 // creation of a startIBSS profile. This startIBSS profile
11004 // has Auto MACProtocol and the adapter property setting
11005 // for dot11Mode is also AUTO. So in this case, let's
11006 // start the IBSS network in 11b mode instead of 11g mode.
11007 // So this is for Auto=profile->MacProtocol && Auto=Global.
11008 // dot11Mode && profile->channel is < 14, then start the IBSS
11009 // in b mode.
Jeff Johnson295189b2012-06-20 16:38:30 -070011010 //
Ravi Joshia96ceb42013-05-20 18:52:39 -070011011 // Note: we used to have this start as an 11g IBSS for best
11012 // performance... now to specify that the user will have to
11013 // set the do11Mode in the property page to 11g to force it.
Jeff Johnson295189b2012-06-20 16:38:30 -070011014 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11015 eBand = eCSR_BAND_24;
11016 }
11017 else
11018 {
11019 // else, it's a 5.0GHz channel. Set mode to 11a.
11020 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11021 eBand = eCSR_BAND_5G;
11022 }
11023 break;
11024 }//switch
11025 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
11026 else
11027 {
11028 //dot11 mode is set, lets pick the band
11029 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
11030 {
11031 // channel is Auto also.
11032 eBand = pMac->roam.configParam.eBand;
11033 if(eCSR_BAND_ALL == eBand)
11034 {
11035 //prefer 5GHz
11036 eBand = eCSR_BAND_5G;
11037 }
11038 }
11039 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11040 {
11041 eBand = eCSR_BAND_24;
11042 }
11043 else
11044 {
11045 eBand = eCSR_BAND_5G;
11046 }
Ravi Joshia96ceb42013-05-20 18:52:39 -070011047 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011048 if(pBand)
11049 {
11050 *pBand = eBand;
11051 }
11052
11053 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011054 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -070011055 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11056 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011057
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080011058 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
11059 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 -070011060 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011061#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011062 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011063#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011064 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
11065 {
11066 //We cannot do 11n here
11067 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11068 {
11069 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
11070 }
11071 else
11072 {
11073 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11074 }
11075 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011076 return( cfgDot11Mode );
11077}
11078
Jeff Johnson295189b2012-06-20 16:38:30 -070011079eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
11080{
11081 eHalStatus status;
11082 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011083
11084 if(!pSession)
11085 {
11086 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11087 return eHAL_STATUS_FAILURE;
11088 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011089
11090#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11091 {
11092 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011093 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11094 if(pIbssLog)
11095 {
11096 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
11097 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11098 }
11099 }
11100#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011101 // Set the roaming substate to 'stop Bss request'...
11102 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
11103
11104 // attempt to stop the Bss (reason code is ignored...)
11105 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080011106 if(!HAL_STATUS_SUCCESS(status))
11107 {
11108 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
11109 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011110 return (status);
11111}
11112
Jeff Johnson295189b2012-06-20 16:38:30 -070011113//pNumChan is a caller allocated space with the sizeof pChannels
11114eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
11115{
11116
11117 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
11118 (tANI_U8 *)pChannels,
11119 pNumChan));
11120}
11121
Kiran4a17ebe2013-01-31 10:43:43 -080011122tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
11123{
11124 tANI_U32 cfgLength = 0;
11125 tANI_U16 cfgId = 0;
11126 tPowerdBm maxTxPwr = 0;
11127 tANI_U8 *pCountryInfo = NULL;
11128 eHalStatus status;
11129 tANI_U8 count = 0;
11130 tANI_U8 firstChannel;
11131 tANI_U8 maxChannels;
11132
11133 if (CSR_IS_CHANNEL_5GHZ(channel))
11134 {
11135 cfgId = WNI_CFG_MAX_TX_POWER_5;
11136 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
11137 }
11138 else if (CSR_IS_CHANNEL_24GHZ(channel))
11139 {
11140 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
11141 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
11142 }
11143 else
11144 return maxTxPwr;
11145
Kiet Lam64c1b492013-07-12 13:56:44 +053011146 pCountryInfo = vos_mem_malloc(cfgLength);
11147 if ( NULL == pCountryInfo )
11148 status = eHAL_STATUS_FAILURE;
11149 else
11150 status = eHAL_STATUS_SUCCESS;
Kiran4a17ebe2013-01-31 10:43:43 -080011151 if (status != eHAL_STATUS_SUCCESS)
11152 {
11153 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiet Lam64c1b492013-07-12 13:56:44 +053011154 FL("%s: failed to allocate memory, status = %d"),
Kiran4a17ebe2013-01-31 10:43:43 -080011155 __FUNCTION__, status);
11156 goto error;
11157 }
11158 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
11159 if (status != eHAL_STATUS_SUCCESS)
11160 {
11161 goto error;
11162 }
11163 /* Identify the channel and maxtxpower */
11164 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
11165 {
11166 firstChannel = pCountryInfo[count++];
11167 maxChannels = pCountryInfo[count++];
11168 maxTxPwr = pCountryInfo[count++];
11169
11170 if ((channel >= firstChannel) &&
11171 (channel < (firstChannel + maxChannels)))
11172 {
11173 break;
11174 }
11175 }
11176
11177error:
11178 if (NULL != pCountryInfo)
Kiet Lam64c1b492013-07-12 13:56:44 +053011179 vos_mem_free(pCountryInfo);
Kiran4a17ebe2013-01-31 10:43:43 -080011180
11181 return maxTxPwr;
11182}
11183
11184
Jeff Johnson295189b2012-06-20 16:38:30 -070011185tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
11186{
11187 tANI_BOOLEAN fValid = FALSE;
11188 tANI_U32 idxValidChannels;
11189 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11190
11191 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
11192 {
11193 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
11194 {
11195 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
11196 {
11197 fValid = TRUE;
11198 break;
11199 }
11200 }
11201 }
11202 pMac->roam.numValidChannels = len;
11203 return fValid;
11204}
11205
Jeff Johnson295189b2012-06-20 16:38:30 -070011206tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
11207{
11208 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
11209 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011210 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
11211 {
11212 if(channel == pMac->scan.base40MHzChannels.channelList[i])
11213 {
11214 fValid = eANI_BOOLEAN_TRUE;
11215 break;
11216 }
11217 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011218 return (fValid);
11219}
11220
Jeff Johnson295189b2012-06-20 16:38:30 -070011221//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070011222 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011223{
Jeff Johnsone7245742012-09-05 17:12:55 -070011224 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011225 tANI_U8 centerChn;
11226 tANI_U32 ChannelBondingMode;
Sandeep Puligilla60342762014-01-30 21:05:37 +053011227
Jeff Johnson295189b2012-06-20 16:38:30 -070011228 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
11229 {
11230 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
11231 }
11232 else
11233 {
11234 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
11235 }
11236 //Figure what the other side's CB mode
11237 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
11238 {
11239 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
11240 {
Agrawal Ashishf187d512014-04-03 17:01:52 +053011241 // In Case WPA2 and TKIP is the only one cipher suite in Pairwise.
11242 if ((pIes->RSN.present && (pIes->RSN.pwise_cipher_suite_count == 1) &&
11243 !memcmp(&(pIes->RSN.pwise_cipher_suites[0][0]),
11244 "\x00\x0f\xac\x02",4))
11245 //In Case WPA1 and TKIP is the only one cipher suite in Unicast.
11246 ||(pIes->WPA.present && (pIes->WPA.unicast_cipher_count == 1) &&
11247 !memcmp(&(pIes->WPA.unicast_ciphers[0][0]),
11248 "\x00\x50\xf2\x02",4)))
11249
Leela Venkata Kiran Kumar Reddy Chirala10c5a2e2013-12-18 14:41:28 -080011250 {
11251 smsLog(pMac, LOGW, " No channel bonding in TKIP mode ");
11252 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11253 }
11254
11255 else if(pIes->HTInfo.present)
Jeff Johnson295189b2012-06-20 16:38:30 -070011256 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011257 /* This is called during INFRA STA/CLIENT and should use the merged value of
11258 * supported channel width and recommended tx width as per standard
11259 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011260 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070011261 pIes->HTCaps.supportedChannelWidthSet,
11262 pIes->HTInfo.recommendedTxWidthSet,
11263 pIes->HTInfo.secondaryChannelOffset);
11264
11265 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
11266 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070011267 else
Jeff Johnsone7245742012-09-05 17:12:55 -070011268 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11269 switch (eRet) {
11270 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
11271 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
11272 break;
11273 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
11274 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
11275 break;
11276 case PHY_SINGLE_CHANNEL_CENTERED:
11277 default:
11278 centerChn = primaryChn;
11279 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011280 }
Jeff Johnsone7245742012-09-05 17:12:55 -070011281 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070011282 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011283 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Abhishek Singh25144bb2014-05-01 16:03:21 +053011284 eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011285 }
11286 }
11287 }
11288 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011289 return eRet;
11290}
Jeff Johnson295189b2012-06-20 16:38:30 -070011291tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
11292{
11293 tANI_BOOLEAN fFound = FALSE;
11294 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011295 for( idx = 0; idx < pCipherList->numEntries; idx++ )
11296 {
11297 if( pCipherList->encryptionType[idx] == encryptionType )
11298 {
11299 fFound = TRUE;
11300 break;
11301 }
11302 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011303 return fFound;
11304}
Jeff Johnson295189b2012-06-20 16:38:30 -070011305tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
11306{
11307 tANI_BOOLEAN fFound = FALSE;
11308 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011309 for( idx = 0; idx < pAuthList->numEntries; idx++ )
11310 {
11311 if( pAuthList->authType[idx] == authType )
11312 {
11313 fFound = TRUE;
11314 break;
11315 }
11316 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011317 return fFound;
11318}
Jeff Johnson295189b2012-06-20 16:38:30 -070011319tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
11320{
11321 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11322 tCsrScanResultFilter *pScanFilter = NULL;
11323 eHalStatus status = eHAL_STATUS_SUCCESS;
11324
11325 if(pProfile1 && pProfile2)
11326 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011327 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
11328 if ( NULL == pScanFilter )
11329 status = eHAL_STATUS_FAILURE;
11330 else
11331 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011332 if(HAL_STATUS_SUCCESS(status))
11333 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011334 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011335 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
11336 if(HAL_STATUS_SUCCESS(status))
11337 {
11338 fCheck = eANI_BOOLEAN_FALSE;
11339 do
11340 {
11341 tANI_U32 i;
11342 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
11343 {
11344 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
11345 pScanFilter->SSIDs.SSIDList[i].SSID.length,
11346 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
11347 if ( fCheck ) break;
11348 }
11349 if(!fCheck)
11350 {
11351 break;
11352 }
11353 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
11354 || pProfile2->BSSType != pProfile1->BSSType
11355 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
11356 )
11357 {
11358 fCheck = eANI_BOOLEAN_FALSE;
11359 break;
11360 }
11361#ifdef WLAN_FEATURE_VOWIFI_11R
11362 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
11363 {
11364 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
11365 {
11366 fCheck = eANI_BOOLEAN_FALSE;
11367 break;
11368 }
11369 }
11370#endif
11371 //Match found
11372 fCheck = eANI_BOOLEAN_TRUE;
11373 }while(0);
11374 csrFreeScanFilter(pMac, pScanFilter);
11375 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011376 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011377 }
11378 }
11379
11380 return (fCheck);
11381}
11382
Jeff Johnson295189b2012-06-20 16:38:30 -070011383tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
11384{
11385 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11386 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011387 do
11388 {
11389 //Only check for static WEP
11390 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
11391 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
11392 {
11393 fCheck = eANI_BOOLEAN_TRUE;
11394 break;
11395 }
11396 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
11397 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
11398 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
11399 {
11400 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053011401 if (!vos_mem_compare(&pConnProfile->Keys.KeyMaterial[i],
11402 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
Jeff Johnson295189b2012-06-20 16:38:30 -070011403 {
11404 break;
11405 }
11406 }
11407 if( i == CSR_MAX_NUM_KEY)
11408 {
11409 fCheck = eANI_BOOLEAN_TRUE;
11410 }
11411 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011412 return (fCheck);
11413}
11414
Jeff Johnson295189b2012-06-20 16:38:30 -070011415//IBSS
11416
Jeff Johnson295189b2012-06-20 16:38:30 -070011417tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
11418{
11419 tANI_U8 channel = 0;
11420 tANI_U32 idx;
11421 tANI_U32 idxValidChannels;
11422 tANI_BOOLEAN fFound = FALSE;
11423 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11424
11425 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
11426 {
11427 channel = pMac->roam.configParam.AdHocChannel5G;
11428 if(!csrRoamIsChannelValid(pMac, channel))
11429 {
11430 channel = 0;
11431 }
11432 }
11433 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11434 {
11435 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
11436 {
11437 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11438 {
11439 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11440 {
11441 fFound = TRUE;
11442 channel = csrStartIbssChannels50[ idx ];
11443 }
11444 }
11445 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011446 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
11447 if (!fFound)
11448 {
11449 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
11450 {
11451 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idx ]) ) // the max channel# in 11g is 14
11452 {
11453 channel = csrStartIbssChannels50[ idx ];
11454 break;
11455 }
11456 }
11457 }
11458 }//if
11459
11460 return( channel );
11461}
11462
Jeff Johnson295189b2012-06-20 16:38:30 -070011463tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
11464{
11465 tANI_U8 channel = 1;
11466 tANI_U32 idx;
11467 tANI_U32 idxValidChannels;
11468 tANI_BOOLEAN fFound = FALSE;
11469 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11470
11471 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
11472 {
11473 channel = pMac->roam.configParam.AdHocChannel24;
11474 if(!csrRoamIsChannelValid(pMac, channel))
11475 {
11476 channel = 0;
11477 }
11478 }
11479
11480 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11481 {
11482 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
11483 {
11484 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11485 {
11486 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11487 {
11488 fFound = TRUE;
11489 channel = csrStartIbssChannels24[ idx ];
11490 }
11491 }
11492 }
11493 }
11494
11495 return( channel );
11496}
11497
Jeff Johnson295189b2012-06-20 16:38:30 -070011498static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
11499 tCsrRoamStartBssParams *pParam )
11500{
11501 eCsrCfgDot11Mode cfgDot11Mode;
11502 eCsrBand eBand;
11503 tANI_U8 channel = 0;
11504 tSirNwType nwType;
11505 tANI_U8 operationChannel = 0;
11506
11507 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
11508 {
11509 operationChannel = pProfile->ChannelInfo.ChannelList[0];
11510 }
11511
Jeff Johnson295189b2012-06-20 16:38:30 -070011512 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070011513
Jeff Johnson295189b2012-06-20 16:38:30 -070011514 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11515 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
11516 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
11517 )
11518 {
11519 /* This should never happen */
11520 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011521 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070011522 pProfile->csrPersona);
11523 VOS_ASSERT(0);
11524 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011525 switch( cfgDot11Mode )
11526 {
11527 case eCSR_CFG_DOT11_MODE_11G:
11528 nwType = eSIR_11G_NW_TYPE;
11529 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011530 case eCSR_CFG_DOT11_MODE_11B:
11531 nwType = eSIR_11B_NW_TYPE;
11532 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011533 case eCSR_CFG_DOT11_MODE_11A:
11534 nwType = eSIR_11A_NW_TYPE;
11535 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011536 default:
11537 case eCSR_CFG_DOT11_MODE_11N:
11538 case eCSR_CFG_DOT11_MODE_TAURUS:
11539 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
11540 if(eCSR_BAND_24 == eBand)
11541 {
11542 nwType = eSIR_11G_NW_TYPE;
11543 }
11544 else
11545 {
11546 nwType = eSIR_11A_NW_TYPE;
11547 }
11548 break;
11549 }
11550
11551 pParam->extendedRateSet.numRates = 0;
11552
11553 switch ( nwType )
11554 {
11555 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011556 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011557 case eSIR_11A_NW_TYPE:
11558
11559 pParam->operationalRateSet.numRates = 8;
11560
11561 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11562 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11563 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11564 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11565 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11566 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11567 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11568 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11569
11570 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11571 {
11572 channel = csrRoamGetIbssStartChannelNumber50( pMac );
11573 if( 0 == channel &&
11574 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
11575 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
11576 )
11577 {
11578 //We could not find a 5G channel by auto pick, let's try 2.4G channels
11579 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
11580 nwType = eSIR_11B_NW_TYPE;
11581 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11582 pParam->operationalRateSet.numRates = 4;
11583 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11584 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11585 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11586 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11587 }
11588 }
11589 else
11590 {
11591 channel = operationChannel;
11592 }
11593 break;
11594
11595 case eSIR_11B_NW_TYPE:
11596 pParam->operationalRateSet.numRates = 4;
11597 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11598 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11599 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11600 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070011601 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11602 {
11603 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11604 }
11605 else
11606 {
11607 channel = operationChannel;
11608 }
11609
11610 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011611 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070011612 /* For P2P Client and P2P GO, disable 11b rates */
11613 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11614 (pProfile->csrPersona == VOS_P2P_GO_MODE)
11615 )
11616 {
11617 pParam->operationalRateSet.numRates = 8;
11618
11619 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11620 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11621 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11622 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11623 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11624 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11625 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11626 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11627 }
11628 else
Jeff Johnson295189b2012-06-20 16:38:30 -070011629 {
11630 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070011631 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11632 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11633 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11634 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11635
11636 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070011637 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
11638 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
11639 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
11640 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
11641 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
11642 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
11643 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
11644 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
11645 }
11646
11647 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11648 {
11649 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11650 }
11651 else
11652 {
11653 channel = operationChannel;
11654 }
11655
11656 break;
11657 }
11658 pParam->operationChn = channel;
11659 pParam->sirNwType = nwType;
11660}
11661
Jeff Johnson295189b2012-06-20 16:38:30 -070011662static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
11663 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
11664{
11665
11666 if( pParam )
11667 {
11668 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070011669 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011670 pParam->operationChn = pBssDesc->channelId;
Kiet Lam64c1b492013-07-12 13:56:44 +053011671 vos_mem_copy(&pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011672
11673 if( pIes )
11674 {
11675 if(pIes->SuppRates.present)
11676 {
11677 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
11678 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
11679 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011680 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 -070011681 pIes->SuppRates.num_rates);
11682 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
11683 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011684 vos_mem_copy(pParam->operationalRateSet.rate, pIes->SuppRates.rates,
11685 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
Jeff Johnson295189b2012-06-20 16:38:30 -070011686 }
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011687 if (pIes->ExtSuppRates.present)
11688 {
11689 pParam->extendedRateSet.numRates = pIes->ExtSuppRates.num_rates;
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053011690 if(pIes->ExtSuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011691 {
11692 smsLog(pMac, LOGE, FL("num_rates :%d is more than \
11693 SIR_MAC_RATESET_EID_MAX, resetting to \
11694 SIR_MAC_RATESET_EID_MAX"),
11695 pIes->ExtSuppRates.num_rates);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053011696 pIes->ExtSuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011697 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053011698 vos_mem_copy(pParam->extendedRateSet.rate,
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011699 pIes->ExtSuppRates.rates,
11700 sizeof(*pIes->ExtSuppRates.rates) * pIes->ExtSuppRates.num_rates);
11701 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011702 if( pIes->SSID.present )
11703 {
11704 pParam->ssId.length = pIes->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +053011705 vos_mem_copy(pParam->ssId.ssId, pIes->SSID.ssid,
11706 pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011707 }
11708 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070011709 }
11710 else
11711 {
11712 pParam->ssId.length = 0;
11713 pParam->operationalRateSet.numRates = 0;
11714 }
11715 }
11716}
11717
Jeff Johnson295189b2012-06-20 16:38:30 -070011718static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
11719{
11720 tANI_U8 MaxRate = 0;
11721 tANI_U32 i;
11722 tANI_U8 *pRate;
11723
11724 pRate = pSirRateSet->rate;
11725 for ( i = 0; i < pSirRateSet->numRates; i++ )
11726 {
11727 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
11728 }
11729
11730 // Save the max rate in the connected state information...
11731
11732 // modify LastRates variable as well
11733
11734 return;
11735}
11736
Jeff Johnson295189b2012-06-20 16:38:30 -070011737eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
11738 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
11739{
11740 eHalStatus status = eHAL_STATUS_SUCCESS;
11741 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070011742 // Set the roaming substate to 'Start BSS attempt'...
11743 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011744#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11745 //Need to figure out whether we need to log WDS???
11746 if( CSR_IS_IBSS( pProfile ) )
11747 {
11748 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011749 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11750 if(pIbssLog)
11751 {
11752 if(pBssDesc)
11753 {
11754 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
Kiet Lam64c1b492013-07-12 13:56:44 +053011755 vos_mem_copy(pIbssLog->bssid, pBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070011756 }
11757 else
11758 {
11759 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
11760 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011761 vos_mem_copy(pIbssLog->ssid, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011762 if(pProfile->ChannelInfo.numOfChannels == 0)
11763 {
11764 pIbssLog->channelSetting = AUTO_PICK;
11765 }
11766 else
11767 {
11768 pIbssLog->channelSetting = SPECIFIED;
11769 }
11770 pIbssLog->operatingChannel = pParam->operationChn;
11771 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11772 }
11773 }
11774#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
11775 //Put RSN information in for Starting BSS
11776 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
11777 pParam->pRSNIE = pProfile->pRSNReqIE;
11778
Jeff Johnson295189b2012-06-20 16:38:30 -070011779 pParam->privacy = pProfile->privacy;
11780 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
11781 pParam->authType = pProfile->csr80211AuthType;
11782 pParam->beaconInterval = pProfile->beaconInterval;
11783 pParam->dtimPeriod = pProfile->dtimPeriod;
11784 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
11785 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
11786 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
11787 {
11788 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
11789 {
11790 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
11791 }
11792 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011793 pParam->protEnabled = pProfile->protEnabled;
11794 pParam->obssProtEnabled = pProfile->obssProtEnabled;
11795 pParam->ht_protection = pProfile->cfg_protection;
11796 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080011797
Jeff Johnson295189b2012-06-20 16:38:30 -070011798 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
11799 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070011800 pParam->bssPersona = pProfile->csrPersona;
Chet Lanctot8cecea22014-02-11 19:09:36 -080011801
11802#ifdef WLAN_FEATURE_11W
11803 pParam->mfpCapable = (0 != pProfile->MFPCapable);
11804 pParam->mfpRequired = (0 != pProfile->MFPRequired);
11805#endif
11806
Jeff Johnson295189b2012-06-20 16:38:30 -070011807 // When starting an IBSS, start on the channel from the Profile.
11808 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070011809 return (status);
11810}
11811
Jeff Johnson295189b2012-06-20 16:38:30 -070011812static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070011813 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011814{
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011815 tANI_U8 Channel;
Jeff Johnsone7245742012-09-05 17:12:55 -070011816 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011817 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011818
11819 if(!pSession)
11820 {
11821 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11822 return;
11823 }
11824
Jeff Johnson295189b2012-06-20 16:38:30 -070011825 if( pBssDesc )
11826 {
11827 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
11828 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
11829 //The following code has to be do after that.
11830 //For WDS station, use selfMac as the self BSSID
11831 if( CSR_IS_WDS_STA( pProfile ) )
11832 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011833 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
11834 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011835 }
11836 }
11837 else
11838 {
11839 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070011840 //Use the first SSID
11841 if(pProfile->SSIDs.numOfSSIDs)
11842 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011843 vos_mem_copy(&pSession->bssParams.ssId, pProfile->SSIDs.SSIDList,
11844 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011845 }
11846 //For WDS station, use selfMac as the self BSSID
11847 if( CSR_IS_WDS_STA( pProfile ) )
11848 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011849 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
11850 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011851 }
11852 //Use the first BSSID
11853 else if( pProfile->BSSIDs.numOfBSSIDs )
11854 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011855 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid,
11856 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011857 }
11858 else
11859 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011860 vos_mem_set(&pSession->bssParams.bssid, sizeof(tCsrBssid), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011861 }
11862 }
11863 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070011864 //Set operating channel in pProfile which will be used
11865 //in csrRoamSetBssConfigCfg() to determine channel bonding
11866 //mode and will be configured in CFG later
11867 pProfile->operationChannel = Channel;
11868
11869 if(Channel == 0)
11870 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053011871 smsLog(pMac, LOGE, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070011872 }
11873 else
11874 {
11875
11876 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011877 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS( pProfile ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011878 {
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011879 if(CSR_IS_CHANNEL_24GHZ(Channel) )
Jeff Johnsone7245742012-09-05 17:12:55 -070011880 {
Sandeep Puligillae3f239f2014-04-17 02:11:46 +053011881 /* TODO- SAP: HT40 Support in SAP 2.4Ghz mode is not enabled.
11882 so channel bonding in 2.4Ghz is configured as 20MHZ
11883 irrespective of the 'channelBondingMode24GHz' Parameter */
11884 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -070011885 }
11886 else
11887 {
11888 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
11889 }
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011890 smsLog(pMac, LOG1, "## cbMode %d", cbMode);
Jeff Johnsone7245742012-09-05 17:12:55 -070011891 pBssConfig->cbMode = cbMode;
11892 pSession->bssParams.cbMode = cbMode;
11893 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011894 }
11895}
11896
Jeff Johnson295189b2012-06-20 16:38:30 -070011897static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
11898 tANI_BOOLEAN *pfSameIbss )
11899{
11900 eHalStatus status = eHAL_STATUS_SUCCESS;
11901 tANI_BOOLEAN fSameIbss = FALSE;
11902
11903 if ( csrIsConnStateIbss( pMac, sessionId ) )
11904 {
11905 // Check if any profile parameter has changed ? If any profile parameter
11906 // has changed then stop old BSS and start a new one with new parameters
11907 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
11908 {
11909 fSameIbss = TRUE;
11910 }
11911 else
11912 {
11913 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
11914 }
11915 }
11916 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
11917 {
11918 // Disassociate from the connected Infrastructure network...
11919 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
11920 }
11921 else
11922 {
11923 tBssConfigParam *pBssConfig;
11924
Kiet Lam64c1b492013-07-12 13:56:44 +053011925 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
11926 if ( NULL == pBssConfig )
11927 status = eHAL_STATUS_FAILURE;
11928 else
11929 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011930 if(HAL_STATUS_SUCCESS(status))
11931 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011932 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011933 // there is no Bss description before we start an IBSS so we need to adopt
11934 // all Bss configuration parameters from the Profile.
11935 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
11936 if(HAL_STATUS_SUCCESS(status))
11937 {
11938 //save dotMode
11939 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
11940 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070011941 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053011942 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
11943 NULL, pBssConfig,
11944 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070011945 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011946
11947 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -070011948 }//Allocate memory
11949 }
11950
11951 if(pfSameIbss)
11952 {
11953 *pfSameIbss = fSameIbss;
11954 }
11955 return( status );
11956}
11957
Jeff Johnson295189b2012-06-20 16:38:30 -070011958static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
11959 tSirSmeNewBssInfo *pNewBss )
11960{
11961 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011962
11963 if(!pSession)
11964 {
11965 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11966 return;
11967 }
11968
Jeff Johnson295189b2012-06-20 16:38:30 -070011969 if( pNewBss )
11970 {
11971 // Set the operating channel.
11972 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
11973 // move the BSSId from the BSS description into the connected state information.
Kiet Lam64c1b492013-07-12 13:56:44 +053011974 vos_mem_copy(&pSession->connectedProfile.bssid, &(pNewBss->bssId),
11975 sizeof( tCsrBssid ));
Jeff Johnson295189b2012-06-20 16:38:30 -070011976 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011977 return;
11978}
11979
Jeff Johnson295189b2012-06-20 16:38:30 -070011980#ifdef FEATURE_WLAN_WAPI
11981eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
11982 tANI_U32 numItems )
11983{
11984 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
11985 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070011986 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
11987 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011988 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011989 return status;
11990 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011991 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070011992 pSession = CSR_GET_SESSION( pMac, sessionId );
11993 if(numItems <= CSR_MAX_BKID_ALLOWED)
11994 {
11995 status = eHAL_STATUS_SUCCESS;
11996 //numItems may be 0 to clear the cache
11997 pSession->NumBkidCache = (tANI_U16)numItems;
11998 if(numItems && pBKIDCache)
11999 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012000 vos_mem_copy(pSession->BkidCacheInfo, pBKIDCache,
12001 sizeof(tBkidCacheInfo) * numItems);
12002 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012003 }
12004 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012005 return (status);
12006}
Jeff Johnson295189b2012-06-20 16:38:30 -070012007eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
12008 tBkidCacheInfo *pBkidCache)
12009{
12010 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12011 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070012012 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
12013 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012014 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012015 return status;
12016 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012017 pSession = CSR_GET_SESSION( pMac, sessionId );
12018 if(pNum && pBkidCache)
12019 {
12020 if(pSession->NumBkidCache == 0)
12021 {
12022 *pNum = 0;
12023 status = eHAL_STATUS_SUCCESS;
12024 }
12025 else if(*pNum >= pSession->NumBkidCache)
12026 {
12027 if(pSession->NumBkidCache > CSR_MAX_PMKID_ALLOWED)
12028 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012029 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 -070012030 pSession->NumBkidCache);
12031 pSession->NumBkidCache = CSR_MAX_PMKID_ALLOWED;
12032 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012033 vos_mem_copy(pBkidCache, pSession->BkidCacheInfo,
12034 sizeof(tBkidCacheInfo) * pSession->NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012035 *pNum = pSession->NumBkidCache;
12036 status = eHAL_STATUS_SUCCESS;
12037 }
12038 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012039 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070012040}
Jeff Johnson295189b2012-06-20 16:38:30 -070012041tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
12042{
12043 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012044}
12045#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012046eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
12047 tPmkidCacheInfo *pPMKIDCache, tANI_U32 numItems )
12048{
12049 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12050 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012051
12052 if(!pSession)
12053 {
12054 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12055 return eHAL_STATUS_FAILURE;
12056 }
12057
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012058 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070012059 if(numItems <= CSR_MAX_PMKID_ALLOWED)
12060 {
12061#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12062 {
12063 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053012064 vos_mem_set(&secEvent,
12065 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012066 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
12067 secEvent.encryptionModeMulticast =
12068 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
12069 secEvent.encryptionModeUnicast =
12070 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053012071 vos_mem_copy(secEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070012072 secEvent.authMode =
12073 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
12074 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
12075 }
12076#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070012077 status = eHAL_STATUS_SUCCESS;
12078 //numItems may be 0 to clear the cache
12079 pSession->NumPmkidCache = (tANI_U16)numItems;
12080 if(numItems && pPMKIDCache)
12081 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012082 vos_mem_copy(pSession->PmkidCacheInfo, pPMKIDCache,
12083 sizeof(tPmkidCacheInfo) * numItems);
12084 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012085 }
12086 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012087 return (status);
12088}
12089
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012090eHalStatus csrRoamDelPMKIDfromCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
12091 tANI_U8 *pBSSId )
12092{
12093 eHalStatus status = eHAL_STATUS_FAILURE;
12094 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12095 tANI_BOOLEAN fMatchFound = FALSE;
12096 tANI_U32 Index;
12097 if(!pSession)
12098 {
12099 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12100 return eHAL_STATUS_FAILURE;
12101 }
12102 do
12103 {
12104 for( Index=0; Index < pSession->NumPmkidCache; Index++ )
12105 {
Arif Hussaina7c8e412013-11-20 11:06:42 -080012106 smsLog(pMac, LOGW, "Delete PMKID for "
12107 MAC_ADDRESS_STR, MAC_ADDR_ARRAY(pBSSId));
Kiet Lamf2f201e2013-11-16 21:24:16 +053012108 if( vos_mem_compare( pBSSId, pSession->PmkidCacheInfo[Index].BSSID, sizeof(tCsrBssid) ) )
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012109 {
12110 fMatchFound = TRUE;
12111 break;
12112 }
12113 }
12114 if( !fMatchFound ) break;
Abhishek Singh1e2bfa32014-01-02 15:44:15 +053012115 vos_mem_set(pSession->PmkidCacheInfo[Index].BSSID, sizeof(tCsrBssid), 0);
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012116 status = eHAL_STATUS_SUCCESS;
12117 }
12118 while( 0 );
12119 smsLog(pMac, LOGW, "csrDelPMKID called return match = %d Status = %d",
12120 fMatchFound, status);
12121 return status;
12122}
Jeff Johnson295189b2012-06-20 16:38:30 -070012123tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
12124{
12125 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
12126}
12127
Jeff Johnson295189b2012-06-20 16:38:30 -070012128eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
12129{
12130 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12131 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012132
12133 if(!pSession)
12134 {
12135 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12136 return eHAL_STATUS_FAILURE;
12137 }
12138
Jeff Johnson295189b2012-06-20 16:38:30 -070012139 if(pNum && pPmkidCache)
12140 {
12141 if(pSession->NumPmkidCache == 0)
12142 {
12143 *pNum = 0;
12144 status = eHAL_STATUS_SUCCESS;
12145 }
12146 else if(*pNum >= pSession->NumPmkidCache)
12147 {
12148 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
12149 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012150 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 -070012151 pSession->NumPmkidCache);
12152 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
12153 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012154 vos_mem_copy(pPmkidCache, pSession->PmkidCacheInfo,
12155 sizeof(tPmkidCacheInfo) * pSession->NumPmkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012156 *pNum = pSession->NumPmkidCache;
12157 status = eHAL_STATUS_SUCCESS;
12158 }
12159 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012160 return (status);
12161}
12162
Jeff Johnson295189b2012-06-20 16:38:30 -070012163eHalStatus csrRoamGetWpaRsnReqIE(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->nWpaRsnReqIeLength;
12179 if(pBuf)
12180 {
12181 if(len >= pSession->nWpaRsnReqIeLength)
12182 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012183 vos_mem_copy(pBuf, pSession->pWpaRsnReqIE,
12184 pSession->nWpaRsnReqIeLength);
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}
12191
Jeff Johnson295189b2012-06-20 16:38:30 -070012192eHalStatus csrRoamGetWpaRsnRspIE(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->nWpaRsnRspIeLength;
12208 if(pBuf)
12209 {
12210 if(len >= pSession->nWpaRsnRspIeLength)
12211 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012212 vos_mem_copy(pBuf, pSession->pWpaRsnRspIE,
12213 pSession->nWpaRsnRspIeLength);
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 -070012220#ifdef FEATURE_WLAN_WAPI
12221eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12222{
12223 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12224 tANI_U32 len;
12225 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012226
12227 if(!pSession)
12228 {
12229 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12230 return eHAL_STATUS_FAILURE;
12231 }
12232
Jeff Johnson295189b2012-06-20 16:38:30 -070012233 if(pLen)
12234 {
12235 len = *pLen;
12236 *pLen = pSession->nWapiReqIeLength;
12237 if(pBuf)
12238 {
12239 if(len >= pSession->nWapiReqIeLength)
12240 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012241 vos_mem_copy(pBuf, pSession->pWapiReqIE,
12242 pSession->nWapiReqIeLength);
12243 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012244 }
12245 }
12246 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012247 return (status);
12248}
Jeff Johnson295189b2012-06-20 16:38:30 -070012249eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12250{
12251 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12252 tANI_U32 len;
12253 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012254
12255 if(!pSession)
12256 {
12257 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12258 return eHAL_STATUS_FAILURE;
12259 }
12260
Jeff Johnson295189b2012-06-20 16:38:30 -070012261 if(pLen)
12262 {
12263 len = *pLen;
12264 *pLen = pSession->nWapiRspIeLength;
12265 if(pBuf)
12266 {
12267 if(len >= pSession->nWapiRspIeLength)
12268 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012269 vos_mem_copy(pBuf, pSession->pWapiRspIE,
12270 pSession->nWapiRspIeLength);
12271 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012272 }
12273 }
12274 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012275 return (status);
12276}
12277#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012278eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
12279{
12280 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
12281 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012282
12283 if(!pSession)
12284 {
12285 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12286 return (retStatus);
12287 }
12288
Jeff Johnson295189b2012-06-20 16:38:30 -070012289 if(CSR_IS_ROAMING(pSession))
12290 {
12291 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
12292 pSession->fRoaming = eANI_BOOLEAN_FALSE;
12293 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012294 return (retStatus);
12295}
12296
Jeff Johnson295189b2012-06-20 16:38:30 -070012297//This function remove the connected BSS from te cached scan result
12298eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
12299 tCsrRoamConnectedProfile *pConnProfile)
12300{
12301 eHalStatus status = eHAL_STATUS_FAILURE;
12302 tCsrScanResultFilter *pScanFilter = NULL;
12303 tListElem *pEntry;
12304 tCsrScanResult *pResult;
12305 tDot11fBeaconIEs *pIes;
12306 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070012307 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
12308 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
12309 {
12310 do
12311 {
12312 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
Kiet Lam64c1b492013-07-12 13:56:44 +053012313 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
12314 if ( NULL == pScanFilter )
12315 status = eHAL_STATUS_FAILURE;
12316 else
12317 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012318 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012319 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
12320 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
12321 if ( NULL == pScanFilter->BSSIDs.bssid )
12322 status = eHAL_STATUS_FAILURE;
12323 else
12324 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012325 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012326 vos_mem_copy(pScanFilter->BSSIDs.bssid, &pConnProfile->bssid,
12327 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012328 pScanFilter->BSSIDs.numOfBSSIDs = 1;
12329 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
12330 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012331 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
12332 if ( NULL == pScanFilter->SSIDs.SSIDList )
12333 status = eHAL_STATUS_FAILURE;
12334 else
12335 status = eHAL_STATUS_SUCCESS;
12336 if (!HAL_STATUS_SUCCESS(status)) break;
12337 vos_mem_copy(&pScanFilter->SSIDs.SSIDList[0].SSID,
12338 &pConnProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012339 }
12340 pScanFilter->authType.numEntries = 1;
12341 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
12342 pScanFilter->BSSType = pConnProfile->BSSType;
12343 pScanFilter->EncryptionType.numEntries = 1;
12344 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
12345 pScanFilter->mcEncryptionType.numEntries = 1;
12346 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
12347 //We ignore the channel for now, BSSID should be enough
12348 pScanFilter->ChannelInfo.numOfChannels = 0;
12349 //Also ignore the following fields
12350 pScanFilter->uapsd_mask = 0;
12351 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070012352 pScanFilter->bOSENAssociation = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012353 pScanFilter->countryCode[0] = 0;
12354 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012355 csrLLLock(&pMac->scan.scanResultList);
12356 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
12357 while( pEntry )
12358 {
12359 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
12360 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
12361 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
12362 pScanFilter, NULL, NULL, NULL, &pIes);
12363 //Release the IEs allocated by csrMatchBSS is needed
12364 if( !pResult->Result.pvIes )
12365 {
12366 //need to free the IEs since it is allocated by csrMatchBSS
Kiet Lam64c1b492013-07-12 13:56:44 +053012367 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012368 }
12369 if(fMatch)
12370 {
12371 //We found the one
12372 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
12373 {
12374 //Free the memory
12375 csrFreeScanResultEntry( pMac, pResult );
12376 }
12377 break;
12378 }
12379 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
12380 }//while
12381 csrLLUnlock(&pMac->scan.scanResultList);
12382 }while(0);
12383 if(pScanFilter)
12384 {
12385 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +053012386 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012387 }
12388 }
12389 return (status);
12390}
12391
Jeff Johnson295189b2012-06-20 16:38:30 -070012392//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070012393eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
12394{
12395 eHalStatus status = eHAL_STATUS_SUCCESS;
12396 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012397 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
12398 {
12399 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
12400 {
12401 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
12402 {
12403 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012404 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012405 status = eHAL_STATUS_CSR_WRONG_STATE;
12406 break;
12407 }
12408 if( csrIsConnStateInfra( pMac, sessionId ) )
12409 {
12410 if( chnId &&
12411 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
12412 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012413 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070012414 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
12415 status = eHAL_STATUS_CSR_WRONG_STATE;
12416 break;
12417 }
12418 }
12419 }
12420 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012421 return ( status );
12422}
12423
Jeff Johnson295189b2012-06-20 16:38:30 -070012424static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
12425{
12426 eHalStatus status = eHAL_STATUS_SUCCESS;
12427 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12428 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012429
12430 if(!pSession)
12431 {
12432 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12433 return eHAL_STATUS_FAILURE;
12434 }
12435
Jeff Johnson295189b2012-06-20 16:38:30 -070012436 if ( csrIsConnStateIbss( pMac, sessionId ) )
12437 {
12438 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
12439 }
12440 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
12441 {
12442 // Disassociate from the connected Infrastructure network...
12443 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
12444 }
12445 else
12446 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012447 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
12448 //Otherwise we need to add code to handle the
12449 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
12450 //send stop_bss to PE, before we can continue.
12451 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012452 vos_mem_set(&bssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012453 /* Assume HDD provide bssid in profile */
Kiet Lam64c1b492013-07-12 13:56:44 +053012454 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0],
12455 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012456 // there is no Bss description before we start an WDS so we need
12457 // to adopt all Bss configuration parameters from the Profile.
12458 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
12459 if(HAL_STATUS_SUCCESS(status))
12460 {
12461 //Save profile for late use
12462 csrFreeRoamProfile( pMac, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +053012463 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
12464 if (pSession->pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -070012465 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012466 vos_mem_set(pSession->pCurRoamProfile,
12467 sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012468 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
12469 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012470 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070012471 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012472 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
12473 NULL, &bssConfig,
12474 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012475 }
12476 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012477
Jeff Johnson295189b2012-06-20 16:38:30 -070012478 return( status );
12479}
12480
Jeff Johnson295189b2012-06-20 16:38:30 -070012481////////////////////Mail box
12482
Jeff Johnson295189b2012-06-20 16:38:30 -070012483//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
12484//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012485static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
12486 tSirBssDescription *pBssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -070012487 tANI_U8 *pBuf, tANI_U8 uapsdMask)
12488{
12489 tCsrChannelSet channelGroup;
12490 tSirMacCapabilityInfo *pAP_capabilityInfo;
12491 tAniBool fTmp;
12492 tANI_BOOLEAN found = FALSE;
12493 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012494 tANI_S8 pwrLimit = 0;
12495 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070012496 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
12497 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
12498 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
12499 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070012500 // 802.11h
12501 //We can do this because it is in HOST CPU order for now.
12502 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080012503 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
12504 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
12505 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012506 fTmp = (tAniBool)pal_cpu_to_be32(1);
12507 }
12508 else
12509 fTmp = (tAniBool)0;
12510
12511 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
Kiet Lam64c1b492013-07-12 13:56:44 +053012512 vos_mem_copy(pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool));
Jeff Johnson295189b2012-06-20 16:38:30 -070012513 pBuf += sizeof(tAniBool);
12514 *pBuf++ = MIN_STA_PWR_CAP_DBM; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012515 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070012516 // This is required for 11k test VoWiFi Ent: Test 2.
12517 // We need the power capabilities for Assoc Req.
12518 // This macro is provided by the halPhyCfg.h. We pick our
12519 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080012520 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
12521 if (0 != pwrLimit)
12522 {
12523 *pBuf++ = pwrLimit;
12524 }
12525 else
12526 {
12527 *pBuf++ = MAX_STA_PWR_CAP_DBM;
12528 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012529 size = sizeof(pMac->roam.validChannelList);
12530 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
12531 {
12532 *pBuf++ = (tANI_U8)size; //tSirSupChnl->numChnl
12533 for ( i = 0; i < size; i++)
12534 {
12535 *pBuf++ = pMac->roam.validChannelList[ i ]; //tSirSupChnl->channelList[ i ]
12536
12537 }
12538 }
12539 else
12540 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012541 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012542 *pBuf++ = 0; //tSirSupChnl->numChnl
12543 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012544 //Check whether it is ok to enter UAPSD
12545#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12546 if( btcIsReadyForUapsd(pMac) )
12547#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12548 {
12549 *pBuf++ = uapsdMask;
12550 }
12551#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12552 else
12553 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012554 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070012555 *pBuf++ = 0;
12556 }
12557#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12558
Jeff Johnson295189b2012-06-20 16:38:30 -070012559 // move the entire BssDescription into the join request.
Kiet Lam64c1b492013-07-12 13:56:44 +053012560 vos_mem_copy(pBuf, pBssDescription,
12561 pBssDescription->length + sizeof( pBssDescription->length ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012562 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
12563}
12564
Jeff Johnson295189b2012-06-20 16:38:30 -070012565/*
12566 * The communication between HDD and LIM is thru mailbox (MB).
12567 * Both sides will access the data structure "tSirSmeJoinReq".
12568 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
12569 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
12570 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
12571 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
12572 */
12573eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012574 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012575{
12576 eHalStatus status = eHAL_STATUS_SUCCESS;
12577 tSirSmeJoinReq *pMsg;
12578 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012579 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070012580 tANI_U16 msgLen, wTmp, ieLen;
12581 tSirMacRateSet OpRateSet;
12582 tSirMacRateSet ExRateSet;
12583 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12584 tANI_U32 dwTmp;
12585 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012586 tANI_U32 ucDot11Mode = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012587
12588 if(!pSession)
12589 {
12590 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12591 return eHAL_STATUS_FAILURE;
12592 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012593 /* To satisfy klockworks */
12594 if (NULL == pBssDescription)
12595 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012596 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012597 return eHAL_STATUS_FAILURE;
12598 }
12599
Jeff Johnson295189b2012-06-20 16:38:30 -070012600 do {
12601 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
12602 pSession->joinFailStatusCode.reasonCode = 0;
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -070012603 memcpy (&pSession->joinFailStatusCode.bssId, &pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012604 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
12605 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
12606 // IE fields, but the length field in the bssDescription needs to be interpreted to
12607 // determine length of the IE fields.
12608 //
12609 // So, take the size of the JoinReq, subtract the size of the bssDescription and
12610 // add in the length from the bssDescription (then add the size of the 'length' field
12611 // itself because that is NOT included in the length field).
12612 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
12613 pBssDescription->length + sizeof( pBssDescription->length ) +
12614 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 +053012615 pMsg = vos_mem_malloc(msgLen);
12616 if (NULL == pMsg)
12617 status = eHAL_STATUS_FAILURE;
12618 else
12619 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012620 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012621 vos_mem_set(pMsg, msgLen , 0);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012622 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012623 pMsg->length = pal_cpu_to_be16(msgLen);
12624 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012625 // sessionId
12626 *pBuf = (tANI_U8)sessionId;
12627 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012628 // transactionId
12629 *pBuf = 0;
12630 *( pBuf + 1 ) = 0;
12631 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012632 // ssId
12633 if( pIes->SSID.present && pIes->SSID.num_ssid )
12634 {
12635 // ssId len
12636 *pBuf = pIes->SSID.num_ssid;
12637 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053012638 vos_mem_copy(pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -070012639 pBuf += pIes->SSID.num_ssid;
12640 }
12641 else
12642 {
12643 *pBuf = 0;
12644 pBuf++;
12645 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012646 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053012647 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
12648 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012649 pBuf += sizeof(tSirMacAddr);
12650 // bsstype
12651 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
12652 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
Kiet Lam64c1b492013-07-12 13:56:44 +053012653 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070012654 pBuf += sizeof(tSirBssType);
12655 // dot11mode
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012656 ucDot11Mode = csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
12657 if (pBssDescription->channelId <= 14 &&
12658 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
12659 WNI_CFG_DOT11_MODE_11AC == ucDot11Mode)
12660 {
12661 //Need to disable VHT operation in 2.4 GHz band
12662 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
12663 }
12664 *pBuf = (tANI_U8)ucDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -070012665 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012666 //Persona
12667 *pBuf = (tANI_U8)pProfile->csrPersona;
12668 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070012669 //CBMode
12670 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
12671 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012672
12673 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -070012674 FL("CSR PERSONA=%d CSR CbMode %d"), pProfile->csrPersona, pSession->bssParams.cbMode);
12675
Jeff Johnson295189b2012-06-20 16:38:30 -070012676 // uapsdPerAcBitmask
12677 *pBuf = pProfile->uapsd_mask;
12678 pBuf++;
12679
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012680
12681
Jeff Johnson295189b2012-06-20 16:38:30 -070012682 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012683 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012684 {
12685 // OperationalRateSet
12686 if (OpRateSet.numRates) {
12687 *pBuf++ = OpRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012688 vos_mem_copy(pBuf, OpRateSet.rate, OpRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012689 pBuf += OpRateSet.numRates;
12690 } else *pBuf++ = 0;
12691 // ExtendedRateSet
12692 if (ExRateSet.numRates) {
12693 *pBuf++ = ExRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012694 vos_mem_copy(pBuf, ExRateSet.rate, ExRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012695 pBuf += ExRateSet.numRates;
12696 } else *pBuf++ = 0;
12697 }
12698 else
12699 {
12700 *pBuf++ = 0;
12701 *pBuf++ = 0;
12702 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012703 // rsnIE
12704 if ( csrIsProfileWpa( pProfile ) )
12705 {
12706 // Insert the Wpa IE into the join request
12707 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
12708 (tCsrWpaIe *)( wpaRsnIE ) );
12709 }
12710 else if( csrIsProfileRSN( pProfile ) )
12711 {
12712 // Insert the RSN IE into the join request
12713 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12714 (tCsrRSNIe *)( wpaRsnIE ) );
12715 }
12716#ifdef FEATURE_WLAN_WAPI
12717 else if( csrIsProfileWapi( pProfile ) )
12718 {
12719 // Insert the WAPI IE into the join request
12720 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12721 (tCsrWapiIe *)( wpaRsnIE ) );
12722 }
12723#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012724 else
12725 {
12726 ieLen = 0;
12727 }
12728 //remember the IE for future use
12729 if( ieLen )
12730 {
12731 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
12732 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012733 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 -070012734 ieLen = DOT11F_IE_RSN_MAX_LEN;
12735 }
12736#ifdef FEATURE_WLAN_WAPI
12737 if( csrIsProfileWapi( pProfile ) )
12738 {
12739 //Check whether we need to allocate more memory
12740 if(ieLen > pSession->nWapiReqIeLength)
12741 {
12742 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
12743 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012744 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012745 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012746 pSession->pWapiReqIE = vos_mem_malloc(ieLen);
12747 if (NULL == pSession->pWapiReqIE)
12748 status = eHAL_STATUS_FAILURE;
12749 else
12750 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012751 if(!HAL_STATUS_SUCCESS(status)) break;
12752 }
12753 pSession->nWapiReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012754 vos_mem_copy(pSession->pWapiReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012755 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012756 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012757 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012758 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012759 pBuf += ieLen;
12760 }
12761 else//should be WPA/WPA2 otherwise
12762#endif /* FEATURE_WLAN_WAPI */
12763 {
12764 //Check whether we need to allocate more memory
12765 if(ieLen > pSession->nWpaRsnReqIeLength)
12766 {
12767 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
12768 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012769 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012770 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012771 pSession->pWpaRsnReqIE = vos_mem_malloc(ieLen);
12772 if (NULL == pSession->pWpaRsnReqIE)
12773 status = eHAL_STATUS_FAILURE;
12774 else
12775 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012776 if(!HAL_STATUS_SUCCESS(status)) break;
12777 }
12778 pSession->nWpaRsnReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012779 vos_mem_copy(pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012780 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012781 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012782 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012783 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012784 pBuf += ieLen;
12785 }
12786 }
12787 else
12788 {
12789 //free whatever old info
12790 pSession->nWpaRsnReqIeLength = 0;
12791 if(pSession->pWpaRsnReqIE)
12792 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012793 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012794 pSession->pWpaRsnReqIE = NULL;
12795 }
12796#ifdef FEATURE_WLAN_WAPI
12797 pSession->nWapiReqIeLength = 0;
12798 if(pSession->pWapiReqIE)
12799 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012800 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012801 pSession->pWapiReqIE = NULL;
12802 }
12803#endif /* FEATURE_WLAN_WAPI */
12804 //length is two bytes
12805 *pBuf = 0;
12806 *(pBuf + 1) = 0;
12807 pBuf += 2;
12808 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012809#ifdef FEATURE_WLAN_ESE
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012810 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012811 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012812 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070012813 //length is two bytes
12814 *pBuf = 0;
12815 *(pBuf + 1) = 0;
12816 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012817 }
12818 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012819 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012820 // cckmIE
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012821 if( csrIsProfileESE( pProfile ) )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012822 {
12823 // Insert the CCKM IE into the join request
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012824#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070012825 ieLen = pSession->suppCckmIeInfo.cckmIeLen;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080012826 vos_mem_copy((void *) (wpaRsnIE),
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070012827 pSession->suppCckmIeInfo.cckmIe, ieLen);
12828#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012829 ieLen = csrConstructEseCckmIe( pMac,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012830 pSession,
12831 pProfile,
12832 pBssDescription,
12833 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070012834 pSession->nWpaRsnReqIeLength,
12835 (void *)( wpaRsnIE ) );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012836#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012837 }
12838 else
12839 {
12840 ieLen = 0;
12841 }
12842 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
12843 if( ieLen )
12844 {
12845 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
12846 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012847 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012848 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012849 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012850 pBuf += ieLen;
12851 }
12852 else
12853 {
12854 //Indicate you have no CCKM IE
12855 //length is two bytes
12856 *pBuf = 0;
12857 *(pBuf + 1) = 0;
12858 pBuf += 2;
12859 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012860 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012861#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -070012862 // addIEScan
Agarwal Ashish4f616132013-12-30 23:32:50 +053012863 if (pProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070012864 {
12865 ieLen = pProfile->nAddIEScanLength;
Agarwal Ashish4f616132013-12-30 23:32:50 +053012866 memset(pSession->addIEScan, 0 , pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070012867 pSession->nAddIEScanLength = ieLen;
Agarwal Ashish4f616132013-12-30 23:32:50 +053012868 vos_mem_copy(pSession->addIEScan, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012869 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012870 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012871 pBuf += sizeof(tANI_U16);
Agarwal Ashish4f616132013-12-30 23:32:50 +053012872 vos_mem_copy(pBuf, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012873 pBuf += ieLen;
12874 }
12875 else
12876 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053012877 memset(pSession->addIEScan, 0, pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070012878 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070012879 *pBuf = 0;
12880 *(pBuf + 1) = 0;
12881 pBuf += 2;
12882 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012883 // addIEAssoc
12884 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
12885 {
12886 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070012887 if(ieLen > pSession->nAddIEAssocLength)
12888 {
12889 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
Kiet Lam64c1b492013-07-12 13:56:44 +053012890 {
12891 vos_mem_free(pSession->pAddIEAssoc);
12892 }
12893 pSession->pAddIEAssoc = vos_mem_malloc(ieLen);
12894 if (NULL == pSession->pAddIEAssoc)
12895 status = eHAL_STATUS_FAILURE;
12896 else
12897 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012898 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012899 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012900 pSession->nAddIEAssocLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012901 vos_mem_copy(pSession->pAddIEAssoc, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012902 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012903 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012904 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012905 vos_mem_copy(pBuf, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012906 pBuf += ieLen;
12907 }
12908 else
12909 {
12910 pSession->nAddIEAssocLength = 0;
12911 if(pSession->pAddIEAssoc)
12912 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012913 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070012914 pSession->pAddIEAssoc = NULL;
12915 }
12916 *pBuf = 0;
12917 *(pBuf + 1) = 0;
12918 pBuf += 2;
12919 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012920
12921 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012922 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012923 //Unmask any AC in reassoc that is ACM-set
12924 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
12925 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012926 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012927 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
12928 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012929#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012930 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012931#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012932 }
12933 else
12934 {
12935 uapsd_mask = 0;
12936 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012937 }
12938 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012939
Jeff Johnson295189b2012-06-20 16:38:30 -070012940 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012941 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012942 pBuf += sizeof(tANI_U32);
12943
Jeff Johnson295189b2012-06-20 16:38:30 -070012944 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012945 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012946 pBuf += sizeof(tANI_U32);
Chet Lanctot186b5732013-03-18 10:26:30 -070012947#ifdef WLAN_FEATURE_11W
12948 //MgmtEncryption
12949 if (pProfile->MFPEnabled)
12950 {
12951 dwTmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
12952 }
12953 else
12954 {
12955 dwTmp = pal_cpu_to_be32(eSIR_ED_NONE);
12956 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012957 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Chet Lanctot186b5732013-03-18 10:26:30 -070012958 pBuf += sizeof(tANI_U32);
12959#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070012960#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012961 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053012962 if (csrIsProfile11r( pProfile )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012963#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala09dd66b2013-04-01 17:13:01 +053012964 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012965 (pIes->ESEVersion.present) && (pMac->roam.configParam.isEseIniFeatureEnabled))
Saurabh Gupta775073c2013-02-14 13:31:36 +053012966#endif
12967 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012968 {
12969 // is11Rconnection;
12970 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012971 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool)) ;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012972 pBuf += sizeof(tAniBool);
12973 }
12974 else
12975 {
12976 // is11Rconnection;
12977 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012978 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012979 pBuf += sizeof(tAniBool);
12980 }
12981#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012982#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012983
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012984 // isESEFeatureIniEnabled
12985 if (TRUE == pMac->roam.configParam.isEseIniFeatureEnabled)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012986 {
12987 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053012988 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012989 pBuf += sizeof(tAniBool);
12990 }
12991 else
12992 {
12993 dwTmp = pal_cpu_to_be32(FALSE);
Srinivas Girigowda18112782013-11-27 12:21:19 -080012994 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053012995 pBuf += sizeof(tAniBool);
12996 }
12997
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012998 /* A profile can not be both ESE and 11R. But an 802.11R AP
12999 * may be advertising support for ESE as well. So if we are
13000 * associating Open or explicitly ESE then we will get ESE.
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013001 * If we are associating explictly 11R only then we will get
13002 * 11R.
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))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013008 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013009 // isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013010 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013011 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013012 pBuf += sizeof(tAniBool);
13013 }
13014 else
13015 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013016 //isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013017 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013018 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013019 pBuf += sizeof(tAniBool);
13020 }
13021
13022 if (eWNI_SME_JOIN_REQ == messageType)
13023 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013024 tESETspecInfo eseTspec;
13025 // ESE-Tspec IEs in the ASSOC request is presently not supported
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013026 // 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);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013030 }
13031 else if (eWNI_SME_REASSOC_REQ == messageType)
13032 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013033 if ((csrIsProfileESE(pProfile) ||
13034 ((pIes->ESEVersion.present)
Sandeep Puligilla798d6f22014-04-24 23:30:36 +053013035 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013036 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070013037 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013038 tESETspecInfo eseTspec;
13039 // ESE Tspec information
13040 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13041 eseTspec.numTspecs = sme_QosESERetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &eseTspec.tspec[0]);
13042 *pBuf = eseTspec.numTspecs;
Jeff Johnson295189b2012-06-20 16:38:30 -070013043 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013044 // Copy the TSPEC information only if present
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013045 if (eseTspec.numTspecs) {
13046 vos_mem_copy(pBuf, (void*)&eseTspec.tspec[0],
13047 (eseTspec.numTspecs*sizeof(tTspecInfo)));
Jeff Johnson295189b2012-06-20 16:38:30 -070013048 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013049 pBuf += sizeof(eseTspec.tspec);
Jeff Johnson295189b2012-06-20 16:38:30 -070013050 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013051 else
Jeff Johnson295189b2012-06-20 16:38:30 -070013052 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013053 tESETspecInfo eseTspec;
13054 // ESE-Tspec IEs in the ASSOC request is presently not supported
Jeff Johnson295189b2012-06-20 16:38:30 -070013055 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013056 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13057 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
13058 pBuf += sizeof(tESETspecInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070013059 }
13060 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013061#endif // FEATURE_WLAN_ESE
13062#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070013063 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013064 if (pMac->roam.configParam.isFastTransitionEnabled
13065#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053013066 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013067#endif
13068 )
Jeff Johnson295189b2012-06-20 16:38:30 -070013069 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013070 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013071 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013072 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070013073 }
13074 else
13075 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013076 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013077 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013078 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070013079 }
13080#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070013081#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053013082 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070013083 {
13084 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013085 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013086 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013087 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070013088 }
13089 else
13090 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013091 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013092 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013093 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070013094 }
13095#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013096
13097 // txLdpcIniFeatureEnabled
13098 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
13099 pBuf++;
13100
Kiran4a17ebe2013-01-31 10:43:43 -080013101 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
13102 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
13103 {
13104 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
13105 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
13106 csrApplyPower2Current(pMac);
13107 }
13108
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080013109#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080013110 // txBFIniFeatureEnabled
13111 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
13112 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080013113
13114 // txBFCsnValue
13115 *pBuf = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
13116 pBuf++;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080013117#endif
krunal soni5afa96c2013-09-06 22:19:02 -070013118 *pBuf = (tANI_U8)pMac->roam.configParam.isAmsduSupportInAMPDU;
13119 pBuf++;
13120
Sandeep Puligillaaea98a22013-12-04 13:36:32 +053013121 // WME
13122 if(pMac->roam.roamSession[sessionId].fWMMConnection)
13123 {
13124 //WME enabled
13125 dwTmp = pal_cpu_to_be32(TRUE);
13126 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13127 pBuf += sizeof(tAniBool);
13128 }
13129 else
13130 {
13131 dwTmp = pal_cpu_to_be32(FALSE);
13132 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13133 pBuf += sizeof(tAniBool);
13134 }
13135
13136 // QOS
13137 if(pMac->roam.roamSession[sessionId].fQOSConnection)
13138 {
13139 //QOS enabled
13140 dwTmp = pal_cpu_to_be32(TRUE);
13141 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13142 pBuf += sizeof(tAniBool);
13143 }
13144 else
13145 {
13146 dwTmp = pal_cpu_to_be32(FALSE);
13147 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13148 pBuf += sizeof(tAniBool);
13149 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013150 //BssDesc
13151 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
13152 (tANI_U8)pProfile->uapsd_mask);
krunal soni5afa96c2013-09-06 22:19:02 -070013153
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013154 status = palSendMBMessage(pMac->hHdd, pMsg );
13155 if(!HAL_STATUS_SUCCESS(status))
13156 {
13157 break;
13158 }
13159 else
13160 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013161#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013162 if (eWNI_SME_JOIN_REQ == messageType)
13163 {
13164 //Tush-QoS: notify QoS module that join happening
13165 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
13166 }
13167 else if (eWNI_SME_REASSOC_REQ == messageType)
13168 {
13169 //Tush-QoS: notify QoS module that reassoc happening
13170 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
13171 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013172#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013173 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013174 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013175 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013176}
13177
Jeff Johnson295189b2012-06-20 16:38:30 -070013178//
13179eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13180{
13181 eHalStatus status = eHAL_STATUS_SUCCESS;
13182 tSirSmeDisassocReq *pMsg;
13183 tANI_U8 *pBuf;
13184 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013185 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13186 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13187 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013188 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013189 pMsg = vos_mem_malloc(sizeof(tSirSmeDisassocReq));
13190 if (NULL == pMsg)
13191 status = eHAL_STATUS_FAILURE;
13192 else
13193 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013194 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013195 vos_mem_set(pMsg, sizeof( tSirSmeDisassocReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013196 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
13197 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013198 pBuf = &pMsg->sessionId;
13199 // sessionId
13200 *pBuf++ = (tANI_U8)sessionId;
13201 // transactionId
13202 *pBuf = 0;
13203 *( pBuf + 1 ) = 0;
13204 pBuf += sizeof(tANI_U16);
13205
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053013206 if ( (pSession->pCurRoamProfile != NULL) &&
13207 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
13208 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013209 {
13210 // Set the bssid address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013211 vos_mem_copy((tSirMacAddr *)pBuf, pSession->selfMacAddr,
13212 sizeof( tSirMacAddr ));
13213 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013214 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070013215 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013216 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
13217 //perMacAddr is passed as bssId for softAP
13218 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013219 pBuf = pBuf + sizeof ( tSirMacAddr );
13220 }
13221 else
13222 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013223 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013224 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
13225 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013226 pBuf = pBuf + sizeof ( tSirMacAddr );
Kiet Lam64c1b492013-07-12 13:56:44 +053013227 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ));
13228 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013229 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070013230 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013231 if(!HAL_STATUS_SUCCESS(status))
13232 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013233 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013234 break;
13235 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013236 // reasonCode
13237 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013238 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
13239 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013240 if(!HAL_STATUS_SUCCESS(status))
13241 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013242 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013243 break;
13244 }
13245 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013246 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
13247 Here we should not send the disassoc over the air to the AP */
13248 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
13249#ifdef WLAN_FEATURE_VOWIFI_11R
13250 && csrRoamIs11rAssoc(pMac)
13251#endif
13252 )
13253 {
13254 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
13255 }
13256 pBuf += sizeof(tANI_U8);
13257 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013258 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013259 return( status );
13260}
Jeff Johnson295189b2012-06-20 16:38:30 -070013261eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
13262{
13263 eHalStatus status = eHAL_STATUS_SUCCESS;
13264 tSirSmeTkipCntrMeasReq *pMsg;
13265 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013266 do
13267 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013268 pMsg = vos_mem_malloc(sizeof( tSirSmeTkipCntrMeasReq ));
13269 if ( NULL == pMsg )
13270 status = eHAL_STATUS_FAILURE;
13271 else
13272 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013273 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013274 vos_mem_set(pMsg, sizeof( tSirSmeTkipCntrMeasReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013275 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
13276 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013277 pBuf = &pMsg->sessionId;
13278 // sessionId
13279 *pBuf++ = (tANI_U8)sessionId;
13280 // transactionId
13281 *pBuf = 0;
13282 *( pBuf + 1 ) = 0;
13283 pBuf += sizeof(tANI_U16);
13284 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053013285 vos_mem_copy(pMsg->bssId, bssId, sizeof( tSirMacAddr ));
13286 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013287 pBuf = pBuf + sizeof ( tSirMacAddr );
13288 // bEnable
13289 *pBuf = (tANI_BOOLEAN)bEnable;
13290 if(!HAL_STATUS_SUCCESS(status))
13291 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013292 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013293 break;
13294 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013295 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013296 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013297 return( status );
13298}
Jeff Johnson295189b2012-06-20 16:38:30 -070013299eHalStatus
13300csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
13301 VOS_MODULE_ID modId, tSirMacAddr bssId,
13302 void *pUsrContext, void *pfnSapEventCallback,
13303 tANI_U8 *pAssocStasBuf )
13304{
13305 eHalStatus status = eHAL_STATUS_SUCCESS;
13306 tSirSmeGetAssocSTAsReq *pMsg;
13307 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
13308 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013309 do
13310 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013311 pMsg = vos_mem_malloc(sizeof( tSirSmeGetAssocSTAsReq ));
13312 if ( NULL == pMsg )
13313 status = eHAL_STATUS_FAILURE;
13314 else
13315 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013316 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013317 vos_mem_set(pMsg, sizeof( tSirSmeGetAssocSTAsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013318 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013319 pBuf = (tANI_U8 *)&pMsg->bssId;
13320 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013321 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013322 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013323 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013324 // modId
13325 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013326 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013327 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013328 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080013329 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void *));
13330 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013331 // pfnSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080013332 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void*));
13333 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013334 // pAssocStasBuf
krunal soni4f802b22014-02-11 17:01:13 -080013335 vos_mem_copy(pBuf, pAssocStasBuf, sizeof(void*));
13336 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013337 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013338 status = palSendMBMessage( pMac->hHdd, pMsg );
13339 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013340 return( status );
13341 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013342eHalStatus
13343csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
13344 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
13345 {
13346 eHalStatus status = eHAL_STATUS_SUCCESS;
13347 tSirSmeGetWPSPBCSessionsReq *pMsg;
13348 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
krunal soni4f802b22014-02-11 17:01:13 -080013349
Jeff Johnson295189b2012-06-20 16:38:30 -070013350 do
13351 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013352 pMsg = vos_mem_malloc(sizeof(tSirSmeGetWPSPBCSessionsReq));
13353 if ( NULL == pMsg )
13354 status = eHAL_STATUS_FAILURE;
13355 else
13356 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013357 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013358 vos_mem_set(pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013359 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013360 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
lukez3c809222013-05-03 10:23:02 -070013361 VOS_ASSERT(pBuf);
13362
Jeff Johnson295189b2012-06-20 16:38:30 -070013363 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013364 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080013365 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void*));
13366 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070013367 // pSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080013368 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void *));
13369 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070013370 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013371 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013372 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013373 // MAC Address of STA in WPS session
Kiet Lam64c1b492013-07-12 13:56:44 +053013374 vos_mem_copy((tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
Jeff Johnson295189b2012-06-20 16:38:30 -070013375 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070013376 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013377 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013378 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013379 return( status );
13380}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013381
13382eHalStatus
13383csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
13384{
13385 tpSirChangeBIParams pMsg;
13386 tANI_U16 len = 0;
13387 eHalStatus status = eHAL_STATUS_SUCCESS;
13388 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13389
13390 if(!pSession)
13391 {
13392 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13393 return eHAL_STATUS_FAILURE;
13394 }
13395
13396 //NO need to update the Beacon Params if update beacon parameter flag is not set
13397 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
13398 return eHAL_STATUS_SUCCESS;
13399
13400 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
13401
13402 /* Create the message and send to lim */
13403 len = sizeof(tSirChangeBIParams);
Kiet Lam64c1b492013-07-12 13:56:44 +053013404 pMsg = vos_mem_malloc(len);
13405 if ( NULL == pMsg )
13406 status = eHAL_STATUS_FAILURE;
13407 else
13408 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013409 if(HAL_STATUS_SUCCESS(status))
13410 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013411 vos_mem_set(pMsg, sizeof(tSirChangeBIParams), 0);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013412 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
13413 pMsg->length = len;
13414
13415 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013416 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
13417 sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -080013418 smsLog( pMac, LOG1, FL("CSR Attempting to change BI for Bssid= "MAC_ADDRESS_STR),
13419 MAC_ADDR_ARRAY(pMsg->bssId));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013420 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013421 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013422 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
13423 status = palSendMBMessage(pMac->hHdd, pMsg);
13424 }
13425 return status;
13426}
13427
Jeff Johnson295189b2012-06-20 16:38:30 -070013428eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13429{
13430 eHalStatus status = eHAL_STATUS_SUCCESS;
13431 tSirSmeDeauthReq *pMsg;
13432 tANI_U8 *pBuf;
13433 tANI_U16 wTmp;
13434 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13435 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13436 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013437 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013438 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthReq ));
13439 if ( NULL == pMsg )
13440 status = eHAL_STATUS_FAILURE;
13441 else
13442 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013443 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013444 vos_mem_set(pMsg, sizeof( tSirSmeDeauthReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013445 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
13446 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
13447 //sessionId
13448 pBuf = &pMsg->sessionId;
13449 *pBuf++ = (tANI_U8)sessionId;
13450
13451 //tansactionId
13452 *pBuf = 0;
13453 *(pBuf + 1 ) = 0;
13454 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013455 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070013456 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070013457 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
13458 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013459 vos_mem_copy( (tSirMacAddr *)pBuf, pSession->selfMacAddr,
13460 sizeof( pMsg->peerMacAddr ) );
13461 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013462 pBuf = pBuf + sizeof(tSirMacAddr);
13463 }
13464 else
13465 {
13466 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013467 vos_mem_copy( (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13468 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013469 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013470 }
13471 if(!HAL_STATUS_SUCCESS(status))
13472 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013473 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013474 break;
13475 }
13476 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013477 vos_mem_copy( (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13478 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013479 pBuf = pBuf + sizeof(tSirMacAddr);
13480 if(!HAL_STATUS_SUCCESS(status))
13481 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013482 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013483 break;
13484 }
13485 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013486 vos_mem_copy( pBuf, &wTmp,sizeof( tANI_U16 ) );
13487 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013488 if(!HAL_STATUS_SUCCESS(status))
13489 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013490 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013491 break;
13492 }
13493 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013494 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013495 return( status );
13496}
13497
Jeff Johnson295189b2012-06-20 16:38:30 -070013498eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
13499{
13500 eHalStatus status = eHAL_STATUS_SUCCESS;
13501 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013502 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013503 pMsg = vos_mem_malloc(sizeof( tSirSmeDisassocCnf ));
13504 if ( NULL == pMsg )
13505 status = eHAL_STATUS_FAILURE;
13506 else
13507 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013508 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013509 vos_mem_set(pMsg, sizeof( tSirSmeDisassocCnf), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013510 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
13511 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13512 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013513 vos_mem_copy(pMsg->peerMacAddr, pDisassocInd->peerMacAddr,
13514 sizeof(pMsg->peerMacAddr));
13515 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013516 if(!HAL_STATUS_SUCCESS(status))
13517 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013518 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013519 break;
13520 }
13521//To test reconn
Kiet Lam64c1b492013-07-12 13:56:44 +053013522 vos_mem_copy(pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
13523 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013524 if(!HAL_STATUS_SUCCESS(status))
13525 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013526 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013527 break;
13528 }
13529//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070013530 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013531 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013532 return( status );
13533}
13534
Jeff Johnson295189b2012-06-20 16:38:30 -070013535eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
13536{
13537 eHalStatus status = eHAL_STATUS_SUCCESS;
13538 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013539 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013540 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthCnf ));
13541 if ( NULL == pMsg )
13542 status = eHAL_STATUS_FAILURE;
13543 else
13544 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013545 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013546 vos_mem_set(pMsg, sizeof( tSirSmeDeauthCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013547 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
13548 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13549 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013550 vos_mem_copy(pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
13551 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013552 if(!HAL_STATUS_SUCCESS(status))
13553 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013554 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013555 break;
13556 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013557 vos_mem_copy(pMsg->peerMacAddr, pDeauthInd->peerMacAddr,
13558 sizeof(pMsg->peerMacAddr));
13559 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013560 if(!HAL_STATUS_SUCCESS(status))
13561 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013562 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013563 break;
13564 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013565 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013566 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013567 return( status );
13568}
Jeff Johnson295189b2012-06-20 16:38:30 -070013569eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
13570{
13571 eHalStatus status = eHAL_STATUS_SUCCESS;
13572 tSirSmeAssocCnf *pMsg;
13573 tANI_U8 *pBuf;
13574 tSirResultCodes statusCode;
13575 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013576 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013577 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocCnf ));
13578 if ( NULL == pMsg )
13579 status = eHAL_STATUS_FAILURE;
13580 else
13581 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013582 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013583 vos_mem_set(pMsg, sizeof( tSirSmeAssocCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013584 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
13585 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013586 pBuf = (tANI_U8 *)&pMsg->statusCode;
13587 if(HAL_STATUS_SUCCESS(Halstatus))
13588 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13589 else
13590 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053013591 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes));
Jeff Johnson295189b2012-06-20 16:38:30 -070013592 pBuf += sizeof(tSirResultCodes);
13593 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013594 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13595 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013596 pBuf += sizeof (tSirMacAddr);
13597 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013598 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13599 sizeof(tSirMacAddr));
13600 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013601 pBuf += sizeof (tSirMacAddr);
13602 // aid
13603 wTmp = pal_cpu_to_be16(pAssocInd->aid);
Kiet Lam64c1b492013-07-12 13:56:44 +053013604 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013605 pBuf += sizeof (tANI_U16);
13606 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013607 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13608 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013609 pBuf += sizeof (tSirMacAddr);
13610 // alternateChannelId
13611 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070013612 status = palSendMBMessage( pMac->hHdd, pMsg );
13613 if(!HAL_STATUS_SUCCESS(status))
13614 {
13615 //pMsg is freed by palSendMBMessage
13616 break;
13617 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013618 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013619 return( status );
13620}
Jeff Johnson295189b2012-06-20 16:38:30 -070013621eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
13622 tpSirSmeAssocInd pAssocInd,
13623 eHalStatus Halstatus,
13624 tANI_U8 sessionId)
13625{
13626 tSirMsgQ msgQ;
Jeff Johnson295189b2012-06-20 16:38:30 -070013627 tSirSmeAssocIndToUpperLayerCnf *pMsg;
13628 tANI_U8 *pBuf;
13629 tSirResultCodes statusCode;
13630 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013631 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013632 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocIndToUpperLayerCnf ));
13633 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13634 vos_mem_set(pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ), 0);
Jeff Johnsone7245742012-09-05 17:12:55 -070013635
Jeff Johnson295189b2012-06-20 16:38:30 -070013636 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
13637 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
13638
13639 pMsg->sessionId = sessionId;
13640
13641 pBuf = (tANI_U8 *)&pMsg->statusCode;
13642 if(HAL_STATUS_SUCCESS(Halstatus))
13643 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13644 else
13645 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053013646 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes)) ;
Jeff Johnson295189b2012-06-20 16:38:30 -070013647 pBuf += sizeof(tSirResultCodes);
13648 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013649 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013650 pBuf += sizeof (tSirMacAddr);
13651 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013652 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13653 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013654 pBuf += sizeof (tSirMacAddr);
13655 // StaId
13656 wTmp = pal_cpu_to_be16(pAssocInd->staId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013657 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013658 pBuf += sizeof (tANI_U16);
13659 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013660 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013661 pBuf += sizeof (tSirMacAddr);
13662 // alternateChannelId
13663 *pBuf = 11;
13664 pBuf += sizeof (tANI_U8);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013665 // Instead of copying roam Info, we just copy only WmmEnabled, RsnIE information
Jeff Johnson295189b2012-06-20 16:38:30 -070013666 //Wmm
13667 *pBuf = pAssocInd->wmmEnabledSta;
13668 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013669 //RSN IE
Kiet Lam64c1b492013-07-12 13:56:44 +053013670 vos_mem_copy((tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070013671 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070013672 //Additional IE
Kiet Lam64c1b492013-07-12 13:56:44 +053013673 vos_mem_copy((void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
Jeff Johnson295189b2012-06-20 16:38:30 -070013674 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070013675 //reassocReq
13676 *pBuf = pAssocInd->reassocReq;
13677 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013678 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
13679 msgQ.bodyptr = pMsg;
13680 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013681 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013682 } while( 0 );
Kiet Lam64c1b492013-07-12 13:56:44 +053013683 return( eHAL_STATUS_SUCCESS );
Jeff Johnson295189b2012-06-20 16:38:30 -070013684}
Jeff Johnson295189b2012-06-20 16:38:30 -070013685
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013686eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -070013687 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
13688 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
13689 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
13690 tANI_U8 *pKeyRsc )
13691{
13692 tSirSmeSetContextReq *pMsg;
13693 tANI_U16 msgLen;
13694 eHalStatus status = eHAL_STATUS_FAILURE;
13695 tAniEdType tmpEdType;
13696 tAniKeyDirection tmpDirection;
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +053013697 tANI_U8 *pBuf = NULL;
13698 tANI_U8 *p = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013699 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013700 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070013701 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013702 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
13703 // key set. Since we only support upto one key, we always allocate memory for 1 key
13704 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
13705 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
13706 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
13707 ( sizeof( pMsg->keyMaterial.key ) );
13708
Kiet Lam64c1b492013-07-12 13:56:44 +053013709 pMsg = vos_mem_malloc(msgLen);
13710 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13711 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013712 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
13713 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013714 //sessionId
13715 pBuf = &pMsg->sessionId;
13716 *pBuf = (tANI_U8)sessionId;
13717 pBuf++;
13718 // transactionId
13719 *pBuf = 0;
13720 *(pBuf + 1) = 0;
13721 pBuf += sizeof(tANI_U16);
13722 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013723 vos_mem_copy(pBuf, (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013724
13725 pBuf += sizeof(tSirMacAddr);
13726
13727 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013728 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
13729 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013730
13731 pBuf += sizeof(tSirMacAddr);
13732
13733 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013734 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
13735 // in the tSirKeyMaterial keyMaterial; field).
13736 //
13737 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
13738 // shorter than this max size. Is LIM interpreting this ok ?
13739 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 -070013740 // set pMsg->keyMaterial.edType
13741 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013742 vos_mem_copy(p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013743 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070013744 // set the pMsg->keyMaterial.numKeys field
13745 *p = numKeys;
13746 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070013747 // set pSirKey->keyId = keyId;
13748 *p = keyId;
13749 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013750 // set pSirKey->unicast = (tANI_U8)fUnicast;
13751 *p = (tANI_U8)fUnicast;
13752 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070013753 // set pSirKey->keyDirection = aniKeyDirection;
13754 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
Kiet Lam64c1b492013-07-12 13:56:44 +053013755 vos_mem_copy(p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection));
Jeff Johnson295189b2012-06-20 16:38:30 -070013756 p += sizeof(tAniKeyDirection);
13757 // pSirKey->keyRsc = ;;
Kiet Lam64c1b492013-07-12 13:56:44 +053013758 vos_mem_copy(p, pKeyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -070013759 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070013760 // set pSirKey->paeRole
13761 *p = paeRole; // 0 is Supplicant
13762 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013763 // set pSirKey->keyLength = keyLength;
13764 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013765 if ( keyLength && pKey )
13766 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013767 vos_mem_copy(p, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013768 if(keyLength == 16)
13769 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013770 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 -070013771 keyId, edType, pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
13772 pKey[5], pKey[6], pKey[7], pKey[8],
13773 pKey[9], pKey[10], pKey[11], pKey[12], pKey[13], pKey[14], pKey[15]);
13774 }
13775 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013776 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013777 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013778 return( status );
13779}
13780
Jeff Johnson295189b2012-06-20 16:38:30 -070013781eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
13782 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
13783{
13784 eHalStatus status;
13785 tSirSmeStartBssReq *pMsg;
13786 tANI_U8 *pBuf = NULL;
13787 tANI_U8 *wTmpBuf = NULL;
13788 tANI_U16 msgLen, wTmp;
13789 tANI_U32 dwTmp;
13790 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070013791 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070013792 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070013793 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070013794
13795 if(!pSession)
13796 {
13797 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13798 return eHAL_STATUS_FAILURE;
13799 }
13800
Jeff Johnson295189b2012-06-20 16:38:30 -070013801 do {
13802 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
13803 pSession->joinFailStatusCode.reasonCode = 0;
13804 msgLen = sizeof(tSirSmeStartBssReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053013805 pMsg = vos_mem_malloc(msgLen);
13806 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13807 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013808 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013809 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070013810 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013811 //sessionId
13812 *pBuf = (tANI_U8)sessionId;
13813 pBuf++;
13814 // transactionId
13815 *pBuf = 0;
13816 *(pBuf + 1) = 0;
13817 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013818 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053013819 vos_mem_copy(pBuf, pParam->bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013820 pBuf += sizeof(tSirMacAddr);
13821 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013822 vos_mem_copy(pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013823 pBuf += sizeof(tSirMacAddr);
13824 // beaconInterval
13825 if( pBssDesc && pBssDesc->beaconInterval )
13826 {
13827 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
13828 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013829 else if(pParam->beaconInterval)
13830 {
13831 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
13832 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013833 else
13834 {
13835 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
13836 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -070013837 if(csrIsconcurrentsessionValid (pMac, sessionId,
13838 pParam->bssPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -070013839 == eHAL_STATUS_SUCCESS )
13840 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013841 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070013842 pParam->bssPersona);
13843 //Update the beacon Interval
13844 pParam->beaconInterval = wTmp;
13845 }
13846 else
13847 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013848 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070013849 status = eHAL_STATUS_FAILURE;
Kiet Lam64c1b492013-07-12 13:56:44 +053013850 vos_mem_free(pMsg);
Jeff Johnsone7245742012-09-05 17:12:55 -070013851 return status;
13852 }
13853
Kiet Lam64c1b492013-07-12 13:56:44 +053013854 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013855 pBuf += sizeof(tANI_U16);
13856 // dot11mode
13857 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
13858 pBuf += 1;
13859 // bssType
13860 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013861 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013862 pBuf += sizeof(tSirBssType);
13863 // ssId
13864 if( pParam->ssId.length )
13865 {
13866 // ssId len
13867 *pBuf = pParam->ssId.length;
13868 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053013869 vos_mem_copy(pBuf, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070013870 pBuf += pParam->ssId.length;
13871 }
13872 else
13873 {
13874 *pBuf = 0;
13875 pBuf++;
13876 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013877 // set the channel Id
13878 *pBuf = pParam->operationChn;
13879 pBuf++;
13880 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070013881 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013882 vos_mem_copy(pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState));
Jeff Johnsone7245742012-09-05 17:12:55 -070013883 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070013884
Jeff Johnson295189b2012-06-20 16:38:30 -070013885 // Set privacy
13886 *pBuf = pParam->privacy;
13887 pBuf++;
13888
13889 //Set Uapsd
13890 *pBuf = pParam->ApUapsdEnable;
13891 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013892 //Set SSID hidden
13893 *pBuf = pParam->ssidHidden;
13894 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013895 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
13896 pBuf++;
13897
13898 //Ht protection Enable/Disable
13899 *pBuf = (tANI_U8)pParam->protEnabled;
13900 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013901 //Enable Beacons to Receive for OBSS protection Enable/Disable
13902 *pBuf = (tANI_U8)pParam->obssProtEnabled;
13903 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013904 //set cfg related to protection
13905 wTmp = pal_cpu_to_be16( pParam->ht_protection );
Kiet Lam64c1b492013-07-12 13:56:44 +053013906 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013907 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013908 // Set Auth type
13909 authType = pal_cpu_to_be32(pParam->authType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013910 vos_mem_copy(pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013911 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013912 // Set DTIM
13913 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
Kiet Lam64c1b492013-07-12 13:56:44 +053013914 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070013915 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070013916 // Set wps_state
13917 *pBuf = pParam->wps_state;
13918 pBuf++;
krunal sonie9002db2013-11-25 14:24:17 -080013919 // set isCoalesingInIBSSAllowed
13920 *pBuf = pMac->isCoalesingInIBSSAllowed;
13921 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013922 //Persona
13923 *pBuf = (tANI_U8)pParam->bssPersona;
13924 pBuf++;
13925
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080013926 //txLdpcIniFeatureEnabled
13927 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
13928 pBuf++;
krunal soni4f087d22013-07-29 16:32:26 -070013929
Chet Lanctot8cecea22014-02-11 19:09:36 -080013930#ifdef WLAN_FEATURE_11W
13931 // Set MFP capable/required
13932 *pBuf = (tANI_U8)pParam->mfpCapable;
13933 pBuf++;
13934 *pBuf = (tANI_U8)pParam->mfpRequired;
13935 pBuf++;
13936#endif
13937
krunal soni4f087d22013-07-29 16:32:26 -070013938 // set RSN IE
Jeff Johnson295189b2012-06-20 16:38:30 -070013939 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
13940 {
13941 status = eHAL_STATUS_INVALID_PARAMETER;
Kiet Lam64c1b492013-07-12 13:56:44 +053013942 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013943 break;
13944 }
13945 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
Kiet Lam64c1b492013-07-12 13:56:44 +053013946 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013947 pBuf += sizeof(tANI_U16);
13948 if( wTmp )
13949 {
13950 wTmp = pParam->nRSNIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +053013951 vos_mem_copy(pBuf, pParam->pRSNIE, wTmp);
Jeff Johnson295189b2012-06-20 16:38:30 -070013952 pBuf += wTmp;
13953 }
13954 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013955 vos_mem_copy(pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013956 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070013957 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
13958 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053013959 vos_mem_copy(pBuf, pParam->operationalRateSet.rate,
13960 pParam->operationalRateSet.numRates );
Jeff Johnson295189b2012-06-20 16:38:30 -070013961 pBuf += pParam->operationalRateSet.numRates ;
13962 *pBuf++ = pParam->extendedRateSet.numRates;
13963 if(0 != pParam->extendedRateSet.numRates)
13964 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013965 vos_mem_copy(pBuf, pParam->extendedRateSet.rate,
13966 pParam->extendedRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070013967 pBuf += pParam->extendedRateSet.numRates;
13968 }
krunal sonie9002db2013-11-25 14:24:17 -080013969
Jeff Johnson295189b2012-06-20 16:38:30 -070013970 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
13971 pMsg->length = pal_cpu_to_be16(msgLen);
13972
13973 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013974 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013975 return( status );
13976}
13977
Jeff Johnson295189b2012-06-20 16:38:30 -070013978eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
13979{
13980 eHalStatus status = eHAL_STATUS_FAILURE;
13981 tSirSmeStopBssReq *pMsg;
13982 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13983 tANI_U8 *pBuf;
13984 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070013985
13986 if(!pSession)
13987 {
13988 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13989 return eHAL_STATUS_FAILURE;
13990 }
13991
Jeff Johnson295189b2012-06-20 16:38:30 -070013992 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013993 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
13994 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13995 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013996 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
13997 pBuf = &pMsg->sessionId;
13998 //sessionId
13999 *pBuf = (tANI_U8)sessionId;
14000 pBuf++;
14001 // transactionId
14002 *pBuf = 0;
14003 pBuf += sizeof(tANI_U16);
14004 //reason code
14005 *pBuf = 0;
14006 pBuf += sizeof(tSirResultCodes);
14007 // bssid
14008 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
14009 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
14010 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014011 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->selfMacAddr,
14012 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014013 }
14014 else
14015 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014016 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
14017 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014018 }
14019 pBuf += sizeof(tSirMacAddr);
14020 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
14021 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014022 status = palSendMBMessage( pMac->hHdd, pMsg );
14023#if 0
Kiet Lam64c1b492013-07-12 13:56:44 +053014024 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
14025 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14026 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014027 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
14028 pMsg->reasonCode = 0;
14029 // bssid
14030 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
14031 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
14032 {
14033 pbBssid = (tANI_U8 *)&pSession->selfMacAddr;
14034 }
14035 else
14036 {
14037 pbBssid = (tANI_U8 *)&pSession->connectedProfile.bssid;
14038 }
Kiet Lam64c1b492013-07-12 13:56:44 +053014039 vos_mem_copy(&pMsg->bssId, pbBssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014040 pMsg->transactionId = 0;
14041 pMsg->sessionId = (tANI_U8)sessionId;
14042 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeStopBssReq ));
14043 status = palSendMBMessage( pMac->hHdd, pMsg );
14044#endif
14045 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014046 return( status );
14047}
14048
Jeff Johnson295189b2012-06-20 16:38:30 -070014049eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
14050 tCsrRoamModifyProfileFields *pModProfileFields,
14051 tANI_U32 *pRoamId, v_BOOL_t fForce)
14052{
Jeff Johnson295189b2012-06-20 16:38:30 -070014053 eHalStatus status = eHAL_STATUS_FAILURE;
14054 tANI_U32 roamId = 0;
14055 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014056 if((csrIsConnStateConnected(pMac, sessionId)) &&
Kiet Lam64c1b492013-07-12 13:56:44 +053014057 (fForce || (!vos_mem_compare( &pModProfileFields,
14058 &pSession->connectedProfile.modifyProfileFields,
14059 sizeof(tCsrRoamModifyProfileFields)))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070014060 {
14061 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
14062 if(pRoamId)
14063 {
14064 *pRoamId = roamId;
14065 }
14066
Jeff Johnson295189b2012-06-20 16:38:30 -070014067 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
14068 eCsrSmeIssuedReassocToSameAP, roamId,
14069 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014070 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014071 return status;
14072}
Jeff Johnson295189b2012-06-20 16:38:30 -070014073static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
14074{
14075 eHalStatus status = eHAL_STATUS_SUCCESS;
14076 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +053014077 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014078 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
14079 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
14080 return (status);
14081}
Jeff Johnson295189b2012-06-20 16:38:30 -070014082eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
14083{
14084 eHalStatus status = eHAL_STATUS_SUCCESS;
14085 tListElem *pEntry = NULL;
14086 tSmeCmd *pCommand = NULL;
14087 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014088 do
14089 {
14090 if(pMsg == NULL)
14091 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014092 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014093 status = eHAL_STATUS_FAILURE;
14094 break;
14095 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014096 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
14097 if(pEntry)
14098 {
14099 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14100 if(eSmeCommandAddStaSession == pCommand->command)
14101 {
14102 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014103 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Siddharth Bhal85f99b12014-05-09 08:09:07 +053014104 if (pRsp->status == eSIR_FAILURE) {
14105 VOS_ASSERT( 0 );
14106 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014107 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070014108 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014109 //Remove this command out of the active list
14110 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
14111 {
14112 //Now put this command back on the avilable command list
14113 csrReleaseCommand(pMac, pCommand);
14114 }
14115 smeProcessPendingQueue( pMac );
14116 }
14117 else
14118 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014119 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 -070014120 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014121 status = eHAL_STATUS_FAILURE;
14122 break;
14123 }
14124 }
14125 else
14126 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014127 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 -070014128 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014129 status = eHAL_STATUS_FAILURE;
14130 break;
14131 }
14132 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014133 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014134}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014135eHalStatus csrSendMBAddSelfStaReqMsg(tpAniSirGlobal pMac,
14136 tAddStaForSessionCmd *pAddStaReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070014137{
14138 tSirSmeAddStaSelfReq *pMsg;
14139 tANI_U16 msgLen;
14140 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014141 do {
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014142 msgLen = sizeof(tSirSmeAddStaSelfReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053014143 pMsg = vos_mem_malloc(msgLen);
14144 if ( NULL == pMsg ) break;
14145 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014146 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
14147 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014148 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053014149 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr,
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014150 (tANI_U8 *)&pAddStaReq->selfMacAddr, sizeof(tSirMacAddr));
14151
14152 pMsg->currDeviceMode = pAddStaReq->currDeviceMode;
14153
Arif Hussain24bafea2013-11-15 15:10:03 -080014154 smsLog( pMac, LOG1, FL("selfMac="MAC_ADDRESS_STR),
14155 MAC_ADDR_ARRAY(pMsg->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014156 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014157 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014158 return( status );
14159}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014160eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac,
14161 tANI_U32 sessionId,
14162 tSirMacAddr sessionMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -070014163{
14164 eHalStatus status = eHAL_STATUS_SUCCESS;
14165 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014166 pCommand = csrGetCommandBuffer(pMac);
14167 if(NULL == pCommand)
14168 {
14169 status = eHAL_STATUS_RESOURCES;
14170 }
14171 else
14172 {
14173 pCommand->command = eSmeCommandAddStaSession;
14174 pCommand->sessionId = (tANI_U8)sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053014175 vos_mem_copy(pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr,
14176 sizeof( tSirMacAddr ) );
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014177 pCommand->u.addStaSessionCmd.currDeviceMode = pMac->sme.currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070014178 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
14179 if( !HAL_STATUS_SUCCESS( status ) )
14180 {
14181 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014182 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014183 }
14184 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014185 return (status);
14186}
Jeff Johnson295189b2012-06-20 16:38:30 -070014187eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14188{
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014189 return csrSendMBAddSelfStaReqMsg(pMac, &pCommand->u.addStaSessionCmd);
Jeff Johnson295189b2012-06-20 16:38:30 -070014190}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014191eHalStatus csrRoamOpenSession(tpAniSirGlobal pMac,
14192 csrRoamCompleteCallback callback,
14193 void *pContext, tANI_U8 *pSelfMacAddr,
14194 tANI_U8 *pbSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -070014195{
14196 eHalStatus status = eHAL_STATUS_SUCCESS;
14197 tANI_U32 i;
14198 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070014199 *pbSessionId = CSR_SESSION_ID_INVALID;
14200 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14201 {
14202 if( !CSR_IS_SESSION_VALID( pMac, i ) )
14203 {
14204 pSession = CSR_GET_SESSION( pMac, i );
14205 status = eHAL_STATUS_SUCCESS;
14206 pSession->sessionActive = eANI_BOOLEAN_TRUE;
14207 pSession->sessionId = (tANI_U8)i;
14208 pSession->callback = callback;
14209 pSession->pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053014210 vos_mem_copy(&pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070014211 *pbSessionId = (tANI_U8)i;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014212 status = vos_timer_init(&pSession->hTimerRoaming, VOS_TIMER_TYPE_SW,
14213 csrRoamRoamingTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070014214 &pSession->roamingTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014215 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014216 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014217 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014218 break;
14219 }
14220#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014221 status = vos_timer_init(&pSession->hTimerJoinRetry, VOS_TIMER_TYPE_SW,
14222 csrRoamJoinRetryTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070014223 &pSession->joinRetryTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014224 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014225 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014226 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014227 break;
14228 }
14229#endif
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014230 status = csrIssueAddStaForSessionReq (pMac, i, pSelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014231 break;
14232 }
14233 }
14234 if( CSR_ROAM_SESSION_MAX == i )
14235 {
14236 //No session is available
14237 status = eHAL_STATUS_RESOURCES;
14238 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014239 return ( status );
14240}
Jeff Johnson295189b2012-06-20 16:38:30 -070014241eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
14242{
14243 eHalStatus status = eHAL_STATUS_SUCCESS;
14244 tListElem *pEntry = NULL;
14245 tSmeCmd *pCommand = NULL;
14246 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014247 do
14248 {
14249 if(pMsg == NULL)
14250 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014251 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014252 status = eHAL_STATUS_FAILURE;
14253 break;
14254 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014255 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
14256 if(pEntry)
14257 {
14258 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14259 if(eSmeCommandDelStaSession == pCommand->command)
14260 {
14261 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070014262 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014263 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014264 //This session is done.
14265 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014266 if(pCommand->u.delStaSessionCmd.callback)
14267 {
14268
14269 status = sme_ReleaseGlobalLock( &pMac->sme );
14270 if ( HAL_STATUS_SUCCESS( status ) )
14271 {
14272 pCommand->u.delStaSessionCmd.callback(
14273 pCommand->u.delStaSessionCmd.pContext);
14274 status = sme_AcquireGlobalLock( &pMac->sme );
14275 if (! HAL_STATUS_SUCCESS( status ) )
14276 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014277 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014278 return status;
14279 }
14280 }
14281 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014282 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014283 }
14284 }
14285
14286 //Remove this command out of the active list
14287 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
14288 {
14289 //Now put this command back on the avilable command list
14290 csrReleaseCommand(pMac, pCommand);
14291 }
14292 smeProcessPendingQueue( pMac );
14293 }
14294 else
14295 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014296 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 -070014297 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014298 status = eHAL_STATUS_FAILURE;
14299 break;
14300 }
14301 }
14302 else
14303 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014304 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 -070014305 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014306 status = eHAL_STATUS_FAILURE;
14307 break;
14308 }
14309 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014310 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014311}
Jeff Johnson295189b2012-06-20 16:38:30 -070014312eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
14313{
14314 tSirSmeDelStaSelfReq *pMsg;
14315 tANI_U16 msgLen;
14316 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014317 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070014318 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
14319 sizeof( tSirBssType )*/;
Kiet Lam64c1b492013-07-12 13:56:44 +053014320 pMsg = vos_mem_malloc(msgLen);
14321 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14322 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014323 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
14324 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014325 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053014326 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr,
14327 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014328 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014329 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014330 return( status );
14331}
Jeff Johnson295189b2012-06-20 16:38:30 -070014332eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
14333 tSirMacAddr sessionMacAddr,
14334 csrRoamSessionCloseCallback callback,
14335 void *pContext)
14336{
14337 eHalStatus status = eHAL_STATUS_SUCCESS;
14338 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014339 pCommand = csrGetCommandBuffer(pMac);
14340 if(NULL == pCommand)
14341 {
14342 status = eHAL_STATUS_RESOURCES;
14343 }
14344 else
14345 {
14346 pCommand->command = eSmeCommandDelStaSession;
14347 pCommand->sessionId = (tANI_U8)sessionId;
14348 pCommand->u.delStaSessionCmd.callback = callback;
14349 pCommand->u.delStaSessionCmd.pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053014350 vos_mem_copy(pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr,
14351 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014352 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
14353 if( !HAL_STATUS_SUCCESS( status ) )
14354 {
14355 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014356 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014357 }
14358 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014359 return (status);
14360}
Jeff Johnson295189b2012-06-20 16:38:30 -070014361eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14362{
14363 return csrSendMBDelSelfStaReqMsg( pMac,
14364 pCommand->u.delStaSessionCmd.selfMacAddr );
14365}
Jeff Johnson295189b2012-06-20 16:38:30 -070014366static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
14367{
14368 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
14369 tListElem *pEntry, *pNext;
14370 tSmeCmd *pCommand;
14371 tDblLinkList localList;
14372
14373 vos_mem_zero(&localList, sizeof(tDblLinkList));
14374 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
14375 {
14376 smsLog(pMac, LOGE, FL(" failed to open list"));
14377 return;
14378 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014379 csrLLLock(pList);
14380 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
14381 while(pEntry != NULL)
14382 {
14383 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
14384 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14385 if(pCommand->sessionId == sessionId)
14386 {
14387 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
14388 {
14389 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
14390 }
14391 }
14392 pEntry = pNext;
14393 }
14394 csrLLUnlock(pList);
14395
14396 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
14397 {
14398 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14399 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
14400 }
14401 csrLLClose(&localList);
14402}
14403
Jeff Johnson295189b2012-06-20 16:38:30 -070014404void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
14405{
14406 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14407 {
14408 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014409 csrRoamStop(pMac, sessionId);
14410 csrFreeConnectBssDesc(pMac, sessionId);
14411 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
14412 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014413 vos_timer_destroy(&pSession->hTimerRoaming);
Jeff Johnson295189b2012-06-20 16:38:30 -070014414#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014415 vos_timer_destroy(&pSession->hTimerJoinRetry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014416#endif
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014417 purgeSmeSessionCmdList(pMac, sessionId, &pMac->sme.smeCmdPendingList);
14418 if (pMac->fScanOffload)
14419 {
14420 purgeSmeSessionCmdList(pMac, sessionId,
14421 &pMac->sme.smeScanCmdPendingList);
14422 }
14423
Jeff Johnson295189b2012-06-20 16:38:30 -070014424 purgeCsrSessionCmdList(pMac, sessionId);
14425 csrInitSession(pMac, sessionId);
14426 }
14427}
14428
Jeff Johnson295189b2012-06-20 16:38:30 -070014429eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
14430 tANI_BOOLEAN fSync,
14431 csrRoamSessionCloseCallback callback,
14432 void *pContext )
14433{
14434 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014435 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14436 {
14437 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14438 if(fSync)
14439 {
14440 csrCleanupSession(pMac, sessionId);
14441 }
14442 else
14443 {
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014444 purgeSmeSessionCmdList(pMac, sessionId,
14445 &pMac->sme.smeCmdPendingList);
14446 if (pMac->fScanOffload)
14447 {
14448 purgeSmeSessionCmdList(pMac, sessionId,
14449 &pMac->sme.smeScanCmdPendingList);
14450 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014451 purgeCsrSessionCmdList(pMac, sessionId);
14452 status = csrIssueDelStaForSessionReq( pMac, sessionId,
14453 pSession->selfMacAddr, callback, pContext);
14454 }
14455 }
14456 else
14457 {
14458 status = eHAL_STATUS_INVALID_PARAMETER;
14459 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014460 return ( status );
14461}
14462
Jeff Johnson295189b2012-06-20 16:38:30 -070014463static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
14464{
14465 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014466
14467 if(!pSession)
14468 {
14469 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14470 return;
14471 }
14472
Jeff Johnson295189b2012-06-20 16:38:30 -070014473 pSession->sessionActive = eANI_BOOLEAN_FALSE;
14474 pSession->sessionId = CSR_SESSION_ID_INVALID;
14475 pSession->callback = NULL;
14476 pSession->pContext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014477 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
14478 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
14479 csrFreeRoamProfile( pMac, sessionId );
14480 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
14481 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
14482 csrFreeConnectBssDesc(pMac, sessionId);
14483 csrScanEnable(pMac);
Kiet Lam64c1b492013-07-12 13:56:44 +053014484 vos_mem_set(&pSession->selfMacAddr, sizeof(tCsrBssid), 0);
14485 if (pSession->pWpaRsnReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014486 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014487 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014488 pSession->pWpaRsnReqIE = NULL;
14489 }
14490 pSession->nWpaRsnReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014491 if (pSession->pWpaRsnRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014492 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014493 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014494 pSession->pWpaRsnRspIE = NULL;
14495 }
14496 pSession->nWpaRsnRspIeLength = 0;
14497#ifdef FEATURE_WLAN_WAPI
Kiet Lam64c1b492013-07-12 13:56:44 +053014498 if (pSession->pWapiReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014499 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014500 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014501 pSession->pWapiReqIE = NULL;
14502 }
14503 pSession->nWapiReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014504 if (pSession->pWapiRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014505 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014506 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014507 pSession->pWapiRspIE = NULL;
14508 }
14509 pSession->nWapiRspIeLength = 0;
14510#endif /* FEATURE_WLAN_WAPI */
Agarwal Ashish4f616132013-12-30 23:32:50 +053014511 if (pSession->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070014512 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053014513 memset(pSession->addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH);
Jeff Johnson295189b2012-06-20 16:38:30 -070014514 }
14515 pSession->nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053014516
Kiet Lam64c1b492013-07-12 13:56:44 +053014517 if (pSession->pAddIEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070014518 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014519 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070014520 pSession->pAddIEAssoc = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053014521 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014522 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014523}
14524
Jeff Johnson295189b2012-06-20 16:38:30 -070014525eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
14526{
14527 eHalStatus status = eHAL_STATUS_FAILURE;
14528 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070014529 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14530 {
14531 if( CSR_IS_SESSION_VALID( pMac, i ) )
14532 {
14533 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
14534 {
14535 //Found it
14536 status = eHAL_STATUS_SUCCESS;
14537 *pSessionId = i;
14538 break;
14539 }
14540 }
14541 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014542 return( status );
14543}
14544
Jeff Johnson295189b2012-06-20 16:38:30 -070014545//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
14546//session because for IBSS, the bssid changes.
14547static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
14548{
14549 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
14550 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070014551 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14552 {
14553 if( CSR_IS_SESSION_VALID( pMac, i ) )
14554 {
14555 pSession = CSR_GET_SESSION( pMac, i );
14556 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
14557 {
14558 //Found it
14559 nRet = i;
14560 break;
14561 }
14562 }
14563 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014564 return (nRet);
14565}
Jeff Johnson295189b2012-06-20 16:38:30 -070014566static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
14567{
14568 /* Update the current BSS info in ho control block based on connected
14569 profile info from pmac global structure */
14570
Arif Hussain24bafea2013-11-15 15:10:03 -080014571 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= "MAC_ADDRESS_STR,
14572 MAC_ADDR_ARRAY(bssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070014573 /* Check for user misconfig of RSSI trigger threshold */
14574 pMac->roam.configParam.vccRssiThreshold =
14575 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
14576 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
14577 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070014578 /* Check for user misconfig of UL MAC Loss trigger threshold */
14579 pMac->roam.configParam.vccUlMacLossThreshold =
14580 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
14581 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014582#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14583 {
14584 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014585 /* Indicate the neighbor roal algorithm about the connect indication */
14586 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
14587 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
14588 }
14589#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014590}
14591
Jeff Johnson295189b2012-06-20 16:38:30 -070014592static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
14593{
14594 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014595
14596 if(!pSession)
14597 {
14598 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14599 return;
14600 }
14601
Jeff Johnson295189b2012-06-20 16:38:30 -070014602 //Only to handle the case for Handover on infra link
14603 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
14604 {
14605 return;
14606 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014607 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
14608 csrRoamDeregStatisticsReq(pMac);
14609 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14610#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14611 /* Indicate the neighbor roal algorithm about the disconnect indication */
14612 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
14613#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070014614
14615 //Remove this code once SLM_Sessionization is supported
14616 //BMPS_WORKAROUND_NOT_NEEDED
14617 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070014618 csrIsInfraApStarted( pMac ) &&
14619 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070014620 {
14621 pMac->roam.configParam.doBMPSWorkaround = 0;
14622 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014623}
14624
Jeff Johnson295189b2012-06-20 16:38:30 -070014625void csrRoamTlStatsTimerHandler(void *pv)
14626{
14627 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
14628 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014629 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14630
Jeff Johnsone7245742012-09-05 17:12:55 -070014631 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
14632
Jeff Johnson295189b2012-06-20 16:38:30 -070014633#if 0
14634 // TODO Persession .???
14635 //req TL for stats
14636 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
14637 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014638 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014639 }
14640 else
14641 {
14642 //save in SME
14643 csrRoamSaveStatsFromTl(pMac, tlStats);
14644 }
14645#endif
14646 if(!pMac->roam.tlStatsReqInfo.timerRunning)
14647 {
14648 if(pMac->roam.tlStatsReqInfo.periodicity)
14649 {
14650 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014651 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
14652 pMac->roam.tlStatsReqInfo.periodicity);
14653 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014654 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014655 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014656 return;
14657 }
14658 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
14659 }
14660 }
14661}
Jeff Johnson295189b2012-06-20 16:38:30 -070014662void csrRoamPeStatsTimerHandler(void *pv)
14663{
14664 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
14665 eHalStatus status;
14666 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
14667 VOS_STATUS vosStatus;
14668 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070014669 pPeStatsReqListEntry->timerRunning = FALSE;
14670 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
14671 {
14672 // If we entered here, meaning the timer could not be successfully
14673 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
14674
14675 /* Destroy the timer */
14676 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
14677 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14678 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014679 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014680 }
14681
14682 // Free the entry
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014683 vos_mem_free(pPeStatsReqListEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014684 pPeStatsReqListEntry = NULL;
14685 }
14686 else
14687 {
14688 if(!pPeStatsReqListEntry->rspPending)
14689 {
14690 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
14691 pPeStatsReqListEntry->staId);
14692 if(!HAL_STATUS_SUCCESS(status))
14693 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014694 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014695 }
14696 else
14697 {
14698 pPeStatsReqListEntry->rspPending = TRUE;
14699 }
14700 }
14701
14702 //send down a req
14703 if(pPeStatsReqListEntry->periodicity &&
14704 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
14705 {
14706 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
14707 if(ePMC_FULL_POWER == powerState)
14708 {
14709 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
14710 {
14711 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
14712 }
14713 }
14714 else
14715 {
14716 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
14717 {
14718 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
14719 }
14720 }
14721 //start timer
14722 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
14723 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14724 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014725 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014726 return;
14727 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014728 pPeStatsReqListEntry->timerRunning = TRUE;
14729
14730 }
14731
14732 }
14733}
Jeff Johnson295189b2012-06-20 16:38:30 -070014734void csrRoamStatsClientTimerHandler(void *pv)
14735{
14736 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070014737 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
14738 {
14739#if 0
14740 // TODO Stats fix for multisession
14741 //start the timer
14742 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
14743
14744 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14745 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014746 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014747 }
14748#endif
14749 }
14750#if 0
14751 //send up the stats report
14752 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
14753 pStaEntry->staId, pStaEntry->pContext);
14754#endif
14755}
14756
14757
14758
Jeff Johnson295189b2012-06-20 16:38:30 -070014759eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
14760{
14761 tAniGetPEStatsReq *pMsg;
14762 eHalStatus status = eHAL_STATUS_SUCCESS;
Kiet Lam64c1b492013-07-12 13:56:44 +053014763 pMsg = vos_mem_malloc(sizeof(tAniGetPEStatsReq));
14764 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070014765 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053014766 smsLog(pMac, LOGE, FL( "Failed to allocate mem for stats req "));
Kiet Lam64c1b492013-07-12 13:56:44 +053014767 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014768 }
14769 // need to initiate a stats request to PE
14770 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_STATISTICS_REQ);
14771 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
14772 pMsg->staId = staId;
14773 pMsg->statsMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070014774 status = palSendMBMessage(pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070014775 if(!HAL_STATUS_SUCCESS(status))
14776 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053014777 smsLog(pMac, LOG1, FL("Failed to send down the stats req "));
Jeff Johnson295189b2012-06-20 16:38:30 -070014778 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014779 return status;
14780}
Jeff Johnson295189b2012-06-20 16:38:30 -070014781void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
14782{
14783 tAniGetPEStatsRsp *pSmeStatsRsp;
14784 eHalStatus status = eHAL_STATUS_FAILURE;
14785 tListElem *pEntry = NULL;
14786 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
14787 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
14788 tANI_U32 tempMask = 0;
14789 tANI_U8 counter = 0;
14790 tANI_U8 *pStats = NULL;
14791 tANI_U32 length = 0;
14792 v_PVOID_t pvosGCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014793 v_S7_t rssi = 0, snr = 0;
14794 tANI_U32 *pRssi = NULL, *pSnr = NULL;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014795 tANI_U32 linkCapacity;
Jeff Johnson295189b2012-06-20 16:38:30 -070014796 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
14797 if(pSmeStatsRsp->rc)
14798 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014799 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014800 goto post_update;
14801 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014802 tempMask = pSmeStatsRsp->statsMask;
14803 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070014804 /* subtract all statistics from this length, and after processing the entire
14805 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
14806 * in this 'stats' message.
14807 */
14808 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070014809 //new stats info from PE, fill up the stats strucutres in PMAC
14810 while(tempMask)
14811 {
14812 if(tempMask & 1)
14813 {
14814 switch(counter)
14815 {
14816 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014817 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014818 vos_mem_copy((tANI_U8 *)&pMac->roam.summaryStatsInfo,
14819 pStats, sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014820 pStats += sizeof(tCsrSummaryStatsInfo);
14821 length -= sizeof(tCsrSummaryStatsInfo);
14822 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014823 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014824 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014825 vos_mem_copy((tANI_U8 *)&pMac->roam.classAStatsInfo,
14826 pStats, sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014827 pStats += sizeof(tCsrGlobalClassAStatsInfo);
14828 length -= sizeof(tCsrGlobalClassAStatsInfo);
14829 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014830 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014831 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014832 vos_mem_copy((tANI_U8 *)&pMac->roam.classBStatsInfo,
14833 pStats, sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014834 pStats += sizeof(tCsrGlobalClassBStatsInfo);
14835 length -= sizeof(tCsrGlobalClassBStatsInfo);
14836 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014837 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014838 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053014839 vos_mem_copy((tANI_U8 *)&pMac->roam.classCStatsInfo,
14840 pStats, sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014841 pStats += sizeof(tCsrGlobalClassCStatsInfo);
14842 length -= sizeof(tCsrGlobalClassCStatsInfo);
14843 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014844 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014845 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014846 if( CSR_MAX_STA > pSmeStatsRsp->staId )
14847 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014848 vos_mem_copy((tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
14849 pStats, sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070014850 }
14851 else
14852 {
14853 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014854 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014855 VOS_ASSERT( 0 );
14856 }
14857 if(!HAL_STATUS_SUCCESS(status))
14858 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014859 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014860 }
14861 pStats += sizeof(tCsrPerStaStatsInfo);
14862 length -= sizeof(tCsrPerStaStatsInfo);
14863 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014864 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014865 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014866 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014867 }
14868 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014869 tempMask >>=1;
14870 counter++;
14871 }
14872 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
14873 if (length != 0)
14874 {
14875 pRssi = (tANI_U32*)pStats;
14876 rssi = (v_S7_t)*pRssi;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014877 pStats += sizeof(tANI_U32);
14878 length -= sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070014879 }
14880 else
14881 {
14882 /* If riva is not sending rssi, continue to use the hack */
14883 rssi = RSSI_HACK_BMPS;
14884 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014885
Jeff Johnson295189b2012-06-20 16:38:30 -070014886 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014887
14888 if (length != 0)
14889 {
14890 linkCapacity = *(tANI_U32*)pStats;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014891 pStats += sizeof(tANI_U32);
14892 length -= sizeof(tANI_U32);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053014893 }
14894 else
14895 {
14896 linkCapacity = 0;
14897 }
14898
14899 WDA_UpdateLinkCapacity(pvosGCtx, pSmeStatsRsp->staId, linkCapacity);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053014900
14901 if (length != 0)
14902 {
14903 pSnr = (tANI_U32*)pStats;
14904 snr = (v_S7_t)*pSnr;
14905 }
14906 else
14907 {
14908 snr = SNR_HACK_BMPS;
14909 }
14910
14911 WDA_UpdateSnrBmps(pvosGCtx, pSmeStatsRsp->staId, snr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014912post_update:
14913 //make sure to update the pe stats req list
14914 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
14915 if(pEntry)
14916 {
14917 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
14918 pPeStaEntry->rspPending = FALSE;
14919
14920 }
14921 //check the one timer cases
14922 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
14923 if(pEntry)
14924 {
Jeff Johnson295189b2012-06-20 16:38:30 -070014925 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014926 if(pTempStaEntry->timerExpired)
14927 {
14928 //send up the stats report
14929 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
14930 pTempStaEntry->staId, pTempStaEntry->pContext);
14931 //also remove from the client list
14932 csrRoamRemoveStatListEntry(pMac, pEntry);
14933 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014934 }
14935 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014936}
Jeff Johnson295189b2012-06-20 16:38:30 -070014937tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14938{
14939 tListElem *pEntry = NULL;
14940 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014941 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014942 if(!pEntry)
14943 {
14944 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014945 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070014946 return NULL;
14947 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014948 while( pEntry )
14949 {
14950 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014951 if(pTempStaEntry->statsMask == statsMask)
14952 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014953 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014954 break;
14955 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014956 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
14957 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014958 return pEntry;
14959}
14960
Jeff Johnson295189b2012-06-20 16:38:30 -070014961tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
14962 tANI_BOOLEAN update)
14963{
14964 tListElem *pEntry;
14965 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014966 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014967 if(!pEntry)
14968 {
14969 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070014970 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014971 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070014972 return NULL;
14973 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014974 while( pEntry )
14975 {
14976 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070014977 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
14978 (pTempStaEntry->statsMask == pStaEntry->statsMask))
14979 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014980 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070014981 if(update)
14982 {
Jeff Johnsone7245742012-09-05 17:12:55 -070014983 pTempStaEntry->periodicity = pStaEntry->periodicity;
14984 pTempStaEntry->callback = pStaEntry->callback;
14985 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070014986 }
14987 break;
14988 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014989 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
14990 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014991 return pEntry;
14992}
Jeff Johnson295189b2012-06-20 16:38:30 -070014993tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
14994{
14995 tListElem *pEntry;
14996 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070014997 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070014998 if(!pEntry)
14999 {
15000 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070015001 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015002 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070015003 return NULL;
15004 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015005 while( pEntry )
15006 {
15007 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015008 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
15009 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015010 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015011 break;
15012 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015013 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
15014 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015015 return pEntry;
15016}
Jeff Johnson295189b2012-06-20 16:38:30 -070015017eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
15018 csrRoamLinkQualityIndCallback callback,
15019 void *pContext)
15020{
15021 pMac->roam.linkQualityIndInfo.callback = callback;
15022 pMac->roam.linkQualityIndInfo.context = pContext;
15023 if( NULL == callback )
15024 {
15025 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
15026 }
15027 else
15028 {
15029 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070015030 /* do we need to invoke the callback to notify client of initial value ?? */
15031 }
15032 return eHAL_STATUS_SUCCESS;
15033}
Jeff Johnson295189b2012-06-20 16:38:30 -070015034void csrRoamVccTrigger(tpAniSirGlobal pMac)
15035{
15036 eCsrRoamLinkQualityInd newVccLinkQuality;
15037 tANI_U32 ul_mac_loss = 0;
15038 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070015039 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
15040 /*-------------------------------------------------------------------------
15041 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070015042 Check for a change in link quality and notify client if necessary
15043 -------------------------------------------------------------------------*/
15044 ul_mac_loss_trigger_threshold =
15045 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070015046 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015047 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015048 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070015049 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
15050 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015051 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070015052 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
15053 }
15054 else
15055 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015056 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070015057 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
15058 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015059 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
15060 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070015061 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
15062 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015063 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070015064 if(NULL != pMac->roam.linkQualityIndInfo.callback)
15065 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015066 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015067 newVccLinkQuality );
15068
15069 /* we now invoke the callback once to notify client of initial value */
15070 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
15071 pMac->roam.linkQualityIndInfo.context );
15072 //event: EVENT_WLAN_VCC
15073 }
15074 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015075 pMac->roam.vccLinkQuality = newVccLinkQuality;
15076
Jeff Johnson295189b2012-06-20 16:38:30 -070015077}
Jeff Johnson295189b2012-06-20 16:38:30 -070015078VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
15079 v_U8_t rssiNotification,
15080 void * context)
15081{
15082 tpAniSirGlobal pMac = PMAC_STRUCT( context );
15083 eCsrRoamLinkQualityInd newVccLinkQuality;
15084 // TODO : Session info unavailable
15085 tANI_U32 sessionId = 0;
15086 VOS_STATUS status = VOS_STATUS_SUCCESS;
15087 /*-------------------------------------------------------------------------
15088 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070015089 Check for a change in link quality and notify client if necessary
15090 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015091 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015092 pMac->roam.configParam.vccRssiThreshold);
15093 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
15094 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015095 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070015096 return VOS_STATUS_SUCCESS;
15097 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015098 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
15099 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015100 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070015101 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
15102 }
15103 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
15104 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015105 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070015106 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
15107 }
15108 else
15109 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015110 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070015111 //Set to this so the code below won't do anything
15112 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070015113 VOS_ASSERT(0);
15114 }
15115
Jeff Johnson295189b2012-06-20 16:38:30 -070015116 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
15117 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015118 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070015119 if(NULL != pMac->roam.linkQualityIndInfo.callback)
15120 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015121 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015122 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070015123 /* we now invoke the callback once to notify client of initial value */
15124 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
15125 pMac->roam.linkQualityIndInfo.context );
15126 //event: EVENT_WLAN_VCC
15127 }
15128 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015129 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070015130 return status;
15131}
Jeff Johnson295189b2012-06-20 16:38:30 -070015132tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
15133 tDblLinkList *pStaList,
15134 tCsrStatsClientReqInfo *pStaEntry)
15135{
15136 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015137 //if same entity requested for same set of stats with different periodicity &
15138 // callback update it
15139 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
15140 {
15141
Kiet Lam64c1b492013-07-12 13:56:44 +053015142 pNewStaEntry = vos_mem_malloc(sizeof(tCsrStatsClientReqInfo));
15143 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015144 {
15145 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015146 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070015147 return NULL;
15148 }
15149
Jeff Johnson295189b2012-06-20 16:38:30 -070015150 pNewStaEntry->callback = pStaEntry->callback;
15151 pNewStaEntry->pContext = pStaEntry->pContext;
15152 pNewStaEntry->periodicity = pStaEntry->periodicity;
15153 pNewStaEntry->requesterId = pStaEntry->requesterId;
15154 pNewStaEntry->statsMask = pStaEntry->statsMask;
15155 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
15156 pNewStaEntry->pMac = pStaEntry->pMac;
15157 pNewStaEntry->staId = pStaEntry->staId;
15158 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
15159
15160 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
15161 }
15162 return pNewStaEntry;
15163}
15164
Jeff Johnson295189b2012-06-20 16:38:30 -070015165tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
15166 tDblLinkList *pStaList,
15167 tCsrPeStatsReqInfo *pStaEntry)
15168{
15169 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053015170 pNewStaEntry = vos_mem_malloc(sizeof(tCsrPeStatsReqInfo));
15171 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015172 {
15173 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015174 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070015175 return NULL;
15176 }
15177
Jeff Johnson295189b2012-06-20 16:38:30 -070015178 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
15179 pNewStaEntry->numClient = pStaEntry->numClient;
15180 pNewStaEntry->periodicity = pStaEntry->periodicity;
15181 pNewStaEntry->statsMask = pStaEntry->statsMask;
15182 pNewStaEntry->pMac = pStaEntry->pMac;
15183 pNewStaEntry->staId = pStaEntry->staId;
15184 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
15185 pNewStaEntry->rspPending = pStaEntry->rspPending;
15186
15187 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015188 return pNewStaEntry;
15189}
Jeff Johnson295189b2012-06-20 16:38:30 -070015190eHalStatus csrGetRssi(tpAniSirGlobal pMac,
15191 tCsrRssiCallback callback,
15192 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
15193{
15194 eHalStatus status = eHAL_STATUS_SUCCESS;
15195 vos_msg_t msg;
15196 tANI_U32 sessionId;
15197
15198 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015199 smsLog(pMac, LOG2, FL("called"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015200 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
15201 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070015202 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015203 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053015204 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015205 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015206 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
15207
15208 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
15209 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
15210 pMsg->sessionId = sessionId;
15211 pMsg->staId = staId;
15212 pMsg->rssiCallback = callback;
15213 pMsg->pDevContext = pContext;
15214 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070015215 msg.type = eWNI_SME_GET_RSSI_REQ;
15216 msg.bodyptr = pMsg;
15217 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015218 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
15219 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015220 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053015221 vos_mem_free((void *)pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015222 status = eHAL_STATUS_FAILURE;
15223 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015224 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015225 return status;
15226}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015227
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015228eHalStatus csrGetSnr(tpAniSirGlobal pMac,
15229 tCsrSnrCallback callback,
15230 tANI_U8 staId, tCsrBssid bssId,
15231 void *pContext)
15232{
15233 eHalStatus status = eHAL_STATUS_SUCCESS;
15234 vos_msg_t msg;
15235 tANI_U32 sessionId;
15236
15237 tAniGetSnrReq *pMsg;
15238
15239 smsLog(pMac, LOG2, FL("called"));
15240
15241 pMsg =(tAniGetSnrReq *)vos_mem_malloc(sizeof(tAniGetSnrReq));
15242 if (NULL == pMsg )
15243 {
15244 smsLog(pMac, LOGE, "%s: failed to allocate mem for req",__func__);
15245 return status;
15246 }
15247
15248 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
15249
15250 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_SNR_REQ);
15251 pMsg->msgLen = (tANI_U16)sizeof(tAniGetSnrReq);
15252 pMsg->sessionId = sessionId;
15253 pMsg->staId = staId;
15254 pMsg->snrCallback = callback;
15255 pMsg->pDevContext = pContext;
15256 msg.type = eWNI_SME_GET_SNR_REQ;
15257 msg.bodyptr = pMsg;
15258 msg.reserved = 0;
15259
15260 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
15261 {
15262 smsLog(pMac, LOGE, "%s failed to post msg to self", __func__);
15263 vos_mem_free((v_VOID_t *)pMsg);
15264 status = eHAL_STATUS_FAILURE;
15265 }
15266
15267 smsLog(pMac, LOG2, FL("returned"));
15268 return status;
15269}
15270
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015271#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015272eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
15273 tCsrRssiCallback callback,
15274 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
15275{
15276 eHalStatus status = eHAL_STATUS_SUCCESS;
15277 tAniGetRssiReq *pMsg;
15278
Kiet Lam64c1b492013-07-12 13:56:44 +053015279 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
15280 if ( NULL == pMsg )
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015281 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015282 smsLog(pMac, LOGE, FL("Failed to allocate mem for req"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015283 return eHAL_STATUS_FAILURE;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015284 }
15285 // need to initiate a stats request to PE
15286 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
15287 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
15288 pMsg->staId = staId;
15289 pMsg->rssiCallback = callback;
15290 pMsg->pDevContext = pContext;
15291 pMsg->pVosContext = pVosContext;
15292 status = palSendMBMessage(pMac->hHdd, pMsg );
15293 if(!HAL_STATUS_SUCCESS(status))
15294 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015295 smsLog(pMac, LOGE, FL(" Failed to send down get rssi req"));
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070015296 //pMsg is freed by palSendMBMessage
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015297 status = eHAL_STATUS_FAILURE;
15298 }
15299 return status;
15300}
15301#endif
15302
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015303
15304
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015305#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015306eHalStatus csrGetTsmStats(tpAniSirGlobal pMac,
15307 tCsrTsmStatsCallback callback,
15308 tANI_U8 staId,
15309 tCsrBssid bssId,
15310 void *pContext,
15311 void* pVosContext,
15312 tANI_U8 tid)
15313{
15314 eHalStatus status = eHAL_STATUS_SUCCESS;
15315 tAniGetTsmStatsReq *pMsg = NULL;
15316
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015317 pMsg = (tAniGetTsmStatsReq*)vos_mem_malloc(sizeof(tAniGetTsmStatsReq));
15318 if (NULL == pMsg)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015319 {
15320 smsLog(pMac, LOGE, "csrGetTsmStats: failed to allocate mem for req");
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015321 return eHAL_STATUS_FAILED_ALLOC;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015322 }
15323 // need to initiate a stats request to PE
15324 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_TSM_STATS_REQ);
15325 pMsg->msgLen = (tANI_U16)sizeof(tAniGetTsmStatsReq);
15326 pMsg->staId = staId;
15327 pMsg->tid = tid;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015328 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015329 pMsg->tsmStatsCallback = callback;
15330 pMsg->pDevContext = pContext;
15331 pMsg->pVosContext = pVosContext;
15332 status = palSendMBMessage(pMac->hHdd, pMsg );
15333 if(!HAL_STATUS_SUCCESS(status))
15334 {
15335 smsLog(pMac, LOG1, " csrGetTsmStats: failed to send down the rssi req");
15336 //pMsg is freed by palSendMBMessage
15337 status = eHAL_STATUS_FAILURE;
15338 }
15339 return status;
15340}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015341#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015342
15343
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053015344/* ---------------------------------------------------------------------------
15345 \fn csrGetTLSTAState
15346 \helper function to get teh TL STA State whenever the function is called.
15347
15348 \param staId - The staID to be passed to the TL
15349 to get the relevant TL STA State
15350 \return the state as tANI_U16
15351 ---------------------------------------------------------------------------*/
15352tANI_U16 csrGetTLSTAState(tpAniSirGlobal pMac, tANI_U8 staId)
15353{
15354 WLANTL_STAStateType tlSTAState;
15355 tlSTAState = WLANTL_STA_INIT;
15356
15357 //request TL for STA State
15358 if ( !VOS_IS_STATUS_SUCCESS(WLANTL_GetSTAState(pMac->roam.gVosContext, staId, &tlSTAState)) )
15359 {
15360 smsLog(pMac, LOGE, FL("csrGetTLSTAState:couldn't get the STA state from TL"));
15361 }
15362
15363 return tlSTAState;
15364}
15365
Jeff Johnson295189b2012-06-20 16:38:30 -070015366eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
15367 tANI_U32 statsMask,
15368 tCsrStatsCallback callback,
15369 tANI_U32 periodicity, tANI_BOOLEAN cache,
15370 tANI_U8 staId, void *pContext)
15371{
15372 tCsrStatsClientReqInfo staEntry;
15373 tCsrStatsClientReqInfo *pStaEntry = NULL;
15374 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
15375 tListElem *pEntry = NULL;
15376 tANI_BOOLEAN found = FALSE;
15377 eHalStatus status = eHAL_STATUS_SUCCESS;
15378 tANI_BOOLEAN insertInClientList = FALSE;
15379 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070015380 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070015381
15382 if( csrIsAllSessionDisconnected(pMac) )
15383 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015384 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070015385 return eHAL_STATUS_FAILURE;
15386 }
Hanumantha Reddy Pothula449aadf2014-02-07 13:53:35 +053015387
15388 if (csrNeighborMiddleOfRoaming((tHalHandle)pMac))
15389 {
15390 smsLog(pMac, LOG1, FL("in the middle of roaming states"));
15391 return eHAL_STATUS_FAILURE;
15392 }
15393
Jeff Johnson295189b2012-06-20 16:38:30 -070015394 if((!statsMask) && (!callback))
15395 {
15396 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015397 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070015398 return eHAL_STATUS_FAILURE;
15399 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015400 //for the search list method for deregister
15401 staEntry.requesterId = requesterId;
15402 staEntry.statsMask = statsMask;
15403 //requester wants to deregister or just an error
15404 if((statsMask) && (!callback))
15405 {
15406 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
15407 if(!pEntry)
15408 {
15409 //msg
15410 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015411 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015412 return eHAL_STATUS_FAILURE;
15413 }
15414 else
15415 {
15416 //clean up & return
15417 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070015418 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015419 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015420 pStaEntry->pPeStaEntry->numClient--;
15421 //check if we need to delete the entry from peStatsReqList too
15422 if(!pStaEntry->pPeStaEntry->numClient)
15423 {
15424 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
15425 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015426 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070015427
Jeff Johnson295189b2012-06-20 16:38:30 -070015428 //check if we need to stop the tl stats timer too
15429 pMac->roam.tlStatsReqInfo.numClient--;
15430 if(!pMac->roam.tlStatsReqInfo.numClient)
15431 {
15432 if(pMac->roam.tlStatsReqInfo.timerRunning)
15433 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015434 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
15435 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015436 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015437 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015438 return eHAL_STATUS_FAILURE;
15439 }
15440 }
15441 pMac->roam.tlStatsReqInfo.periodicity = 0;
15442 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
15443 }
15444 vos_timer_stop( &pStaEntry->timer );
Jeff Johnson295189b2012-06-20 16:38:30 -070015445 // Destroy the vos timer...
15446 vosStatus = vos_timer_destroy( &pStaEntry->timer );
15447 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15448 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015449 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to destroy Client req timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015450 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015451 csrRoamRemoveStatListEntry(pMac, pEntry);
15452 pStaEntry = NULL;
15453 return eHAL_STATUS_SUCCESS;
15454 }
15455 }
15456
15457 if(cache && !periodicity)
15458 {
15459 //return the cached stats
15460 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15461 }
15462 else
15463 {
15464 //add the request in the client req list
15465 staEntry.callback = callback;
15466 staEntry.pContext = pContext;
15467 staEntry.periodicity = periodicity;
15468 staEntry.pPeStaEntry = NULL;
15469 staEntry.staId = staId;
15470 staEntry.pMac = pMac;
15471 staEntry.timerExpired = FALSE;
15472
15473
Jeff Johnson295189b2012-06-20 16:38:30 -070015474 //if periodic report requested with non cached result from PE/TL
15475 if(periodicity)
15476 {
15477
15478 //if looking for stats from PE
15479 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15480 {
15481
15482 //check if same request made already & waiting for rsp
15483 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
15484 periodicity, &found, staId);
15485 if(!pPeStaEntry)
15486 {
15487 //bail out, maxed out on number of req for PE
15488 return eHAL_STATUS_FAILURE;
15489 }
15490 else
15491 {
15492 staEntry.pPeStaEntry = pPeStaEntry;
15493 }
15494
15495 }
15496 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
15497 if(statsMask & (1 << eCsrGlobalClassDStats))
15498 {
15499 if(cache && pMac->roam.tlStatsReqInfo.numClient)
15500 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015501 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015502 }
15503 else
15504 {
15505
15506 //update periodicity
15507 if(pMac->roam.tlStatsReqInfo.periodicity)
15508 {
15509 pMac->roam.tlStatsReqInfo.periodicity =
15510 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
15511 }
15512 else
15513 {
15514 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
15515 }
15516 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
15517 {
15518 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
15519 }
15520
15521 if(!pMac->roam.tlStatsReqInfo.timerRunning)
15522 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015523 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015524 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015525 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015526 //req TL for class D stats
15527 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
15528 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015529 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015530 }
15531 else
15532 {
15533 //save in SME
15534 csrRoamSaveStatsFromTl(pMac, pTlStats);
15535 }
15536 vos_mem_free(pTlStats);
15537 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015538 }
15539 else
15540 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015541 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015542 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015543
Jeff Johnson295189b2012-06-20 16:38:30 -070015544 if(pMac->roam.tlStatsReqInfo.periodicity)
15545 {
15546 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015547 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
15548 pMac->roam.tlStatsReqInfo.periodicity);
15549 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015550 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015551 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015552 return eHAL_STATUS_FAILURE;
15553 }
15554 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
15555 }
15556 }
15557 }
15558 pMac->roam.tlStatsReqInfo.numClient++;
15559 }
15560
15561 insertInClientList = TRUE;
15562 }
15563 //if one time report requested with non cached result from PE/TL
15564 else if(!cache && !periodicity)
15565 {
15566 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15567 {
15568 //send down a req
15569 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
15570 if(!HAL_STATUS_SUCCESS(status))
15571 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015572 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015573 }
15574 //so that when the stats rsp comes back from PE we respond to upper layer
15575 //right away
15576 staEntry.timerExpired = TRUE;
15577 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015578 }
15579 if(statsMask & (1 << eCsrGlobalClassDStats))
15580 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015581 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015582 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015583 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015584 //req TL for class D stats
15585 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
15586 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015587 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015588 }
15589 else
15590 {
15591 //save in SME
15592 csrRoamSaveStatsFromTl(pMac, pTlStats);
15593 }
15594 vos_mem_free(pTlStats);
15595 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015596 }
15597 else
15598 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015599 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015600 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015601
15602 }
15603 //if looking for stats from TL only
15604 if(!insertInClientList)
15605 {
15606 //return the stats
15607 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15608 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015609 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015610 if(insertInClientList)
15611 {
15612 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
15613 if(!pStaEntry)
15614 {
15615 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015616 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015617 return eHAL_STATUS_FAILURE;
15618 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015619 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070015620 //Init & start timer if needed
15621 if(periodicity)
15622 {
15623 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
15624 csrRoamStatsClientTimerHandler, pStaEntry );
15625 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15626 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015627 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015628 return eHAL_STATUS_FAILURE;
15629 }
15630 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
15631 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15632 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015633 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015634 return eHAL_STATUS_FAILURE;
15635 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015636 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015637 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015638 }
15639 return eHAL_STATUS_SUCCESS;
15640}
15641
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015642#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
15643
15644static tSirRetStatus
15645csrRoamScanOffloadPopulateMacHeader(tpAniSirGlobal pMac,
15646 tANI_U8* pBD,
15647 tANI_U8 type,
15648 tANI_U8 subType,
15649 tSirMacAddr peerAddr,
15650 tSirMacAddr selfMacAddr)
15651{
15652 tSirRetStatus statusCode = eSIR_SUCCESS;
15653 tpSirMacMgmtHdr pMacHdr;
15654
15655 /* Prepare MAC management header */
15656 pMacHdr = (tpSirMacMgmtHdr) (pBD);
15657
15658 /* Prepare FC */
15659 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
15660 pMacHdr->fc.type = type;
15661 pMacHdr->fc.subType = subType;
15662
15663 /* Prepare Address 1 */
Kiet Lam64c1b492013-07-12 13:56:44 +053015664 vos_mem_copy((tANI_U8 *) pMacHdr->da, (tANI_U8 *) peerAddr,
15665 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015666
15667 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
15668
15669 /* Prepare Address 3 */
Kiet Lam64c1b492013-07-12 13:56:44 +053015670 vos_mem_copy((tANI_U8 *) pMacHdr->bssId, (tANI_U8 *) peerAddr,
15671 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015672 return statusCode;
15673} /*** csrRoamScanOffloadPopulateMacHeader() ***/
15674
15675static tSirRetStatus
15676csrRoamScanOffloadPrepareProbeReqTemplate(tpAniSirGlobal pMac,
15677 tANI_U8 nChannelNum,
15678 tANI_U32 dot11mode,
15679 tSirMacAddr selfMacAddr,
15680 tANI_U8 *pFrame,
15681 tANI_U16 *pusLen)
15682{
15683 tDot11fProbeRequest pr;
15684 tANI_U32 nStatus, nBytes, nPayload;
15685 tSirRetStatus nSirStatus;
15686 /*Bcast tx*/
15687 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
15688 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
15689
15690
Kiet Lam64c1b492013-07-12 13:56:44 +053015691 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015692
15693 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
15694
15695 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
15696 {
15697 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
15698 }
15699
15700
15701 if (IS_DOT11_MODE_HT(dot11mode))
15702 {
15703 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
15704 }
15705
15706
15707 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
15708 if ( DOT11F_FAILED( nStatus ) )
15709 {
15710 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15711 "Failed to calculate the packed size f"
15712 "or a Probe Request (0x%08x).\n", nStatus );
15713
15714
15715 nPayload = sizeof( tDot11fProbeRequest );
15716 }
15717 else if ( DOT11F_WARNED( nStatus ) )
15718 {
15719 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15720 "There were warnings while calculating"
15721 "the packed size for a Probe Request ("
15722 "0x%08x).\n", nStatus );
15723 }
15724
15725 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
15726
15727 /* Prepare outgoing frame*/
Kiet Lam64c1b492013-07-12 13:56:44 +053015728 vos_mem_set(pFrame, nBytes , 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015729
15730
15731 nSirStatus = csrRoamScanOffloadPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015732 SIR_MAC_MGMT_PROBE_REQ, bssId,selfMacAddr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015733
15734 if ( eSIR_SUCCESS != nSirStatus )
15735 {
15736 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15737 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
15738 nSirStatus );
15739 return nSirStatus;
15740 }
15741
15742
15743 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
15744 sizeof( tSirMacMgmtHdr ),
15745 nPayload, &nPayload );
15746 if ( DOT11F_FAILED( nStatus ) )
15747 {
15748 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15749 "Failed to pack a Probe Request (0x%08x).\n", nStatus );
15750 return eSIR_FAILURE;
15751 }
15752 else if ( DOT11F_WARNED( nStatus ) )
15753 {
15754 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce8ad512013-10-30 12:34:42 -070015755 "There were warnings while packing a Probe Request (0x%08x).\n",
15756 nStatus );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015757 }
15758
15759 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
15760 return eSIR_SUCCESS;
15761}
15762
15763eHalStatus csrRoamOffloadScan(tpAniSirGlobal pMac, tANI_U8 command, tANI_U8 reason)
15764{
15765 vos_msg_t msg;
15766 tSirRoamOffloadScanReq *pRequestBuf;
15767 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
15768 tCsrRoamSession *pSession;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015769 tANI_U8 i,j,num_channels = 0, ucDot11Mode;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015770 tANI_U8 *ChannelList = NULL;
15771 tANI_U32 sessionId;
15772 eHalStatus status = eHAL_STATUS_SUCCESS;
15773 tpCsrChannelInfo currChannelListInfo;
Srinivas Girigowda56076852013-08-20 14:00:50 -070015774 tANI_U32 host_channels = 0;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070015775 tANI_U8 ChannelCacheStr[128] = {0};
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080015776 eCsrBand eBand;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015777 tSirBssDescription *pBssDesc = NULL;
15778 tDot11fBeaconIEs *pIes = NULL;
15779 tANI_U8 minRate = 0, dataRate;
Varun Reddy Yeturu52231ea2014-02-06 12:00:56 -080015780 tANI_U8 operationChannel = 0;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015781
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015782 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
15783
Srinivas Girigowda830bbd02013-06-13 19:44:16 -070015784 if (0 == csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015785 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015786 smsLog( pMac, LOGE,"isRoamOffloadScanEnabled not set");
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015787 return eHAL_STATUS_FAILURE;
15788 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070015789
15790 if ((VOS_TRUE == bRoamScanOffloadStarted) && (ROAM_SCAN_OFFLOAD_START == command))
15791 {
15792 smsLog( pMac, LOGE,"Roam Scan Offload is already started");
15793 return eHAL_STATUS_FAILURE;
15794 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015795 status = csrRoamGetSessionIdFromBSSID(pMac,
15796 (tCsrBssid *)pNeighborRoamInfo->currAPbssid,
15797 &sessionId);
15798 /*The Dynamic Config Items Update may happen even if the state is in INIT.
15799 * It is important to ensure that the command is passed down to the FW only
15800 * if the Infra Station is in a connected state.A connected station could also be
15801 * in a PREAUTH or REASSOC states.So, consider not sending the command down in INIT state.
15802 * We also have to ensure that if there is a STOP command we always have to inform Riva,
15803 * irrespective of whichever state we are in.*/
15804 if ((pMac->roam.neighborRoamInfo.neighborRoamState == eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
15805 (command != ROAM_SCAN_OFFLOAD_STOP))
15806 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053015807 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
15808 FL("Scan Command not sent to FW with state = %s and cmd=%d\n"),
15809 macTraceGetNeighbourRoamState(
15810 pMac->roam.neighborRoamInfo.neighborRoamState), command);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015811 return eHAL_STATUS_FAILURE;
15812 }
15813
15814 if ( !HAL_STATUS_SUCCESS( status ) )
15815 {
15816 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to find the sessionId for Roam Offload scan request", __func__);
15817 return eHAL_STATUS_FAILURE;
15818 }
15819 pSession = CSR_GET_SESSION( pMac, sessionId );
krunal soni587bf012014-02-04 12:35:11 -080015820 if (NULL == pSession)
15821 {
15822 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15823 "%s:pSession is null", __func__);
15824 return eHAL_STATUS_FAILURE;
15825 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015826 pBssDesc = pSession->pConnectBssDesc;
15827 if (pBssDesc == NULL)
15828 {
15829 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: pBssDesc not found for current session", __func__);
15830 return eHAL_STATUS_FAILURE;
15831 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015832 pRequestBuf = vos_mem_malloc(sizeof(tSirRoamOffloadScanReq));
15833 if (NULL == pRequestBuf)
15834 {
15835 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to allocate memory for Roam Offload scan request", __func__);
15836 return eHAL_STATUS_FAILED_ALLOC;
15837 }
15838
Kiet Lam64c1b492013-07-12 13:56:44 +053015839 vos_mem_zero(pRequestBuf, sizeof(tSirRoamOffloadScanReq));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015840 /* If command is STOP, then pass down ScanOffloadEnabled as Zero.This will handle the case of
15841 * host driver reloads, but Riva still up and running*/
Mukul Sharma90506b42014-04-24 13:24:12 +053015842 pRequestBuf->Command = command;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015843 if(command == ROAM_SCAN_OFFLOAD_STOP)
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015844 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015845 pRequestBuf->RoamScanOffloadEnabled = 0;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015846 /*For a STOP Command, there is no need to
15847 * go through filling up all the below parameters
15848 * since they are not required for the STOP command*/
15849 goto send_roam_scan_offload_cmd;
15850 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015851 else
15852 pRequestBuf->RoamScanOffloadEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
Kiet Lam64c1b492013-07-12 13:56:44 +053015853 vos_mem_copy(pRequestBuf->ConnectedNetwork.currAPbssid,
15854 pNeighborRoamInfo->currAPbssid,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015855 sizeof(tCsrBssid));
15856 pRequestBuf->ConnectedNetwork.ssId.length =
15857 pMac->roam.roamSession[sessionId].connectedProfile.SSID.length;
15858 vos_mem_copy(pRequestBuf->ConnectedNetwork.ssId.ssId,
15859 pMac->roam.roamSession[sessionId].connectedProfile.SSID.ssId,
15860 pRequestBuf->ConnectedNetwork.ssId.length);
15861 pRequestBuf->ConnectedNetwork.authentication =
15862 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
15863 pRequestBuf->ConnectedNetwork.encryption =
15864 pMac->roam.roamSession[sessionId].connectedProfile.EncryptionType;
15865 pRequestBuf->ConnectedNetwork.mcencryption =
15866 pMac->roam.roamSession[sessionId].connectedProfile.mcEncryptionType;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015867 if (pNeighborRoamInfo->cfgParams.neighborLookupThreshold)
15868 {
15869 pRequestBuf->LookupThreshold =
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015870 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborLookupThreshold * (-1);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015871 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
15872 }
15873 else
15874 {
15875 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Calculate Adaptive Threshold");
15876 operationChannel = pSession->connectedProfile.operationChannel;
15877
15878 if (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
15879 {
15880 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15881 "%s: csrGetParsedBssDescriptionIEs failed", __func__);
15882 vos_mem_free(pRequestBuf);
15883 return eHAL_STATUS_FAILURE;
15884 }
Kaushik, Sushant5874d032014-02-20 17:22:36 +053015885 if(NULL == pIes)
15886 {
15887 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15888 "%s : pIes is Null", __func__);
15889 return eHAL_STATUS_FAILURE;
15890 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080015891 if (pIes->SuppRates.present)
15892 {
15893 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Number \t Rate");
15894 /*Check for both basic rates and extended rates.*/
15895 for (i = 0; i < pIes->SuppRates.num_rates; i++)
15896 {
15897 /*Check if the Rate is Mandatory or Not*/
15898 if (csrRatesIsDot11RateSupported(pMac, pIes->SuppRates.rates[i])
15899 && (pIes->SuppRates.rates[i] & 0x80))
15900 {
15901 /*Retrieve the actual data rate*/
15902 dataRate = (pIes->SuppRates.rates[i] & 0x7F)/2;
15903 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
15904 if (minRate == 0)
15905 minRate = dataRate;
15906 else
15907 minRate = (minRate < dataRate) ? minRate:dataRate;
15908 }
15909 }
15910
15911 if (pIes->ExtSuppRates.present)
15912 {
15913 for (i = 0; i < pIes->ExtSuppRates.num_rates; i++)
15914 {
15915 /*Check if the Rate is Mandatory or Not*/
15916 if (csrRatesIsDot11RateSupported(pMac, pIes->ExtSuppRates.rates[i])
15917 && (pIes->ExtSuppRates.rates[i] & 0x80))
15918 {
15919 /*Retrieve the actual data rate*/
15920 dataRate = (pIes->ExtSuppRates.rates[i] & 0x7F)/2;
15921 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
15922 if (minRate == 0)
15923 minRate = dataRate;
15924 else
15925 minRate = (minRate < dataRate) ? minRate:dataRate;
15926 }
15927 }
15928 }
15929 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "MinRate = %d", minRate);
15930 }
15931 else
15932 {
15933 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15934 "%s: Supp Rates not present in pIes", __func__);
15935 vos_mem_free(pRequestBuf);
15936 return eHAL_STATUS_FAILURE;
15937 }
15938 if (NULL != pIes)
15939 {
15940 vos_mem_free(pIes);
15941 pIes = NULL;
15942 }
15943 switch (minRate)
15944 {
15945 case 1:
15946 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_1MBPS;
15947 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_1MBPS;
15948 break;
15949 case 2:
15950 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_2MBPS;
15951 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_2MBPS;
15952 break;
15953 case 5:
15954 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_5_5MBPS;
15955 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_5_5MBPS;
15956 break;
15957 case 6:
15958 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
15959 {
15960 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_2G;
15961 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_2G;
15962 }
15963 else
15964 {
15965 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_5G;
15966 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_5G;
15967 }
15968 break;
15969 case 11:
15970 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_11MBPS;
15971 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_11MBPS;
15972 break;
15973 case 12:
15974 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
15975 {
15976 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_2G;
15977 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_2G;
15978 }
15979 else
15980 {
15981 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_5G;
15982 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_5G;
15983 }
15984 break;
15985 case 24:
15986 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
15987 {
15988 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_2G;
15989 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_2G;
15990 }
15991 else
15992 {
15993 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_5G;
15994 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_5G;
15995 }
15996 break;
15997 default:
15998 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_DEFAULT;
15999 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
16000 break;
16001 }
16002 }
16003 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
16004 "Chnl=%d,MinRate=%d,RxSenThr=%d,LookupThr=%d",
16005 operationChannel, minRate,
16006 pRequestBuf->RxSensitivityThreshold,
16007 pRequestBuf->LookupThreshold);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016008 pRequestBuf->RoamRssiDiff =
16009 pMac->roam.configParam.RoamRssiDiff;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016010 pRequestBuf->StartScanReason = reason;
16011 pRequestBuf->NeighborScanTimerPeriod =
16012 pNeighborRoamInfo->cfgParams.neighborScanPeriod;
16013 pRequestBuf->NeighborRoamScanRefreshPeriod =
16014 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod;
16015 pRequestBuf->NeighborScanChannelMinTime =
16016 pNeighborRoamInfo->cfgParams.minChannelScanTime;
16017 pRequestBuf->NeighborScanChannelMaxTime =
16018 pNeighborRoamInfo->cfgParams.maxChannelScanTime;
16019 pRequestBuf->EmptyRefreshScanPeriod =
16020 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -080016021 /* MAWC feature */
16022 pRequestBuf->MAWCEnabled =
16023 pMac->roam.configParam.MAWCEnabled;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016024#ifdef FEATURE_WLAN_ESE
16025 pRequestBuf->IsESEEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016026#endif
16027 if (
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016028#ifdef FEATURE_WLAN_ESE
16029 ((pNeighborRoamInfo->isESEAssoc) &&
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016030 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived ==
16031 eANI_BOOLEAN_FALSE)) ||
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016032 (pNeighborRoamInfo->isESEAssoc == eANI_BOOLEAN_FALSE) ||
16033#endif // ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016034 currChannelListInfo->numOfChannels == 0)
16035 {
16036
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016037 /*Retrieve the Channel Cache either from ini or from the Occupied Channels list.
16038 * Give Preference to INI Channels.*/
16039 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
16040 {
16041 ChannelList = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
16042 /*The INI channels need to be filtered with respect to the current
16043 * band that is supported.*/
16044 eBand = pMac->roam.configParam.bandCapability;
16045 if ((eCSR_BAND_24 != eBand) && (eCSR_BAND_5G != eBand) && (eCSR_BAND_ALL != eBand))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016046 {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016047 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16048 "Invalid band, No operation carried out (Band %d)", eBand);
16049 vos_mem_free(pRequestBuf);
16050 return eHAL_STATUS_FAILURE;
16051 }
16052 for (i=0; i<pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels; i++)
16053 {
16054 if(((eCSR_BAND_24 == eBand) && CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
16055 ((eCSR_BAND_5G == eBand) && CSR_IS_CHANNEL_5GHZ(*ChannelList)) ||
16056 (eCSR_BAND_ALL == eBand))
16057 {
16058 if(!CSR_IS_CHANNEL_DFS(*ChannelList) &&
16059 csrRoamIsChannelValid(pMac, *ChannelList) &&
16060 *ChannelList && (num_channels < SIR_ROAM_MAX_CHANNELS))
16061 {
16062 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
16063 }
16064 }
16065 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016066 }
16067 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16068 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016069 }
16070 else
16071 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016072 ChannelList = pMac->scan.occupiedChannels.channelList;
16073 for(i=0; i<pMac->scan.occupiedChannels.numChannels; i++)
16074 {
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053016075 /*Allow DFS channels only if the DFS channel roam flag is enabled */
16076 if(((pMac->roam.configParam.allowDFSChannelRoam) ||
16077 (!CSR_IS_CHANNEL_DFS(*ChannelList))) &&
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016078 *ChannelList && (num_channels < SIR_ROAM_MAX_CHANNELS))
16079 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016080 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016081 }
16082 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016083 }
16084 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16085 /* If the profile changes as to what it was earlier, inform the FW through
16086 * FLUSH as ChannelCacheType in which case, the FW will flush the occupied channels
16087 * for the earlier profile and try to learn them afresh.*/
16088 if (reason == REASON_FLUSH_CHANNEL_LIST)
16089 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
16090 else {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016091 if (csrNeighborRoamIsNewConnectedProfile(pMac))
16092 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
16093 else
16094 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016095 }
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016096 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016097 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016098#ifdef FEATURE_WLAN_ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016099 else
16100 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016101 /* If ESE is enabled, and a neighbor Report is received,then
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016102 * Ignore the INI Channels or the Occupied Channel List. Consider
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016103 * the channels in the neighbor list sent by the ESE AP.*/
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016104 if (currChannelListInfo->numOfChannels != 0)
16105 {
16106 ChannelList = currChannelListInfo->ChannelList;
16107 for (i=0;i<currChannelListInfo->numOfChannels;i++)
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016108 {
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053016109 if(((pMac->roam.configParam.allowDFSChannelRoam) ||
16110 (!CSR_IS_CHANNEL_DFS(*ChannelList))) && *ChannelList)
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016111 {
16112 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
16113 }
16114 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016115 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016116 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16117 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
16118 }
16119 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016120#endif
Kaushik, Sushant5ed8ab62014-03-05 11:21:11 +053016121 for (i = 0, j = 0;j < (sizeof(ChannelCacheStr)/sizeof(ChannelCacheStr[0])) && i < pRequestBuf->ConnectedNetwork.ChannelCount; i++)
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016122 {
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053016123 if (j < sizeof(ChannelCacheStr))
16124 {
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016125 j += snprintf(ChannelCacheStr + j, sizeof(ChannelCacheStr) - j," %d",
16126 pRequestBuf->ConnectedNetwork.ChannelCache[i]);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053016127 }
16128 else
16129 {
16130 break;
16131 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016132 }
16133 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
16134 "ChnlCacheType:%d, No of Chnls:%d,Channels: %s",
16135 pRequestBuf->ChannelCacheType,
16136 pRequestBuf->ConnectedNetwork.ChannelCount,
16137 ChannelCacheStr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016138 num_channels = 0;
16139 ChannelList = NULL;
16140
16141 /* Maintain the Valid Channels List*/
Srinivas Girigowda56076852013-08-20 14:00:50 -070016142 host_channels = sizeof(pMac->roam.validChannelList);
16143 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &host_channels)))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016144 {
Srinivas Girigowda56076852013-08-20 14:00:50 -070016145 ChannelList = pMac->roam.validChannelList;
16146 pMac->roam.numValidChannels = host_channels;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016147 }
Srinivas Girigowda56076852013-08-20 14:00:50 -070016148 else
16149 {
16150 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16151 "%s:Failed to get the valid channel list", __func__);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -070016152 vos_mem_free(pRequestBuf);
Srinivas Girigowda56076852013-08-20 14:00:50 -070016153 return eHAL_STATUS_FAILURE;
16154 }
16155 for(i=0; i<pMac->roam.numValidChannels; i++)
16156 {
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053016157 if(((pMac->roam.configParam.allowDFSChannelRoam) ||
16158 (!CSR_IS_CHANNEL_DFS(*ChannelList))) && *ChannelList)
Srinivas Girigowda56076852013-08-20 14:00:50 -070016159 {
16160 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
16161 }
16162 ChannelList++;
16163 }
16164 pRequestBuf->ValidChannelCount = num_channels;
16165
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016166 pRequestBuf->MDID.mdiePresent =
16167 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent;
16168 pRequestBuf->MDID.mobilityDomain =
16169 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mobilityDomain;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016170 pRequestBuf->nProbes = pMac->roam.configParam.nProbes;
16171
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016172 pRequestBuf->HomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016173 /* Home Away Time should be at least equal to (MaxDwell time + (2*RFS)),
16174 * where RFS is the RF Switching time. It is twice RFS to consider the
16175 * time to go off channel and return to the home channel. */
16176 if (pRequestBuf->HomeAwayTime < (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)))
16177 {
16178 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
16179 "%s: Invalid config, Home away time(%d) is less than (twice RF switching time + channel max time)(%d)"
16180 " Hence enforcing home away time to disable (0)",
16181 __func__, pRequestBuf->HomeAwayTime,
16182 (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)));
16183 pRequestBuf->HomeAwayTime = 0;
16184 }
16185 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,"HomeAwayTime:%d",pRequestBuf->HomeAwayTime);
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070016186
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016187 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
16188 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
16189 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
16190 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_24G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
16191 pRequestBuf->p24GProbeTemplate, &pRequestBuf->us24GProbeTemplateLen);
16192
16193 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_5G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
16194 pRequestBuf->p5GProbeTemplate, &pRequestBuf->us5GProbeTemplateLen);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016195send_roam_scan_offload_cmd:
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016196 msg.type = WDA_ROAM_SCAN_OFFLOAD_REQ;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016197 msg.reserved = 0;
16198 msg.bodyptr = pRequestBuf;
16199 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
16200 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016201 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_ROAM_SCAN_OFFLOAD_REQ message to WDA", __func__);
16202 vos_mem_free(pRequestBuf);
16203 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016204 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016205 else
16206 {
16207 if (ROAM_SCAN_OFFLOAD_START == command)
16208 bRoamScanOffloadStarted = VOS_TRUE;
16209 else if (ROAM_SCAN_OFFLOAD_STOP == command)
16210 bRoamScanOffloadStarted = VOS_FALSE;
16211 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016212
16213 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Roam Scan Offload Command %d, Reason %d", command, reason);
16214 return status;
16215}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016216
16217eHalStatus csrRoamOffloadScanRspHdlr(tpAniSirGlobal pMac, tANI_U8 reason)
16218{
16219 switch(reason)
16220 {
16221 case 0:
16222 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with failure status");
16223 break;
16224 case REASON_OS_REQUESTED_ROAMING_NOW:
16225 csrNeighborRoamProceedWithHandoffReq(pMac);
16226 break;
16227 default:
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -070016228 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 -070016229 }
16230 return eHAL_STATUS_SUCCESS;
16231}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016232#endif
16233
Jeff Johnson295189b2012-06-20 16:38:30 -070016234tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
16235 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
16236{
16237 tANI_BOOLEAN found = FALSE;
16238 eHalStatus status = eHAL_STATUS_SUCCESS;
16239 tCsrPeStatsReqInfo staEntry;
16240 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
16241 tListElem *pStaEntry = NULL;
16242 VOS_STATUS vosStatus;
16243 tPmcPowerState powerState;
16244 *pFound = FALSE;
16245
16246 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
16247 if(pStaEntry)
16248 {
16249 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
16250 if(pTempStaEntry->periodicity)
16251 {
16252 pTempStaEntry->periodicity =
16253 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
16254 }
16255 else
16256 {
16257 pTempStaEntry->periodicity = periodicity;
16258 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016259 pTempStaEntry->numClient++;
16260 found = TRUE;
16261 }
16262 else
16263 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016264 vos_mem_set(&staEntry, sizeof(tCsrPeStatsReqInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016265 staEntry.numClient = 1;
16266 staEntry.periodicity = periodicity;
16267 staEntry.pMac = pMac;
16268 staEntry.rspPending = FALSE;
16269 staEntry.staId = staId;
16270 staEntry.statsMask = statsMask;
16271 staEntry.timerRunning = FALSE;
16272 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
16273 if(!pTempStaEntry)
16274 {
16275 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016276 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070016277 return NULL;
16278 }
16279 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016280 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
16281 if(ePMC_FULL_POWER == powerState)
16282 {
16283 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
16284 {
16285 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
16286 }
16287 }
16288 else
16289 {
16290 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
16291 {
16292 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
16293 }
16294 }
16295 if(!pTempStaEntry->timerRunning)
16296 {
16297 //send down a req in case of one time req, for periodic ones wait for timer to expire
16298 if(!pTempStaEntry->rspPending &&
16299 !pTempStaEntry->periodicity)
16300 {
16301 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
16302 if(!HAL_STATUS_SUCCESS(status))
16303 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016304 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016305 }
16306 else
16307 {
16308 pTempStaEntry->rspPending = TRUE;
16309 }
16310 }
16311 if(pTempStaEntry->periodicity)
16312 {
16313 if(!found)
16314 {
16315
16316 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
16317 csrRoamPeStatsTimerHandler, pTempStaEntry );
16318 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16319 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016320 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016321 return NULL;
16322 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016323 }
16324 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016325 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070016326 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
16327 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16328 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016329 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016330 return NULL;
16331 }
16332 pTempStaEntry->timerRunning = TRUE;
16333 }
16334 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016335 *pFound = found;
16336 return pTempStaEntry;
16337}
16338
Jeff Johnson295189b2012-06-20 16:38:30 -070016339/*
16340 pStaEntry is no longer invalid upon the return of this function.
16341*/
16342static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
16343{
16344 if(pEntry)
16345 {
16346 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
16347 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016348 vos_mem_free(GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070016349 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016350 }
16351 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016352
16353void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
16354{
16355 tListElem *pEntry;
16356 tCsrPeStatsReqInfo *pTempStaEntry;
16357 VOS_STATUS vosStatus;
16358 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016359 if(!pEntry)
16360 {
16361 //list empty
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016362 smsLog(pMac, LOGE, FL(" List empty, no stats req for PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016363 return;
16364 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016365 while( pEntry )
16366 {
16367 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016368 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
16369 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016370 smsLog(pMac, LOGW, FL("Match found"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016371 if(pTempStaEntry->timerRunning)
16372 {
16373 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
16374 /* If we are not able to stop the timer here, just remove
16375 * the entry from the linked list. Destroy the timer object
16376 * and free the memory in the timer CB
16377 */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016378 if ( vosStatus == VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -070016379 {
16380 /* the timer is successfully stopped */
16381 pTempStaEntry->timerRunning = FALSE;
16382
16383 /* Destroy the timer */
16384 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
16385 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16386 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016387 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016388 }
16389 }
16390 else
16391 {
16392 // the timer could not be stopped. Hence destroy and free the
16393 // memory for the PE stat entry in the timer CB.
16394 pTempStaEntry->timerStopFailed = TRUE;
16395 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016396 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016397
16398 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
16399 {
16400 // Only free the memory if we could stop the timer successfully
16401 if(!pTempStaEntry->timerStopFailed)
16402 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016403 vos_mem_free(pTempStaEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070016404 pTempStaEntry = NULL;
16405 }
16406 break;
16407 }
16408
16409 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
16410 }
16411 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016412 return;
16413}
16414
16415
Jeff Johnsone7245742012-09-05 17:12:55 -070016416void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070016417{
16418
Jeff Johnsone7245742012-09-05 17:12:55 -070016419 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
16420 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
16421 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
16422 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
16423 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
16424 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
16425 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070016426 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070016427 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
16428 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
16429 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
16430 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
16431 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
16432 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070016433 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070016434 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
16435 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070016436
16437}
16438
Jeff Johnson295189b2012-06-20 16:38:30 -070016439void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
16440 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
16441{
16442 tANI_U8 stats[500];
16443 tANI_U8 *pStats = NULL;
16444 tANI_U32 tempMask = 0;
16445 tANI_U8 counter = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016446 if(!callback)
16447 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016448 smsLog(pMac, LOGE, FL("Cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016449 return;
16450 }
16451 if(!statsMask)
16452 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016453 smsLog(pMac, LOGE, FL("Cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016454 return;
16455 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016456 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070016457 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070016458 while(tempMask)
16459 {
16460 if(tempMask & 1)
16461 {
16462 //new stats info from PE, fill up the stats strucutres in PMAC
16463 switch(counter)
16464 {
16465 case eCsrSummaryStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016466 smsLog( pMac, LOG2, FL("Summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016467 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
16468 sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016469 pStats += sizeof(tCsrSummaryStatsInfo);
16470 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016471 case eCsrGlobalClassAStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016472 smsLog( pMac, LOG2, FL("ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016473 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
16474 sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016475 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016476 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016477 case eCsrGlobalClassBStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016478 smsLog( pMac, LOG2, FL("ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016479 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
16480 sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016481 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016482 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016483 case eCsrGlobalClassCStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016484 smsLog( pMac, LOG2, FL("ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016485 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
16486 sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016487 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016488 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016489 case eCsrGlobalClassDStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016490 smsLog( pMac, LOG2, FL("ClassD stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016491 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
16492 sizeof(tCsrGlobalClassDStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016493 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016494 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016495 case eCsrPerStaStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016496 smsLog( pMac, LOG2, FL("PerSta stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016497 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
16498 sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016499 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016500 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016501 default:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016502 smsLog( pMac, LOGE, FL("Unknown stats type and counter %d"), counter);
Jeff Johnson295189b2012-06-20 16:38:30 -070016503 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016504 }
16505 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016506 tempMask >>=1;
16507 counter++;
16508 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016509 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070016510}
16511
Jeff Johnson295189b2012-06-20 16:38:30 -070016512eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
16513{
16514 tListElem *pEntry = NULL;
16515 tListElem *pPrevEntry = NULL;
16516 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
16517 eHalStatus status = eHAL_STATUS_SUCCESS;
16518 VOS_STATUS vosStatus;
16519 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016520 if(!pEntry)
16521 {
16522 //list empty
16523 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016524 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070016525 return status;
16526 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016527 while( pEntry )
16528 {
16529 if(pPrevEntry)
16530 {
16531 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16532 //send up the stats report
16533 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16534 pTempStaEntry->staId, pTempStaEntry->pContext);
16535 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16536 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016537 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016538 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
16539 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016540 pTempStaEntry->pPeStaEntry->numClient--;
16541 //check if we need to delete the entry from peStatsReqList too
16542 if(!pTempStaEntry->pPeStaEntry->numClient)
16543 {
16544 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
16545 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016546 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016547 //check if we need to stop the tl stats timer too
16548 pMac->roam.tlStatsReqInfo.numClient--;
16549 if(!pMac->roam.tlStatsReqInfo.numClient)
16550 {
16551 if(pMac->roam.tlStatsReqInfo.timerRunning)
16552 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016553 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
16554 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016555 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016556 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016557 //we will continue
16558 }
16559 }
16560 pMac->roam.tlStatsReqInfo.periodicity = 0;
16561 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
16562 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016563 if (pTempStaEntry->periodicity)
16564 {
16565 //While creating StaEntry in csrGetStatistics,
16566 //Initializing and starting timer only when periodicity is set.
16567 //So Stop and Destroy timer only when periodicity is set.
16568
Jeff Johnsone7245742012-09-05 17:12:55 -070016569 vos_timer_stop( &pTempStaEntry->timer );
16570 // Destroy the vos timer...
16571 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
16572 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16573 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016574 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070016575 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016576 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016577
Jeff Johnson295189b2012-06-20 16:38:30 -070016578
16579 pPrevEntry = pEntry;
16580 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
16581 }
16582 //the last one
16583 if(pPrevEntry)
16584 {
16585 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16586 //send up the stats report
16587 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16588 pTempStaEntry->staId, pTempStaEntry->pContext);
16589 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16590 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016591 return status;
16592
16593}
16594
Jeff Johnson295189b2012-06-20 16:38:30 -070016595eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
16596 tRequestFullPowerReason *pReason,
16597 tANI_BOOLEAN *pfNeedPower )
16598{
16599 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
16600 tRequestFullPowerReason reason = eSME_REASON_OTHER;
16601 tPmcState pmcState;
16602 eHalStatus status = eHAL_STATUS_SUCCESS;
16603 // TODO : Session info unavailable
16604 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016605 if( pfNeedPower )
16606 {
16607 *pfNeedPower = eANI_BOOLEAN_FALSE;
16608 }
16609 //We only handle CSR commands
16610 if( !(eSmeCsrCommandMask & pCommand->command) )
16611 {
16612 return eHAL_STATUS_SUCCESS;
16613 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016614 //Check PMC state first
16615 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070016616 switch( pmcState )
16617 {
16618 case REQUEST_IMPS:
16619 case IMPS:
16620 if( eSmeCommandScan == pCommand->command )
16621 {
16622 switch( pCommand->u.scanCmd.reason )
16623 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016624#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
16625 case eCsrScanGetLfrResult:
16626#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016627 case eCsrScanGetResult:
16628 case eCsrScanBGScanAbort:
16629 case eCsrScanBGScanEnable:
16630 case eCsrScanGetScanChnInfo:
16631 //Internal process, no need for full power
16632 fNeedFullPower = eANI_BOOLEAN_FALSE;
16633 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016634 default:
16635 //Other scans are real scan, ask for power
16636 fNeedFullPower = eANI_BOOLEAN_TRUE;
16637 break;
16638 } //switch
16639 }
16640 else
16641 {
16642 //ask for power for roam and status change
16643 fNeedFullPower = eANI_BOOLEAN_TRUE;
16644 }
16645 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016646 case REQUEST_BMPS:
16647 case BMPS:
16648 case REQUEST_START_UAPSD:
16649 case UAPSD:
16650 //We treat WOWL same as BMPS
16651 case REQUEST_ENTER_WOWL:
16652 case WOWL:
16653 if( eSmeCommandRoam == pCommand->command )
16654 {
16655 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
16656 tCsrScanResult *pScanResult;
16657 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070016658 switch ( pCommand->u.roamCmd.roamReason )
16659 {
16660 case eCsrForcedDisassoc:
16661 case eCsrForcedDisassocMICFailure:
16662 reason = eSME_LINK_DISCONNECTED_BY_HDD;
16663 fNeedFullPower = eANI_BOOLEAN_TRUE;
16664 break;
16665 case eCsrSmeIssuedDisassocForHandoff:
16666 case eCsrForcedDeauth:
16667 case eCsrHddIssuedReassocToSameAP:
16668 case eCsrSmeIssuedReassocToSameAP:
16669 fNeedFullPower = eANI_BOOLEAN_TRUE;
16670 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016671 case eCsrCapsChange:
16672 fNeedFullPower = eANI_BOOLEAN_TRUE;
16673 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016674 default:
16675 //Check whether the profile is already connected. If so, no need for full power
16676 //Note: IBSS is ignored for now because we don't support powersave in IBSS
16677 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
16678 {
16679 //Only need to check the first one
16680 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
16681 if( pEntry )
16682 {
16683 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
16684#if 0
16685 // TODO : Session Specific info pConnectBssDesc
16686 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
16687 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
16688 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
16689 {
16690 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
16691 // with Authenticating first. To force this, stop the current association (Disassociate) and
16692 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
16693 // a new Association.
16694 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
16695 {
16696 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
16697 {
16698 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
16699 //No need for full power
16700 //Set the flag so the code later can avoid to do the above
16701 //check again.
16702 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
16703 break;
16704 }
16705 }
16706 }
16707#endif
16708 }
16709 }
16710 //If we are here, full power is needed
16711 fNeedFullPower = eANI_BOOLEAN_TRUE;
16712 break;
16713 }
16714 }
16715 else if( eSmeCommandWmStatusChange == pCommand->command )
16716 {
16717 //need full power for all
16718 fNeedFullPower = eANI_BOOLEAN_TRUE;
16719 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
16720 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016721#ifdef FEATURE_WLAN_TDLS
16722 else if( eSmeCommandTdlsAddPeer == pCommand->command )
16723 {
16724 //TDLS link is getting established. need full power
16725 fNeedFullPower = eANI_BOOLEAN_TRUE;
16726 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
16727 }
16728#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016729 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016730 case REQUEST_STOP_UAPSD:
16731 case REQUEST_EXIT_WOWL:
16732 if( eSmeCommandRoam == pCommand->command )
16733 {
16734 fNeedFullPower = eANI_BOOLEAN_TRUE;
16735 switch ( pCommand->u.roamCmd.roamReason )
16736 {
16737 case eCsrForcedDisassoc:
16738 case eCsrForcedDisassocMICFailure:
16739 reason = eSME_LINK_DISCONNECTED_BY_HDD;
16740 break;
16741 default:
16742 break;
16743 }
16744 }
16745 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016746 case STOPPED:
16747 case REQUEST_STANDBY:
16748 case STANDBY:
16749 case LOW_POWER:
16750 //We are not supposed to do anything
Sushant Kaushike0d2cce2014-04-10 14:36:07 +053016751 smsLog( pMac, LOGE, FL( "cannot process because PMC is in"
16752 " stopped/standby state %s (%d)" ),
16753 sme_PmcStatetoString(pmcState), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070016754 status = eHAL_STATUS_FAILURE;
16755 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016756 case FULL_POWER:
16757 case REQUEST_FULL_POWER:
16758 default:
16759 //No need to ask for full power. This has to be FULL_POWER state
16760 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016761 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070016762 if( pReason )
16763 {
16764 *pReason = reason;
16765 }
16766 if( pfNeedPower )
16767 {
16768 *pfNeedPower = fNeedFullPower;
16769 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016770 return ( status );
16771}
16772
Jeff Johnson295189b2012-06-20 16:38:30 -070016773static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
16774{
16775 eHalStatus status = eHAL_STATUS_SUCCESS;
16776 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
16777 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070016778 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070016779 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
16780 {
16781 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
16782 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016783 return ( status );
16784}
16785
Jeff Johnson295189b2012-06-20 16:38:30 -070016786tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
16787{
16788 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070016789 if( pCmd )
16790 {
16791 pMac->roam.sPendingCommands++;
16792 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016793 return ( pCmd );
16794}
16795
Jeff Johnson295189b2012-06-20 16:38:30 -070016796void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
16797{
16798 if (pMac->roam.sPendingCommands > 0)
16799 {
16800 //All command allocated through csrGetCommandBuffer need to
16801 //decrement the pending count when releasing.
16802 pMac->roam.sPendingCommands--;
16803 smeReleaseCommand( pMac, pCommand );
16804 }
16805 else
16806 {
16807 smsLog(pMac, LOGE, FL( "no pending commands"));
16808 VOS_ASSERT(0);
16809 }
16810}
16811
Jeff Johnson295189b2012-06-20 16:38:30 -070016812//Return SUCCESS is the command is queued, failed
16813eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
16814{
16815 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070016816 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
16817 {
16818 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
16819 pCommand->u.scanCmd.reason);
16820 return eHAL_STATUS_CSR_WRONG_STATE;
16821 }
16822
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016823 if ((pMac->fScanOffload) && (pCommand->command == eSmeCommandScan))
16824 {
16825 csrLLInsertTail(&pMac->sme.smeScanCmdPendingList,
16826 &pCommand->Link, LL_ACCESS_LOCK);
16827 // process the command queue...
16828 smeProcessPendingQueue(pMac);
16829 status = eHAL_STATUS_SUCCESS;
16830 goto end;
16831 }
16832
Jeff Johnson295189b2012-06-20 16:38:30 -070016833 //We can call request full power first before putting the command into pending Q
16834 //because we are holding SME lock at this point.
16835 status = csrRequestFullPower( pMac, pCommand );
16836 if( HAL_STATUS_SUCCESS( status ) )
16837 {
16838 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070016839 //make sure roamCmdPendingList is not empty first
16840 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
16841 if( fNoCmdPending )
16842 {
16843 smePushCommand( pMac, pCommand, fHighPriority );
16844 }
16845 else
16846 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016847 //Other commands are waiting for PMC callback, queue the new command to the pending Q
Jeff Johnson295189b2012-06-20 16:38:30 -070016848 //no list lock is needed since SME lock is held
16849 if( !fHighPriority )
16850 {
16851 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16852 }
16853 else {
16854 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16855 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016856 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016857 }
16858 else if( eHAL_STATUS_PMC_PENDING == status )
16859 {
16860 //no list lock is needed since SME lock is held
16861 if( !fHighPriority )
16862 {
16863 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16864 }
16865 else {
16866 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
16867 }
16868 //Let caller know the command is queue
16869 status = eHAL_STATUS_SUCCESS;
16870 }
16871 else
16872 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016873 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
Jeff Johnson295189b2012-06-20 16:38:30 -070016874 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016875 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070016876 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053016877end:
Jeff Johnson295189b2012-06-20 16:38:30 -070016878 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070016879}
Jeff Johnson295189b2012-06-20 16:38:30 -070016880eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
16881{
16882 eHalStatus status = eHAL_STATUS_SUCCESS;
16883 tSirUpdateAPWPSIEsReq *pMsg;
16884 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
16885
16886 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16887 if (NULL == pSession)
16888 {
16889 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
16890 return eHAL_STATUS_FAILURE;
16891 }
16892
Jeff Johnson295189b2012-06-20 16:38:30 -070016893 do
16894 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016895 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
16896 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
16897 vos_mem_set(pMsg, sizeof(tSirUpdateAPWPSIEsReq), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016898 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
16899
16900 pBuf = (tANI_U8 *)&pMsg->transactionId;
lukez3c809222013-05-03 10:23:02 -070016901 VOS_ASSERT(pBuf);
16902
Jeff Johnson295189b2012-06-20 16:38:30 -070016903 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070016904 // transactionId
16905 *pBuf = 0;
16906 *( pBuf + 1 ) = 0;
16907 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070016908 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053016909 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
16910 sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070016911 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070016912 //sessionId
16913 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070016914 // APWPSIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053016915 vos_mem_copy((tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
Jeff Johnson295189b2012-06-20 16:38:30 -070016916 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070016917 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070016918 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016919 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070016920 return ( status );
16921}
Jeff Johnson295189b2012-06-20 16:38:30 -070016922eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
16923{
16924 eHalStatus status = eHAL_STATUS_SUCCESS;
16925 tSirUpdateAPWPARSNIEsReq *pMsg;
16926 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070016927 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
16928 if (NULL == pSession)
16929 {
16930 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
16931 return eHAL_STATUS_FAILURE;
16932 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016933 do
16934 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016935 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPARSNIEsReq));
16936 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
16937 vos_mem_set(pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016938 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070016939 pBuf = (tANI_U8 *)&pMsg->transactionId;
16940 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070016941 // transactionId
16942 *pBuf = 0;
16943 *( pBuf + 1 ) = 0;
16944 pBuf += sizeof(tANI_U16);
lukez3c809222013-05-03 10:23:02 -070016945 VOS_ASSERT(pBuf);
16946
Jeff Johnson295189b2012-06-20 16:38:30 -070016947 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053016948 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
16949 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070016950 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070016951 // sessionId
16952 *pBuf++ = (tANI_U8)sessionId;
16953
16954 // APWPARSNIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053016955 vos_mem_copy((tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070016956 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070016957 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070016958 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070016959 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070016960 return ( status );
16961}
Jeff Johnson295189b2012-06-20 16:38:30 -070016962
16963#ifdef WLAN_FEATURE_VOWIFI_11R
16964//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
16965eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
16966{
16967 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
16968 tpSirFTPreAuthReq pftPreAuthReq;
16969 tANI_U16 auth_req_len = 0;
16970 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070016971 auth_req_len = sizeof(tSirFTPreAuthReq);
16972 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
Kiet Lam64c1b492013-07-12 13:56:44 +053016973 if (NULL == pftPreAuthReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070016974 {
16975 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
16976 return eHAL_STATUS_RESOURCES;
16977 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016978 // Save the SME Session ID here. We need it while processing the preauth response
16979 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070016980 vos_mem_zero(pftPreAuthReq, auth_req_len);
16981
16982 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
16983 sizeof(pBssDescription->length) + pBssDescription->length);
16984
16985 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
16986
16987 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
16988
Kiet Lam64c1b492013-07-12 13:56:44 +053016989 vos_mem_copy((void *)&pftPreAuthReq->currbssId,
16990 (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
16991 vos_mem_copy((void *)&pftPreAuthReq->preAuthbssId,
16992 (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070016993
Jeff Johnson295189b2012-06-20 16:38:30 -070016994#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080016995 if (csrRoamIs11rAssoc(pMac) &&
16996 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070016997 {
16998 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
Kiet Lam64c1b492013-07-12 13:56:44 +053016999 vos_mem_copy(pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
17000 pMac->ft.ftSmeContext.auth_ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -070017001 }
17002 else
17003#endif
17004 {
17005 pftPreAuthReq->ft_ies_length = 0;
17006 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070017007 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
17008 sizeof(pBssDescription->length) + pBssDescription->length);
17009 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070017010 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
17011}
Jeff Johnson295189b2012-06-20 16:38:30 -070017012/*--------------------------------------------------------------------------
17013 * This will receive and process the FT Pre Auth Rsp from the current
17014 * associated ap.
17015 *
17016 * This will invoke the hdd call back. This is so that hdd can now
17017 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
17018 ------------------------------------------------------------------------*/
17019void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
17020{
17021 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
17022 eHalStatus status = eHAL_STATUS_SUCCESS;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017023#if defined(FEATURE_WLAN_LFR) || defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017024 tCsrRoamInfo roamInfo;
17025#endif
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053017026 eCsrAuthType conn_Auth_type;
Jeff Johnson295189b2012-06-20 16:38:30 -070017027
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070017028#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080017029 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070017030 if (status != eHAL_STATUS_SUCCESS) {
17031 /*
17032 * Bail out if pre-auth was not even processed.
17033 */
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017034 smsLog(pMac, LOGE,FL("Preauth was not processed: %d SessionID: %d"),
17035 status, pFTPreAuthRsp->smeSessionId);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070017036 return;
17037 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017038#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017039 /* The below function calls/timers should be invoked only if the pre-auth is successful */
17040 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
17041 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070017042 // Implies a success
17043 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070017044 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
17045 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
Sandeep Puligilla0c486ca2014-05-24 02:40:49 +053017046 /* No need to notify qos module if this is a non 11r & ESE roam*/
17047 if (csrRoamIs11rAssoc(pMac)
17048#if defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
17049 || csrRoamIsESEAssoc(pMac)
17050#endif
17051 )
Tushnim Bhattacharyya8436d772013-06-26 23:03:29 -070017052 {
17053 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
17054 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017055 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
17056 * actual transition from the current to handoff AP is triggered */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017057 status = vos_timer_start(&pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
17058 60);
Jeff Johnson295189b2012-06-20 16:38:30 -070017059 if (eHAL_STATUS_SUCCESS != status)
17060 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017061 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070017062 return;
17063 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017064 // Save the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053017065 vos_mem_copy((void *)&pMac->ft.ftSmeContext.preAuthbssId,
17066 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070017067 if (csrRoamIs11rAssoc(pMac))
17068 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
17069 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
17070
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017071#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
17072 if (csrRoamIsESEAssoc(pMac))
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017073 {
17074 /* read TSF */
17075 csrRoamReadTSF(pMac, (tANI_U8 *)roamInfo.timestamp);
17076
17077 // Save the bssid from the received response
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080017078 vos_mem_copy((void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017079 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_CCKM_PREAUTH_NOTIFY, 0);
17080 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017081#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017082#ifdef FEATURE_WLAN_LFR
17083 // If Legacy Fast Roaming is enabled, signal the supplicant
17084 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053017085 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017086 {
17087 // Save the bssid from the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053017088 vos_mem_copy((void *)&roamInfo.bssid,
17089 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017090 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
17091 }
17092
17093#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017094
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053017095 // If its an Open Auth, FT IEs are not provided by supplicant
17096 // Hence populate them here
17097 conn_Auth_type = pMac->roam.roamSession[pMac->ft.ftSmeContext.smeSessionId].connectedProfile.AuthType;
17098 pMac->ft.ftSmeContext.addMDIE = FALSE;
17099 if( csrRoamIs11rAssoc(pMac) &&
17100 (conn_Auth_type == eCSR_AUTH_TYPE_OPEN_SYSTEM))
17101 {
17102 tANI_U16 ft_ies_length;
17103 ft_ies_length = pFTPreAuthRsp->ric_ies_length;
17104
17105 if ( (pMac->ft.ftSmeContext.reassoc_ft_ies) &&
17106 (pMac->ft.ftSmeContext.reassoc_ft_ies_length))
17107 {
17108 vos_mem_free(pMac->ft.ftSmeContext.reassoc_ft_ies);
17109 pMac->ft.ftSmeContext.reassoc_ft_ies_length = 0;
17110 }
17111
17112 pMac->ft.ftSmeContext.reassoc_ft_ies = vos_mem_malloc(ft_ies_length);
17113 if ( NULL == pMac->ft.ftSmeContext.reassoc_ft_ies )
17114 {
17115 smsLog( pMac, LOGE, FL("Memory allocation failed for ft_ies"));
17116 }
17117 else
17118 {
17119 // Copy the RIC IEs to reassoc IEs
17120 vos_mem_copy(((tANI_U8 *)pMac->ft.ftSmeContext.reassoc_ft_ies),
17121 (tANI_U8 *)pFTPreAuthRsp->ric_ies,
17122 pFTPreAuthRsp->ric_ies_length);
17123 pMac->ft.ftSmeContext.reassoc_ft_ies_length = ft_ies_length;
17124 pMac->ft.ftSmeContext.addMDIE = TRUE;
17125 }
17126 }
17127
Jeff Johnson295189b2012-06-20 16:38:30 -070017128 // Done with it, init it.
17129 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
17130}
17131#endif
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053017132
Jeff Johnson295189b2012-06-20 16:38:30 -070017133#ifdef FEATURE_WLAN_BTAMP_UT_RF
17134void csrRoamJoinRetryTimerHandler(void *pv)
17135{
17136 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
17137 tpAniSirGlobal pMac = pInfo->pMac;
17138 tANI_U32 sessionId = pInfo->sessionId;
17139 tCsrRoamSession *pSession;
17140
17141 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
17142 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017143 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070017144 pSession = CSR_GET_SESSION( pMac, sessionId );
17145 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
17146 {
17147 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
17148 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017149 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070017150 }
17151 }
17152 }
17153}
Jeff Johnson295189b2012-06-20 16:38:30 -070017154eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
17155{
17156 eHalStatus status = eHAL_STATUS_FAILURE;
17157 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
17158
17159 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
17160 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017161 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070017162 pSession->maxRetryCount--;
17163 pSession->joinRetryTimerInfo.pMac = pMac;
17164 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017165 status = vos_timer_start(&pSession->hTimerJoinRetry, interval/PAL_TIMER_TO_MS_UNIT);
17166 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070017167 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017168 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070017169 }
17170 }
17171 else
17172 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017173 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070017174 pSession->maxRetryCount);
17175 }
17176
17177 return (status);
17178}
Jeff Johnson295189b2012-06-20 16:38:30 -070017179eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
17180{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017181 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070017182 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
17183 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017184 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerJoinRetry));
Jeff Johnson295189b2012-06-20 16:38:30 -070017185 }
17186
17187 return eHAL_STATUS_SUCCESS;
17188}
17189#endif
17190
17191
17192/*
17193 pBuf points to the beginning of the message
17194 LIM packs disassoc rsp as below,
17195 messageType - 2 bytes
17196 messageLength - 2 bytes
17197 sessionId - 1 byte
17198 transactionId - 2 bytes (tANI_U16)
17199 reasonCode - 4 bytes (sizeof(tSirResultCodes))
17200 peerMacAddr - 6 bytes
17201 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
17202*/
17203static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
17204{
17205 if(pBuf && pRsp)
17206 {
17207 pBuf += 4; //skip type and length
17208 pRsp->sessionId = *pBuf++;
17209 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
17210 pBuf += 2;
17211 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
17212 pBuf += 4;
17213 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
17214 }
17215}
17216
Jeff Johnsond13512a2012-07-17 11:42:19 -070017217eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
17218{
17219 static uNvTables nvTables;
17220 eHalStatus status = eHAL_STATUS_SUCCESS;
17221 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
17222
17223 /* read the country code from NV and use it */
17224 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
17225 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017226 vos_mem_copy(pCountry, nvTables.defaultCountryTable.countryCode,
17227 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017228 return status;
17229 }
17230 else
17231 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017232 vos_mem_copy(pCountry, "XXX", WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017233 status = eHAL_STATUS_FAILURE;
17234 return status;
17235 }
17236}
17237
17238eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
17239{
Kiet Lam64c1b492013-07-12 13:56:44 +053017240 vos_mem_copy(pCountry, pMac->scan.countryCode11d, WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017241 return eHAL_STATUS_SUCCESS;
17242}
schang86c22c42013-03-13 18:41:24 -070017243
17244eHalStatus csrSetTxPower(tpAniSirGlobal pMac, v_U8_t sessionId, v_U8_t mW)
17245{
17246 tSirSetTxPowerReq *pMsg = NULL;
17247 eHalStatus status = eHAL_STATUS_SUCCESS;
17248 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17249
17250 if (!pSession)
17251 {
17252 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17253 return eHAL_STATUS_FAILURE;
17254 }
17255
Kiet Lam64c1b492013-07-12 13:56:44 +053017256 pMsg = vos_mem_malloc(sizeof(tSirSetTxPowerReq));
17257 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
17258 vos_mem_set((void *)pMsg, sizeof(tSirSetTxPowerReq), 0);
17259 pMsg->messageType = eWNI_SME_SET_TX_POWER_REQ;
17260 pMsg->length = sizeof(tSirSetTxPowerReq);
17261 pMsg->mwPower = mW;
17262 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
17263 sizeof(tSirMacAddr));
17264 status = palSendMBMessage(pMac->hHdd, pMsg);
17265 if (!HAL_STATUS_SUCCESS(status))
schang86c22c42013-03-13 18:41:24 -070017266 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017267 smsLog(pMac, LOGE, FL(" csr set TX Power Post MSG Fail %d "), status);
17268 //pMsg is freed by palSendMBMessage
schang86c22c42013-03-13 18:41:24 -070017269 }
17270 return status;
17271}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017272
Sandeep Puligilla332ea912014-02-04 00:16:24 +053017273eHalStatus csrHT40StopOBSSScan(tpAniSirGlobal pMac, v_U8_t sessionId)
17274{
17275 tSirSmeHT40OBSSStopScanInd *pMsg = NULL;
17276 eHalStatus status = eHAL_STATUS_SUCCESS;
17277 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17278
17279 if (!pSession)
17280 {
17281 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17282 return eHAL_STATUS_FAILURE;
17283 }
17284 if(IS_HT40_OBSS_SCAN_FEATURE_ENABLE)
17285 {
17286 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSStopScanInd));
Abhishek Singh11aa2902014-05-05 11:52:52 +053017287
17288 if( NULL == pMsg )
17289 {
17290 smsLog(pMac, LOGE, FL("PMsg is NULL "));
17291 return eHAL_STATUS_FAILURE;
17292 }
Sandeep Puligilla332ea912014-02-04 00:16:24 +053017293 vos_mem_zero((void *)pMsg, sizeof(tSirSmeHT40OBSSStopScanInd));
17294 pMsg->messageType = eWNI_SME_HT40_STOP_OBSS_SCAN_IND;
17295 pMsg->length = sizeof(tANI_U8);
17296 pMsg->seesionId = sessionId;
17297 status = palSendMBMessage(pMac->hHdd, pMsg);
17298 if (!HAL_STATUS_SUCCESS(status))
17299 {
17300 smsLog(pMac, LOGE, FL(" csr STOP OBSS SCAN Fail %d "), status);
17301 //pMsg is freed by palSendMBMessage
17302 }
17303 }
17304 else
17305 {
17306 smsLog(pMac, LOGE, FL(" OBSS STOP OBSS SCAN is not supported"));
17307 status = eHAL_STATUS_FAILURE;
17308 }
17309 return status;
17310}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017311/* Returns whether a session is in VOS_STA_MODE...or not */
17312tANI_BOOLEAN csrRoamIsStaMode(tpAniSirGlobal pMac, tANI_U32 sessionId)
17313{
17314 tCsrRoamSession *pSession = NULL;
17315 pSession = CSR_GET_SESSION ( pMac, sessionId );
17316 if(!pSession)
17317 {
17318 smsLog(pMac, LOGE, FL(" %s: session %d not found "), __func__, sessionId);
17319 return eANI_BOOLEAN_FALSE;
17320 }
17321 if ( !CSR_IS_SESSION_VALID ( pMac, sessionId ) )
17322 {
17323 smsLog(pMac, LOGE, FL(" %s: Inactive session"), __func__);
17324 return eANI_BOOLEAN_FALSE;
17325 }
17326 if ( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
17327 {
17328 return eANI_BOOLEAN_FALSE;
17329 }
17330 /* There is a possibility that the above check may fail,because
17331 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
17332 * when it is connected.So,we may sneak through the above check even
17333 * if we are not a STA mode INFRA station. So, if we sneak through
17334 * the above condition, we can use the following check if we are
17335 * really in STA Mode.*/
17336
17337 if ( NULL != pSession->pCurRoamProfile )
17338 {
17339 if ( pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE )
17340 {
17341 return eANI_BOOLEAN_TRUE;
17342 } else {
17343 smsLog(pMac, LOGE, FL(" %s: pCurRoamProfile is NULL\n"), __func__);
17344 return eANI_BOOLEAN_FALSE;
17345 }
17346 }
17347
17348 return eANI_BOOLEAN_FALSE;
17349}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017350
17351#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
17352eHalStatus csrHandoffRequest(tpAniSirGlobal pMac,
17353 tCsrHandoffRequest *pHandoffInfo)
17354{
17355 eHalStatus status = eHAL_STATUS_SUCCESS;
17356 vos_msg_t msg;
17357
17358 tAniHandoffReq *pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053017359 pMsg = vos_mem_malloc(sizeof(tAniHandoffReq));
17360 if ( NULL == pMsg )
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017361 {
17362 smsLog(pMac, LOGE, " csrHandoffRequest: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053017363 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017364 }
17365 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_HANDOFF_REQ);
17366 pMsg->msgLen = (tANI_U16)sizeof(tAniHandoffReq);
17367 pMsg->sessionId = pMac->roam.neighborRoamInfo.csrSessionId;
17368 pMsg->channel = pHandoffInfo->channel;
Kiet Lam64c1b492013-07-12 13:56:44 +053017369 vos_mem_copy(pMsg->bssid,
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017370 pHandoffInfo->bssid,
17371 6);
17372 msg.type = eWNI_SME_HANDOFF_REQ;
17373 msg.bodyptr = pMsg;
17374 msg.reserved = 0;
17375 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
17376 {
17377 smsLog(pMac, LOGE, " csrHandoffRequest failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053017378 vos_mem_free((void *)pMsg);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017379 status = eHAL_STATUS_FAILURE;
17380 }
17381 return status;
17382}
17383#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017384
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017385
17386#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017387/* ---------------------------------------------------------------------------
17388 \fn csrSetCCKMIe
17389 \brief This function stores the CCKM IE passed by the supplicant in a place holder
17390 data structure and this IE will be packed inside reassociation request
17391 \param pMac - pMac global structure
17392 \param sessionId - Current session id
17393 \param pCckmIe - pointer to CCKM IE data
17394 \param ccKmIeLen - length of the CCKM IE
17395 \- return Success or failure
17396 -------------------------------------------------------------------------*/
17397VOS_STATUS csrSetCCKMIe(tpAniSirGlobal pMac, const tANI_U8 sessionId,
17398 const tANI_U8 *pCckmIe,
17399 const tANI_U8 ccKmIeLen)
17400{
17401 eHalStatus status = eHAL_STATUS_SUCCESS;
17402 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17403
17404 if (!pSession)
17405 {
17406 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17407 return eHAL_STATUS_FAILURE;
17408 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053017409 vos_mem_copy(pSession->suppCckmIeInfo.cckmIe, pCckmIe, ccKmIeLen);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017410 pSession->suppCckmIeInfo.cckmIeLen = ccKmIeLen;
17411 return status;
17412}
17413
17414/* ---------------------------------------------------------------------------
17415 \fn csrRoamReadTSF
17416 \brief This function reads the TSF; and also add the time elapsed since last beacon or
17417 probe response reception from the hand off AP to arrive at the latest TSF value.
17418 \param pMac - pMac global structure
17419 \param pTimestamp - output TSF timestamp
17420 \- return Success or failure
17421 -------------------------------------------------------------------------*/
17422VOS_STATUS csrRoamReadTSF(tpAniSirGlobal pMac, tANI_U8 *pTimestamp)
17423{
17424 eHalStatus status = eHAL_STATUS_SUCCESS;
17425 tCsrNeighborRoamBSSInfo handoffNode;
17426 tANI_U32 timer_diff = 0;
17427 tANI_U32 timeStamp[2];
17428 tpSirBssDescription pBssDescription = NULL;
17429
17430 csrNeighborRoamGetHandoffAPInfo(pMac, &handoffNode);
17431 pBssDescription = handoffNode.pBssDescription;
17432
17433 // Get the time diff in milli seconds
17434 timer_diff = vos_timer_get_system_time() - pBssDescription->scanSysTimeMsec;
17435 // Convert msec to micro sec timer
17436 timer_diff = (tANI_U32)(timer_diff * SYSTEM_TIME_MSEC_TO_USEC);
17437
17438 timeStamp[0] = pBssDescription->timeStamp[0];
17439 timeStamp[1] = pBssDescription->timeStamp[1];
17440
17441 UpdateCCKMTSF(&(timeStamp[0]), &(timeStamp[1]), &timer_diff);
17442
Kiet Lamf2f201e2013-11-16 21:24:16 +053017443 vos_mem_copy(pTimestamp, (void *) &timeStamp[0],
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017444 sizeof (tANI_U32) * 2);
17445 return status;
17446}
17447
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017448#endif /*FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017449